本文整理了Java中org.rocksdb.RocksDB.getLongProperty
方法的一些代码示例,展示了RocksDB.getLongProperty
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RocksDB.getLongProperty
方法的具体详情如下:
包路径:org.rocksdb.RocksDB
类名称:RocksDB
方法名:getLongProperty
[英]Similar to GetProperty(), but only works for a subset of properties whose return value is a numerical value. Return the value as long.
Note: As the returned property is of type uint64_t on C++ side the returning value can be negative because Java supports in Java 7 only signed long values.
Java 7: To mitigate the problem of the non existent unsigned long tpye, values should be encapsulated using java.math.BigInteger to reflect the correct value. The correct behavior is guaranteed if 2^64 is added to negative values.
Java 8: In Java 8 the value should be treated as unsigned long using provided methods of type Long.
[中]与GetProperty()类似,但仅适用于返回值为数值的属性子集。尽可能长地返回值。
注意:由于返回属性是C++侧的UTIN 64类型,返回值可以是负的,因为java支持java 7只签名长值。
Java7:为了缓解不存在无符号长tpye的问题,应该使用Java封装值。数学BigInteger以反映正确的值。如果将2^64添加到负值,则保证行为正确。
Java 8:在Java 8中,应该使用提供的long类型的方法将该值视为无符号long。
代码示例来源:origin: apache/flink
/**
* Updates the value of metricView if the reference is still valid.
*/
private void setProperty(ColumnFamilyHandle handle, String property, RocksDBNativeMetricView metricView) {
if (metricView.isClosed()) {
return;
}
try {
synchronized (lock) {
if (rocksDB != null) {
long value = rocksDB.getLongProperty(handle, property);
metricView.setValue(value);
}
}
} catch (RocksDBException e) {
metricView.close();
LOG.warn("Failed to read native metric %s from RocksDB", property, e);
}
}
代码示例来源:origin: opendedup/sdfs
public long setUp() throws Exception {
long sz = 0;
// System.out.println("s="+i);
sz += dbs.getLongProperty("rocksdb.estimate-num-keys");
long size = sz;
this.closed = false;
return size;
}
代码示例来源:origin: opendedup/sdfs
/**
* initializes the Object set of this hash table.
*
* @param initialCapacity
* an <code>int</code> value
* @return an <code>int</code> value
* @throws HashtableFullException
* @throws FileNotFoundException
*/
public long setUp() throws Exception {
long sz = 0;
for (RocksDB db : dbs) {
// System.out.println("s="+i);
sz += db.getLongProperty("rocksdb.estimate-num-keys");
}
long size = sz;
this.closed = false;
return size;
}
代码示例来源:origin: opendedup/sdfs
/**
* initializes the Object set of this hash table.
*
* @param initialCapacity
* an <code>int</code> value
* @return an <code>int</code> value
* @throws HashtableFullException
* @throws FileNotFoundException
*/
public long setUp() throws Exception {
long sz = 0;
for (RocksDB db : dbs) {
// System.out.println("s="+i);
sz += db.getLongProperty("rocksdb.estimate-num-keys");
}
long size = sz;
this.closed = false;
return size;
}
代码示例来源:origin: org.apache.bookkeeper/bookkeeper-server
@Override
public long count() throws IOException {
try {
return db.getLongProperty("rocksdb.estimate-num-keys");
} catch (RocksDBException e) {
throw new IOException("Error in getting records count", e);
}
}
代码示例来源:origin: dremio/dremio-oss
private void append(StringBuilder sb, String propName, String propDisplayName) throws RocksDBException {
sb.append("* ");
sb.append(propDisplayName);
sb.append(": ");
sb.append(db.getLongProperty(handle, propName));
sb.append("\n");
}
代码示例来源:origin: org.rocksdb/rocksdbjni
/**
* <p> Similar to GetProperty(), but only works for a subset of properties
* whose return value is a numerical value. Return the value as long.</p>
*
* <p><strong>Note</strong>: As the returned property is of type
* {@code uint64_t} on C++ side the returning value can be negative
* because Java supports in Java 7 only signed long values.</p>
*
* <p><strong>Java 7</strong>: To mitigate the problem of the non
* existent unsigned long tpye, values should be encapsulated using
* {@link java.math.BigInteger} to reflect the correct value. The correct
* behavior is guaranteed if {@code 2^64} is added to negative values.</p>
*
* <p><strong>Java 8</strong>: In Java 8 the value should be treated as
* unsigned long using provided methods of type {@link Long}.</p>
*
* @param property to be fetched.
*
* @return numerical property value.
*
* @throws RocksDBException if an error happens in the underlying native code.
*/
public long getLongProperty(final String property) throws RocksDBException {
return getLongProperty(nativeHandle_, property, property.length());
}
代码示例来源:origin: org.rocksdb/rocksdbjni
/**
* <p> Similar to GetProperty(), but only works for a subset of properties
* whose return value is a numerical value. Return the value as long.</p>
*
* <p><strong>Note</strong>: As the returned property is of type
* {@code uint64_t} on C++ side the returning value can be negative
* because Java supports in Java 7 only signed long values.</p>
*
* <p><strong>Java 7</strong>: To mitigate the problem of the non
* existent unsigned long tpye, values should be encapsulated using
* {@link java.math.BigInteger} to reflect the correct value. The correct
* behavior is guaranteed if {@code 2^64} is added to negative values.</p>
*
* <p><strong>Java 8</strong>: In Java 8 the value should be treated as
* unsigned long using provided methods of type {@link Long}.</p>
*
* @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
* instance
* @param property to be fetched.
*
* @return numerical property value
*
* @throws RocksDBException if an error happens in the underlying native code.
*/
public long getLongProperty(final ColumnFamilyHandle columnFamilyHandle,
final String property) throws RocksDBException {
return getLongProperty(nativeHandle_, columnFamilyHandle.nativeHandle_,
property, property.length());
}
代码示例来源:origin: opendedup/sdfs
public long getSize() {
try {
long sz = 0;
sz = dbs.getLongProperty("rocksdb.estimate-num-keys");
return sz;
} catch (RocksDBException e) {
SDFSLogger.getLog().error("unable to get lenght for rocksdb", e);
return 0;
}
}
代码示例来源:origin: opendedup/sdfs
@Override
public long getSize() {
try {
long sz = 0;
for (RocksDB db : dbs) {
sz += db.getLongProperty("rocksdb.estimate-num-keys");
}
return sz;
} catch (RocksDBException e) {
SDFSLogger.getLog().error("unable to get lenght for rocksdb", e);
return 0;
}
}
代码示例来源:origin: opendedup/sdfs
@Override
public long getUsedSize() {
try {
long sz = 0;
for (RocksDB db : dbs) {
sz += db.getLongProperty("rocksdb.estimate-num-keys");
}
return sz * Main.CHUNK_LENGTH;
} catch (RocksDBException e) {
SDFSLogger.getLog().error("unable to get lenght for rocksdb", e);
return 0;
}
}
代码示例来源:origin: opendedup/sdfs
@Override
public long getUsedSize() {
try {
long sz = 0;
for (RocksDB db : dbs) {
sz += db.getLongProperty("rocksdb.estimate-num-keys");
}
return sz * Main.CHUNK_LENGTH;
} catch (RocksDBException e) {
SDFSLogger.getLog().error("unable to get lenght for rocksdb", e);
return 0;
}
}
代码示例来源:origin: opendedup/sdfs
@Override
public long getSize() {
try {
long sz = 0;
for (RocksDB db : dbs) {
sz += db.getLongProperty("rocksdb.estimate-num-keys");
}
return sz;
} catch (RocksDBException e) {
SDFSLogger.getLog().error("unable to get lenght for rocksdb", e);
return 0;
}
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.11
/**
* Updates the value of metricView if the reference is still valid.
*/
private void setProperty(ColumnFamilyHandle handle, String property, RocksDBNativeMetricView metricView) {
if (metricView.isClosed()) {
return;
}
try {
synchronized (lock) {
if (rocksDB != null) {
long value = rocksDB.getLongProperty(handle, property);
metricView.setValue(value);
}
}
} catch (RocksDBException e) {
metricView.close();
LOG.warn("Failed to read native metric %s from RocksDB", property, e);
}
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb
/**
* Updates the value of metricView if the reference is still valid.
*/
private void setProperty(ColumnFamilyHandle handle, String property, RocksDBNativeMetricView metricView) {
if (metricView.isClosed()) {
return;
}
try {
synchronized (lock) {
if (rocksDB != null) {
long value = rocksDB.getLongProperty(handle, property);
metricView.setValue(value);
}
}
} catch (RocksDBException e) {
metricView.close();
LOG.warn("Failed to read native metric %s from RocksDB", property, e);
}
}
代码示例来源:origin: dremio/dremio-oss
private void registerMetrics() {
final MetricSetBuilder builder = new MetricSetBuilder(MetricRegistry.name(METRICS_PREFIX, name));
for (String property : METRIC_PROPERTIES) {
builder.gauge(property, () -> {
try {
return db.getLongProperty(handle, property);
} catch (RocksDBException e) {
// throwing an exception would cause Dropwizard's metrics reporter to not report the remaining metrics
logger.warn("failed to retrieve property '{}", property, e);
return null;
}
});
}
Metrics.getInstance().registerAll(builder.build());
}
代码示例来源:origin: org.apache.kafka/kafka-streams
/**
* Return an approximate count of key-value mappings in this store.
*
* <code>RocksDB</code> cannot return an exact entry count without doing a
* full scan, so this method relies on the <code>rocksdb.estimate-num-keys</code>
* property to get an approximate count. The returned size also includes
* a count of dirty keys in the store's in-memory cache, which may lead to some
* double-counting of entries and inflate the estimate.
*
* @return an approximate count of key-value mappings in the store.
*/
@Override
public long approximateNumEntries() {
validateStoreOpen();
final long value;
try {
value = db.getLongProperty("rocksdb.estimate-num-keys");
} catch (final RocksDBException e) {
throw new ProcessorStateException("Error fetching property from store " + name, e);
}
if (isOverflowing(value)) {
return Long.MAX_VALUE;
}
return value;
}
内容来源于网络,如有侵权,请联系作者删除!