use of org.rocksdb.WriteBatch in project jstorm by alibaba.
the class RocksDbHdfsState method putBatch.
@Override
public void putBatch(Map<K, V> batch) {
try {
WriteBatch writeBatch = new WriteBatch();
for (Map.Entry<K, V> entry : batch.entrySet()) {
writeBatch.put(serializer.serialize(entry.getKey()), serializer.serialize(entry.getValue()));
}
rocksDb.write(new WriteOptions(), writeBatch);
} catch (RocksDBException e) {
LOG.error("Failed to put batch={}", batch);
throw new RuntimeException(e.getMessage());
}
}
use of org.rocksdb.WriteBatch in project jstorm by alibaba.
the class WindowedRocksDbHdfsState method putBatch.
@Override
public void putBatch(TimeWindow window, Map<K, V> batch) {
try {
ColumnFamilyHandle handler = getColumnFamilyHandle(window);
WriteBatch writeBatch = new WriteBatch();
for (Map.Entry<K, V> entry : batch.entrySet()) {
writeBatch.put(handler, serializer.serialize(entry.getKey()), serializer.serialize(entry.getValue()));
}
rocksDb.write(new WriteOptions(), writeBatch);
} catch (RocksDBException e) {
LOG.error("Failed to put batch={} for window={}", batch, window);
throw new RuntimeException(e.getMessage());
}
}
use of org.rocksdb.WriteBatch in project kafka by apache.
the class RocksDBStore method putAll.
@Override
public void putAll(List<KeyValue<K, V>> entries) {
try (WriteBatch batch = new WriteBatch()) {
for (KeyValue<K, V> entry : entries) {
final byte[] rawKey = serdes.rawKey(entry.key);
if (entry.value == null) {
db.delete(rawKey);
} else {
final byte[] value = serdes.rawValue(entry.value);
batch.put(rawKey, value);
}
}
db.write(wOptions, batch);
} catch (RocksDBException e) {
throw new ProcessorStateException("Error while batch writing to store " + this.name, e);
}
}
use of org.rocksdb.WriteBatch in project bookkeeper by apache.
the class MVCCStoreImpl method processPut.
synchronized PutResult<K, V> processPut(long revision, PutOp<K, V> op) {
checkStoreOpen();
WriteBatch batch = new WriteBatch();
PutResult<K, V> result = null;
try {
result = put(revision, batch, op);
executeBatch(batch);
return result;
} catch (StateStoreRuntimeException e) {
if (null != result) {
result.close();
}
throw e;
} finally {
RocksUtils.close(batch);
}
}
use of org.rocksdb.WriteBatch in project bookkeeper by apache.
the class MVCCStoreImpl method processDelete.
synchronized DeleteResult<K, V> processDelete(long revision, DeleteOp<K, V> op) {
checkStoreOpen();
WriteBatch batch = new WriteBatch();
DeleteResult<K, V> result = null;
try {
result = delete(revision, batch, op, true);
executeBatch(batch);
return result;
} catch (StateStoreRuntimeException e) {
if (null != result) {
result.close();
}
throw e;
} finally {
RocksUtils.close(batch);
}
}
Aggregations