public void put( @Nonnull ColumnFamilyHandle handle, @Nonnull byte[] key, @Nonnull byte[] value) throws RocksDBException { batch.put(handle, key, value); if (batch.count() == capacity) { flush(); } }
public void remove( @Nonnull ColumnFamilyHandle handle, @Nonnull byte[] key) throws RocksDBException { batch.remove(handle, key); if (batch.count() == capacity) { flush(); } }
@Override public void close() throws RocksDBException { if (batch.count() != 0) { flush(); } IOUtils.closeQuietly(batch); } }
void deleteMetrics(FilterOptions filter) throws MetricException { try (WriteBatch writeBatch = new WriteBatch(); WriteOptions writeOps = new WriteOptions()) { scanRaw(filter, (RocksDbKey key, RocksDbValue value) -> { writeBatch.remove(key.getRaw()); return true; }); if (writeBatch.count() > 0) { LOG.info("Deleting {} metrics", writeBatch.count()); try { db.write(writeOps, writeBatch); } catch (Exception e) { String message = "Failed delete metrics"; LOG.error(message, e); if (this.failureMeter != null) { this.failureMeter.mark(); } throw new MetricException(message, e); } } } }
/** * Any change in the session */ @Override public boolean hasChanges() { return this.batch.count() > 0; }
/** * Commit all updates(put/delete) to DB */ @Override public Integer commit() { int count = this.batch.count(); if (count <= 0) { return 0; } try { rocksdb().write(this.writeOptions, this.batch); } catch (RocksDBException e) { //this.batch.rollbackToSavePoint(); throw new BackendException(e); } // Clear batch if write() successfully (retained if failed) this.batch.clear(); return count; }
/** * Any change in the session */ @Override public boolean hasChanges() { return this.batch.count() > 0; }
public void put( @Nonnull ColumnFamilyHandle handle, @Nonnull byte[] key, @Nonnull byte[] value) throws RocksDBException { batch.put(handle, key, value); if (batch.count() == capacity) { flush(); } }
public void put( @Nonnull ColumnFamilyHandle handle, @Nonnull byte[] key, @Nonnull byte[] value) throws RocksDBException { batch.put(handle, key, value); if (batch.count() == capacity) { flush(); } }
public void remove( @Nonnull ColumnFamilyHandle handle, @Nonnull byte[] key) throws RocksDBException { batch.remove(handle, key); if (batch.count() == capacity) { flush(); } }
public void remove( @Nonnull ColumnFamilyHandle handle, @Nonnull byte[] key) throws RocksDBException { batch.remove(handle, key); if (batch.count() == capacity) { flush(); } }
@Override public void close() throws RocksDBException { if (batch.count() != 0) { flush(); } IOUtils.closeQuietly(batch); } }
@Override public void close() throws RocksDBException { if (batch.count() != 0) { flush(); } IOUtils.closeQuietly(batch); } }
/** * Commit all updates(put/delete) to DB */ @Override public Integer commit() { int count = this.batch.count(); if (count <= 0) { return 0; } try { rocksdb().write(this.writeOptions, this.batch); } catch (RocksDBException e) { //this.batch.rollbackToSavePoint(); throw new BackendException(e); } // Clear batch if write() successfully (retained if failed) this.batch.clear(); return count; }