org.rocksdb.RocksDB.getUpdatesSince()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(262)

本文整理了Java中org.rocksdb.RocksDB.getUpdatesSince方法的一些代码示例,展示了RocksDB.getUpdatesSince的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RocksDB.getUpdatesSince方法的具体详情如下:
包路径:org.rocksdb.RocksDB
类名称:RocksDB
方法名:getUpdatesSince

RocksDB.getUpdatesSince介绍

[英]Returns an iterator that is positioned at a write-batch containing seq_number. If the sequence number is non existent, it returns an iterator at the first available seq_no after the requested seq_no.

Must set WAL_ttl_seconds or WAL_size_limit_MB to large values to use this api, else the WAL files will get cleared aggressively and the iterator might keep getting invalid before an update is read.
[中]返回一个迭代器,该迭代器位于包含seq_number的写入批处理处。如果序列号不存在,它将在请求的序列号之后的第一个可用序列号处返回一个迭代器。
必须将WAL_ttl_seconds或WAL_size_limit_MB设置为大值才能使用此api,否则WAL文件将被强制清除,并且在读取更新之前迭代器可能会一直无效。

代码示例

代码示例来源:origin: org.rocksdb/rocksdbjni

/**
 * <p>Returns an iterator that is positioned at a write-batch containing
 * seq_number. If the sequence number is non existent, it returns an iterator
 * at the first available seq_no after the requested seq_no.</p>
 *
 * <p>Must set WAL_ttl_seconds or WAL_size_limit_MB to large values to
 * use this api, else the WAL files will get
 * cleared aggressively and the iterator might keep getting invalid before
 * an update is read.</p>
 *
 * @param sequenceNumber sequence number offset
 *
 * @return {@link org.rocksdb.TransactionLogIterator} instance.
 *
 * @throws org.rocksdb.RocksDBException if iterator cannot be retrieved
 *     from native-side.
 */
public TransactionLogIterator getUpdatesSince(final long sequenceNumber)
  throws RocksDBException {
 return new TransactionLogIterator(
   getUpdatesSince(nativeHandle_, sequenceNumber));
}

代码示例来源:origin: dremio/dremio-oss

void replaySince(final long transactionNumber, ReplayHandler replayHandler) {
 try (ReplayHandlerAdapter handler =
      new ReplayHandlerAdapter(db.getDefaultColumnFamily().getID(), replayHandler, handleIdToNameMap);
    TransactionLogIterator iterator = db.getUpdatesSince(transactionNumber)) {
  while (iterator.isValid()) {
   iterator.status();
   final TransactionLogIterator.BatchResult result = iterator.getBatch(); // requires isValid and status check
   LOGGER.debug("Requested sequence number: {}, iterator sequence number: {}",
     transactionNumber, result.sequenceNumber());
   result.writeBatch()
     .iterate(handler);
   if (!iterator.isValid()) {
    break;
   }
   iterator.next(); // requires isValid
  }
  for (String updatedStore : handler.getUpdatedStores()) {
   final long latestTransactionNumber = metadataManager.getLatestTransactionNumber();
   metadataManager.setLatestTransactionNumber(updatedStore, latestTransactionNumber, latestTransactionNumber);
  }
 } catch (RocksDBException e) {
  throw new DatastoreException(e);
 }
}

相关文章