@Override public void close() { writeBatch.close(); }
@Override public void close() throws IOException { writeBatch.close(); writeOptions.close(); }
@Override public void flush() { try { for(Map.Entry<ByteArray, Map<ByteArray, byte[]>> entry: dataBatches.entrySet()) { WriteBatch writeBatch = new WriteBatch(); WriteOptions writeOptions = new WriteOptions().setDisableWAL(true); for(Map.Entry<ByteArray, byte[]> batchEntry: entry.getValue().entrySet()) { writeBatch.put( cfHandles.get(entry.getKey()), batchEntry.getKey().getBytes(), batchEntry.getValue() ); } rocksDB.write(writeOptions, writeBatch); writeBatch.close(); writeOptions.close(); entry.getValue().clear(); } FlushOptions fOptions = new FlushOptions().setWaitForFlush(true); rocksDB.flush(fOptions); fOptions.close(); } catch(RocksDBException ex) { throw new RuntimeException(ex); } }
@Override public void flush(String keySpace) { Preconditions.checkNotNull(keySpace); ByteArray byteArray = new ByteArray(keySpace); try { WriteBatch writeBatch = new WriteBatch(); WriteOptions writeOptions = new WriteOptions().setDisableWAL(true); for(Map.Entry<ByteArray, byte[]> entry: dataBatches.get(byteArray).entrySet()) { writeBatch.put( cfHandles.get(byteArray), entry.getKey().getBytes(), entry.getValue() ); } rocksDB.write(writeOptions, writeBatch); writeBatch.close(); writeOptions.close(); dataBatches.get(byteArray).clear(); FlushOptions fOptions = new FlushOptions().setWaitForFlush(true); rocksDB.flush(new FlushOptions(), cfHandles.get(byteArray)); fOptions.close(); } catch(RocksDBException ex) { throw new RuntimeException(ex); } }
@Override public void close() throws IOException { db.close(); optionSync.close(); optionDontSync.close(); optionCache.close(); optionDontCache.close(); emptyBatch.close(); }