org.rocksdb.Options.prepareForBulkLoad()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(196)

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

Options.prepareForBulkLoad介绍

[英]Set appropriate parameters for bulk loading. The reason that this is a function that returns "this" instead of a constructor is to enable chaining of multiple similar calls in the future.

All data will be in level 0 without any automatic compaction. It's recommended to manually call CompactRange(NULL, NULL) before reading from the database, because otherwise the read can be very slow.
[中]为批量装载设置适当的参数。这是一个返回“this”而不是构造函数的函数,其原因是为了在将来启用多个类似调用的链接。
所有数据将处于0级,无需任何自动压缩。建议在从数据库读取之前手动调用CompactRange(NULL,NULL),否则读取速度可能会非常慢。

代码示例

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

/**
 * <p>Set appropriate parameters for bulk loading.
 * The reason that this is a function that returns "this" instead of a
 * constructor is to enable chaining of multiple similar calls in the future.
 * </p>
 *
 * <p>All data will be in level 0 without any automatic compaction.
 * It's recommended to manually call CompactRange(NULL, NULL) before reading
 * from the database, because otherwise the read can be very slow.</p>
 *
 * @return the instance of the current Options.
 */
public Options prepareForBulkLoad() {
 prepareForBulkLoad(nativeHandle_);
 return this;
}

代码示例来源:origin: nlpie/biomedicus

@Override
public SuffixDataStore createSuffixDataStore(int id) {
 RocksDB.loadLibrary();
 try (Options options = new Options().setCreateIfMissing(true).prepareForBulkLoad()) {
  Files.createDirectories(dbPath);
  RocksDB rocksDB = RocksDB.open(options, dbPath.resolve(getSuffixesName(id)).toString());
  rocksDBS.add(rocksDB);
  return new RocksDbSuffixDataStore(rocksDB);
 } catch (RocksDBException | IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: nlpie/biomedicus

@Override
public KnownWordsDataStore createKnownWordsDataStore(int id) {
 RocksDB.loadLibrary();
 try (Options options = new Options().setCreateIfMissing(true).prepareForBulkLoad()) {
  Files.createDirectories(dbPath);
  RocksDB rocksDB = RocksDB.open(options, dbPath.resolve(getWordsName(id)).toString());
  rocksDBS.add(rocksDB);
  RocksDB candidatesDB = RocksDB.open(options, dbPath.resolve(getCandidatesName(id)).toString());
  rocksDBS.add(candidatesDB);
  return new RocksDbKnownWordsDataStore(rocksDB, candidatesDB);
 } catch (RocksDBException | IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: nlpie/biomedicus

public RocksDBSenseVectors(Path path, boolean forWriting) {
 RocksDB.loadLibrary();
 if (forWriting) {
  try (Options options = new Options().setCreateIfMissing(true).prepareForBulkLoad()) {
   rocksDB = RocksDB.open(options, path.toString());
  } catch (RocksDBException e) {
   throw new RuntimeException(e);
  }
 } else {
  try {
   rocksDB = RocksDB.openReadOnly(path.toString());
  } catch (RocksDBException e) {
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: nlpie/biomedicus

@Override
void setOutputPath(Path outputPath) {
 try {
  Files.createDirectories(outputPath);
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
 try (Options options = new Options().setCreateIfMissing(true).prepareForBulkLoad()){
  try {
   words = new RocksDbTermIndexBuilder(
     RocksDB.open(options, outputPath.resolve("wordsTerms").toString()),
     RocksDB.open(options, outputPath.resolve("wordsIndices").toString()));
   terms = new RocksDbTermIndexBuilder(
     RocksDB.open(options, outputPath.resolve("termsTerms").toString()),
     RocksDB.open(options, outputPath.resolve("termsIndices").toString()));
   norms = new RocksDbTermIndexBuilder(
     RocksDB.open(options, outputPath.resolve("normsTerms").toString()),
     RocksDB.open(options, outputPath.resolve("normsIndices").toString()));
  } catch (RocksDBException e) {
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: locationtech/geowave

public synchronized RocksDBDataIndexTable getDataIndexTable(
  final String tableName,
  final short adapterId) {
 if (indexWriteOptions == null) {
  RocksDB.loadLibrary();
  final int cores = Runtime.getRuntime().availableProcessors();
  indexWriteOptions =
    new Options().setCreateIfMissing(true).prepareForBulkLoad().setIncreaseParallelism(cores);
  indexReadOptions = new Options().setIncreaseParallelism(cores);
 }
 final String directory = subDirectory + "/" + tableName;
 return dataIndexTableCache.get(
   (DataIndexCacheKey) keyCache.get(directory, d -> new DataIndexCacheKey(d, adapterId)));
}

代码示例来源:origin: locationtech/geowave

public synchronized RocksDBIndexTable getIndexTable(
  final String tableName,
  final short adapterId,
  final byte[] partition,
  final boolean requiresTimestamp) {
 if (indexWriteOptions == null) {
  RocksDB.loadLibrary();
  final int cores = Runtime.getRuntime().availableProcessors();
  indexWriteOptions =
    new Options().setCreateIfMissing(true).prepareForBulkLoad().setIncreaseParallelism(cores);
  indexReadOptions = new Options().setIncreaseParallelism(cores);
 }
 final String directory = subDirectory + "/" + tableName;
 return indexTableCache.get(
   (IndexCacheKey) keyCache.get(
     directory,
     d -> new IndexCacheKey(d, adapterId, partition, requiresTimestamp)));
}

代码示例来源:origin: org.apache.kafka/kafka-streams

options.prepareForBulkLoad();

代码示例来源:origin: apache/samza

options.prepareForBulkLoad();

相关文章

Options类方法