Java Code Examples for org.rocksdb.RocksDB#compactRange()
The following examples show how to use
org.rocksdb.RocksDB#compactRange() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractRocksDBTable.java From geowave with Apache License 2.0 | 6 votes |
protected void internalFlush() { if (compactOnWrite) { final RocksDB db = getWriteDb(); try { db.compactRange(); } catch (final RocksDBException e) { LOGGER.warn("Unable to compact range", e); } } // force re-opening a reader to catch the updates from this write if (readerDirty && (readDb != null)) { synchronized (this) { if (readDb != null) { readDb.close(); readDb = null; } } } }
Example 2
Source File: AbstractRocksDBTable.java From geowave with Apache License 2.0 | 5 votes |
public void compact() { final RocksDB db = getWriteDb(); try { db.compactRange(); } catch (final RocksDBException e) { LOGGER.warn("Unable to force compacting range", e); } }
Example 3
Source File: RocksDbUnitTest.java From jstorm with Apache License 2.0 | 5 votes |
private static void rocksDbTest(RocksDB db, List<ColumnFamilyHandle> handlers) { try { ColumnFamilyHandle handler1 = null; ColumnFamilyHandle handler2 = null; if (handlers.size() > 0) { // skip default column family handler1 = handlers.get(1); handler2 = handlers.get(2); } else { handler1 = db.createColumnFamily(new ColumnFamilyDescriptor("test1".getBytes())); handler2 = db.createColumnFamily(new ColumnFamilyDescriptor("test2".getBytes())); } int startValue1 = getStartValue(db, handler1); int startValue2 = getStartValue(db, handler2);; Checkpoint cp = Checkpoint.create(db); if (isCompaction) { db.compactRange(); LOG.info("Compaction!"); } long flushWaitTime = System.currentTimeMillis() + flushInterval; for (int i = 0; i < putNum || putNum == -1; i++) { db.put(handler1, String.valueOf(i % 1000).getBytes(), String.valueOf(startValue1 + i).getBytes()); db.put(handler2, String.valueOf(i % 1000).getBytes(), String.valueOf(startValue2 + i).getBytes()); if (isFlush && flushWaitTime <= System.currentTimeMillis()) { db.flush(new FlushOptions()); if (isCheckpoint) { cp.createCheckpoint(cpPath + "/" + i); } flushWaitTime = System.currentTimeMillis() + flushInterval; } } } catch (RocksDBException e) { LOG.error("Failed to put or flush", e); } }