本文整理了Java中org.rocksdb.RocksDB.merge
方法的一些代码示例,展示了RocksDB.merge
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RocksDB.merge
方法的具体详情如下:
包路径:org.rocksdb.RocksDB
类名称:RocksDB
方法名:merge
[英]Add merge operand for key/value pair.
[中]为键/值对添加合并操作数。
代码示例来源:origin: apache/flink
@Override
public void addAll(List<V> values) {
Preconditions.checkNotNull(values, "List of values to add cannot be null.");
if (!values.isEmpty()) {
try {
backend.db.merge(
columnFamily,
writeOptions,
serializeCurrentKeyWithGroupAndNamespace(),
serializeValueList(values, elementSerializer, DELIMITER));
} catch (IOException | RocksDBException e) {
throw new FlinkRuntimeException("Error while updating data to RocksDB", e);
}
}
}
代码示例来源:origin: apache/flink
@Override
public void add(V value) {
Preconditions.checkNotNull(value, "You cannot add null to a ListState.");
try {
backend.db.merge(
columnFamily,
writeOptions,
serializeCurrentKeyWithGroupAndNamespace(),
serializeValue(value, elementSerializer)
);
} catch (Exception e) {
throw new FlinkRuntimeException("Error while adding data to RocksDB", e);
}
}
代码示例来源:origin: apache/flink
@Override
public void mergeNamespaces(N target, Collection<N> sources) {
if (sources == null || sources.isEmpty()) {
return;
}
try {
// create the target full-binary-key
setCurrentNamespace(target);
final byte[] targetKey = serializeCurrentKeyWithGroupAndNamespace();
// merge the sources to the target
for (N source : sources) {
if (source != null) {
setCurrentNamespace(source);
final byte[] sourceKey = serializeCurrentKeyWithGroupAndNamespace();
byte[] valueBytes = backend.db.get(columnFamily, sourceKey);
backend.db.delete(columnFamily, writeOptions, sourceKey);
if (valueBytes != null) {
backend.db.merge(columnFamily, writeOptions, targetKey, valueBytes);
}
}
}
}
catch (Exception e) {
throw new FlinkRuntimeException("Error while merging state in RocksDB", e);
}
}
代码示例来源:origin: hugegraph/hugegraph
/**
* Merge a record to an existing key to a table and commit immediately
*/
@Override
public void increase(String table, byte[] key, byte[] value) {
try {
rocksdb().merge(cf(table), key, value);
} catch (RocksDBException e) {
throw new BackendException(e);
}
}
代码示例来源:origin: org.rocksdb/rocksdbjni
/**
* Add merge operand for key/value pair.
*
* @param key the specified key to be merged.
* @param value the value to be merged with the current value for
* the specified key.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*/
public void merge(final byte[] key, final byte[] value)
throws RocksDBException {
merge(nativeHandle_, key, 0, key.length, value, 0, value.length);
}
代码示例来源:origin: org.rocksdb/rocksdbjni
/**
* Add merge operand for key/value pair in a ColumnFamily.
*
* @param columnFamilyHandle {@link ColumnFamilyHandle} instance
* @param key the specified key to be merged.
* @param value the value to be merged with the current value for
* the specified key.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*/
public void merge(final ColumnFamilyHandle columnFamilyHandle,
final byte[] key, final byte[] value) throws RocksDBException {
merge(nativeHandle_, key, 0, key.length, value, 0, value.length,
columnFamilyHandle.nativeHandle_);
}
代码示例来源:origin: org.rocksdb/rocksdbjni
/**
* Add merge operand for key/value pair.
*
* @param writeOpts {@link WriteOptions} for this write.
* @param key the specified key to be merged.
* @param value the value to be merged with the current value for
* the specified key.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*/
public void merge(final WriteOptions writeOpts, final byte[] key,
final byte[] value) throws RocksDBException {
merge(nativeHandle_, writeOpts.nativeHandle_,
key, 0, key.length, value, 0, value.length);
}
代码示例来源:origin: org.rocksdb/rocksdbjni
/**
* Add merge operand for key/value pair.
*
* @param columnFamilyHandle {@link ColumnFamilyHandle} instance
* @param writeOpts {@link WriteOptions} for this write.
* @param key the specified key to be merged.
* @param value the value to be merged with the current value for
* the specified key.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*/
public void merge(final ColumnFamilyHandle columnFamilyHandle,
final WriteOptions writeOpts, final byte[] key,
final byte[] value) throws RocksDBException {
merge(nativeHandle_, writeOpts.nativeHandle_,
key, 0, key.length, value, 0, value.length,
columnFamilyHandle.nativeHandle_);
}
代码示例来源:origin: weiboad/fiery
public boolean merge(String key, String val) {
if (key.length() == 0) return false;
try {
db.merge(key.getBytes(), val.getBytes());
return true;
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return false;
}
代码示例来源:origin: com.baidu.hugegraph/hugegraph-rocksdb
/**
* Merge a record to an existing key to a table and commit immediately
*/
@Override
public void increase(String table, byte[] key, byte[] value) {
try {
rocksdb().merge(cf(table), key, value);
} catch (RocksDBException e) {
throw new BackendException(e);
}
}
代码示例来源:origin: org.jsimpledb/jsimpledb-kv-rocksdb
@Override
public void adjustCounter(byte[] key, long amount) {
key.getClass();
Preconditions.checkState(!this.closed, "closed");
this.cursorTracker.poll();
final byte[] value = this.encodeCounter(amount);
if (this.writeBatch != null) {
assert RocksDBUtil.isInitialized(this.writeBatch);
synchronized (this.writeBatch) {
this.writeBatch.merge(key, value);
}
} else {
assert RocksDBUtil.isInitialized(this.db);
try {
this.db.merge(key, value);
} catch (RocksDBException e) {
throw new RuntimeException("RocksDB error", e);
}
}
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb
@Override
public void addAll(List<V> values) {
Preconditions.checkNotNull(values, "List of values to add cannot be null.");
if (!values.isEmpty()) {
try {
writeCurrentKeyWithGroupAndNamespace();
byte[] key = dataOutputView.getCopyOfBuffer();
byte[] premerge = getPreMergedValue(values, elementSerializer, dataOutputView);
backend.db.merge(columnFamily, writeOptions, key, premerge);
} catch (IOException | RocksDBException e) {
throw new FlinkRuntimeException("Error while updating data to RocksDB", e);
}
}
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.11
@Override
public void addAll(List<V> values) {
Preconditions.checkNotNull(values, "List of values to add cannot be null.");
if (!values.isEmpty()) {
try {
writeCurrentKeyWithGroupAndNamespace();
byte[] key = dataOutputView.getCopyOfBuffer();
byte[] premerge = getPreMergedValue(values, elementSerializer, dataOutputView);
backend.db.merge(columnFamily, writeOptions, key, premerge);
} catch (IOException | RocksDBException e) {
throw new FlinkRuntimeException("Error while updating data to RocksDB", e);
}
}
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.10
@Override
public void add(V value) throws IOException {
try {
writeCurrentKeyWithGroupAndNamespace();
byte[] key = keySerializationStream.toByteArray();
keySerializationStream.reset();
DataOutputViewStreamWrapper out = new DataOutputViewStreamWrapper(keySerializationStream);
valueSerializer.serialize(value, out);
backend.db.merge(columnFamily, writeOptions, key, keySerializationStream.toByteArray());
} catch (Exception e) {
throw new RuntimeException("Error while adding data to RocksDB", e);
}
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.10
backend.db.merge(columnFamily, writeOptions, targetKey, valueBytes);
代码示例来源:origin: opendedup/sdfs
bk.putLong(10);
for (int i = 0; i < 10000; i++) {
db.merge(k, bk.array());
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.11
@Override
public void add(V value) {
Preconditions.checkNotNull(value, "You cannot add null to a ListState.");
try {
writeCurrentKeyWithGroupAndNamespace();
byte[] key = dataOutputView.getCopyOfBuffer();
dataOutputView.clear();
elementSerializer.serialize(value, dataOutputView);
backend.db.merge(columnFamily, writeOptions, key, dataOutputView.getCopyOfBuffer());
} catch (Exception e) {
throw new FlinkRuntimeException("Error while adding data to RocksDB", e);
}
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb
@Override
public void add(V value) {
Preconditions.checkNotNull(value, "You cannot add null to a ListState.");
try {
writeCurrentKeyWithGroupAndNamespace();
byte[] key = dataOutputView.getCopyOfBuffer();
dataOutputView.clear();
elementSerializer.serialize(value, dataOutputView);
backend.db.merge(columnFamily, writeOptions, key, dataOutputView.getCopyOfBuffer());
} catch (Exception e) {
throw new FlinkRuntimeException("Error while adding data to RocksDB", e);
}
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.11
@Override
public void mergeNamespaces(N target, Collection<N> sources) {
if (sources == null || sources.isEmpty()) {
return;
}
// cache key and namespace
final K key = backend.getCurrentKey();
final int keyGroup = backend.getCurrentKeyGroupIndex();
try {
// create the target full-binary-key
writeKeyWithGroupAndNamespace(keyGroup, key, target, dataOutputView);
final byte[] targetKey = dataOutputView.getCopyOfBuffer();
// merge the sources to the target
for (N source : sources) {
if (source != null) {
writeKeyWithGroupAndNamespace(keyGroup, key, source, dataOutputView);
byte[] sourceKey = dataOutputView.getCopyOfBuffer();
byte[] valueBytes = backend.db.get(columnFamily, sourceKey);
backend.db.delete(columnFamily, writeOptions, sourceKey);
if (valueBytes != null) {
backend.db.merge(columnFamily, writeOptions, targetKey, valueBytes);
}
}
}
}
catch (Exception e) {
throw new FlinkRuntimeException("Error while merging state in RocksDB", e);
}
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb
@Override
public void mergeNamespaces(N target, Collection<N> sources) {
if (sources == null || sources.isEmpty()) {
return;
}
// cache key and namespace
final K key = backend.getCurrentKey();
final int keyGroup = backend.getCurrentKeyGroupIndex();
try {
// create the target full-binary-key
writeKeyWithGroupAndNamespace(keyGroup, key, target, dataOutputView);
final byte[] targetKey = dataOutputView.getCopyOfBuffer();
// merge the sources to the target
for (N source : sources) {
if (source != null) {
writeKeyWithGroupAndNamespace(keyGroup, key, source, dataOutputView);
byte[] sourceKey = dataOutputView.getCopyOfBuffer();
byte[] valueBytes = backend.db.get(columnFamily, sourceKey);
backend.db.delete(columnFamily, writeOptions, sourceKey);
if (valueBytes != null) {
backend.db.merge(columnFamily, writeOptions, targetKey, valueBytes);
}
}
}
}
catch (Exception e) {
throw new FlinkRuntimeException("Error while merging state in RocksDB", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!