Java Code Examples for org.rocksdb.WriteOptions#setSync()

The following examples show how to use org.rocksdb.WriteOptions#setSync() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DBStoreBuilder.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a DBStore instance and returns that.
 *
 * @return DBStore
 */
public DBStore build() throws IOException {
  if(StringUtil.isBlank(dbname) || (dbPath == null)) {
    LOG.error("Required Parameter missing.");
    throw new IOException("Required parameter is missing. Please make sure "
        + "sure Path and DB name is provided.");
  }
  processDBProfile();
  processTables();
  DBOptions options = getDbProfile();

  WriteOptions writeOptions = new WriteOptions();
  writeOptions.setSync(rocksDBConfiguration.getSyncOption());


  File dbFile = getDBFile();
  if (!dbFile.getParentFile().exists()) {
    throw new IOException("The DB destination directory should exist.");
  }
  return new RDBStore(dbFile, options, writeOptions, tables, registry);
}
 
Example 2
Source File: JRocksDB.java    From snowblossom with Apache License 2.0 5 votes vote down vote up
public JRocksDB(Config config)
  throws Exception
{
  super(config);

  use_separate_dbs=config.getBoolean("db_separate");
  
  config.require("db_path");
  
  String path = config.get("db_path");

  base_path = new File(path);

  base_path.mkdirs();

  logger.info(String.format("Loading RocksDB with path %s", path));

  RocksDB.loadLibrary();
  sharedWriteOptions = new WriteOptions();
  sharedWriteOptions.setDisableWAL(false);
  sharedWriteOptions.setSync(false);


  // Separate DBs should only be used when you don't care about syncing between
  // the databases,  If you are fine with writes to them being preserved out of order
  // relative to each other it should be fine.
  // For example, in combined DBs if you write a to A then b to B, you will either get {}, {a}, or {a,b} 
  // on a bad shutdown.  If you use separate, you could very well get {b}.

  if (use_separate_dbs)
  {
    separate_db_map = new TreeMap<>();
  }
  else
  {
    shared_db = openRocksDB(path);
  }

}
 
Example 3
Source File: Builder.java    From act with GNU General Public License v3.0 5 votes vote down vote up
public void processScan(List<Double> targetMZs, File scanFile)
    throws RocksDBException, ParserConfigurationException, XMLStreamException, IOException {
  DateTime start = DateTime.now();
  LOGGER.info("Accessing scan file at %s", scanFile.getAbsolutePath());
  LCMSNetCDFParser parser = new LCMSNetCDFParser();
  Iterator<LCMSSpectrum> spectrumIterator = parser.getIterator(scanFile.getAbsolutePath());

  WriteOptions writeOptions = new WriteOptions();
  /* The write-ahead log and disk synchronization features are useful when we need our writes to be durable (i.e. to
   * survive a crash).  However, our index construction is effectively a one-shot deal: if it doesn't succeed, we'll
   * just start from scratch.  Since we don't care about durability while we're constructing the index, the WAL and
   * sync features eat a lot of disk space and I/O bandwidth, which slows us down.  So long as we cleanly close the
   * index once it's built, nobody has to know that we disabled these features. */
  writeOptions.setDisableWAL(true);
  writeOptions.setSync(false);
  dbAndHandles.setWriteOptions(writeOptions);

  // TODO: split targetMZs into batches of ~100k and extract incrementally to allow huge input sets.

  LOGGER.info("Extracting traces");
  List<MZWindow> windows = targetsToWindows(targetMZs);
  extractTriples(spectrumIterator, windows);

  LOGGER.info("Writing search targets to on-disk index");
  writeWindowsToDB(windows);

  DateTime end = DateTime.now();
  LOGGER.info("Index construction completed in %dms", end.getMillis() - start.getMillis());
}
 
Example 4
Source File: JRocksDB.java    From jelectrum with MIT License 5 votes vote down vote up
public JRocksDB(Config config, EventLog log)
  throws Exception
{
  super(config);

  this.log = log;

  config.require("rocksdb_path");

  String path = config.get("rocksdb_path");

  RocksDB.loadLibrary();
  Options options = new Options();

  options.setIncreaseParallelism(16);
  options.setCreateIfMissing(true);
  options.setAllowMmapReads(true);
  //options.setAllowMmapWrites(true);

  sharedWriteOptions = new WriteOptions();
  sharedWriteOptions.setDisableWAL(true);
  sharedWriteOptions.setSync(false);

  db = RocksDB.open(options, path);

  open();
}