当前位置: 首页>>代码示例>>Java>>正文


Java WriteOptions.sync方法代码示例

本文整理汇总了Java中org.iq80.leveldb.WriteOptions.sync方法的典型用法代码示例。如果您正苦于以下问题:Java WriteOptions.sync方法的具体用法?Java WriteOptions.sync怎么用?Java WriteOptions.sync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.iq80.leveldb.WriteOptions的用法示例。


在下文中一共展示了WriteOptions.sync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkStartTimeInDb

import org.iq80.leveldb.WriteOptions; //导入方法依赖的package包/类
/**
 * Checks db for start time and returns it if it exists.  If it doesn't
 * exist, writes the suggested start time (if it is not null).  This is
 * only called when the start time is not found in the cache,
 * so it adds it back into the cache if it is found. Should only be called
 * when a lock has been obtained on the entity.
 */
private StartAndInsertTime checkStartTimeInDb(EntityIdentifier entity,
    Long suggestedStartTime) throws IOException {
  StartAndInsertTime startAndInsertTime = null;
  // create lookup key for start time
  byte[] b = createStartTimeLookupKey(entity.getId(), entity.getType());
  // retrieve value for key
  byte[] v = db.get(b);
  if (v == null) {
    // start time doesn't exist in db
    if (suggestedStartTime == null) {
      return null;
    }
    startAndInsertTime = new StartAndInsertTime(suggestedStartTime,
        System.currentTimeMillis());

    // write suggested start time
    v = new byte[16];
    writeReverseOrderedLong(suggestedStartTime, v, 0);
    writeReverseOrderedLong(startAndInsertTime.insertTime, v, 8);
    WriteOptions writeOptions = new WriteOptions();
    writeOptions.sync(true);
    db.put(b, v, writeOptions);
  } else {
    // found start time in db, so ignore suggested start time
    startAndInsertTime = new StartAndInsertTime(readReverseOrderedLong(v, 0),
        readReverseOrderedLong(v, 8));
  }
  startTimeWriteCache.put(entity, startAndInsertTime);
  startTimeReadCache.put(entity, startAndInsertTime.startTime);
  return startAndInsertTime;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:39,代码来源:LeveldbTimelineStore.java

示例2: deleteSpentTxOutputs

import org.iq80.leveldb.WriteOptions; //导入方法依赖的package包/类
/**
 * Deletes spent transaction outputs that are older than the maximum transaction age
 *
 * @throws      BlockStoreException     Unable to delete spent transaction outputs
 */
@Override
public void deleteSpentTxOutputs() throws BlockStoreException {
    long ageLimit = chainTime - MAX_TX_AGE;
    int txPurged = 0;
    List<byte[]> purgeList = new LinkedList<>();
    synchronized(lock) {
        try {
            //
            // Delete spent transaction outputs
            //
            log.info("Deleting spent transaction outputs");
            try (DBIterator it = dbTxSpent.iterator()) {
                it.seekToFirst();
                while (it.hasNext()) {
                    Entry<byte[], byte[]> dbEntry = it.next();
                    long timeSpent = getLong(dbEntry.getValue());
                    if (timeSpent < ageLimit) {
                        purgeList.add(dbEntry.getKey());
                        txPurged++;
                    }
                }
            }
            WriteOptions options = new WriteOptions();
            options.sync(false);
            for (int i=0; i<purgeList.size(); i++) {
                dbTxSpent.delete(purgeList.get(i), options);
                dbTxOutputs.delete(purgeList.get(i), options);
            }
            log.info(String.format("%,d spent transaction outputs deleted", txPurged));
        } catch (DBException | IOException exc) {
            log.error("Unable to remove spent transactions", exc);
            throw new BlockStoreException("Unable to remove spent transactions");
        }
    }
}
 
开发者ID:shadders,项目名称:JavaBitcoin,代码行数:41,代码来源:BlockStoreLdb.java

示例3: getWriteOptions

import org.iq80.leveldb.WriteOptions; //导入方法依赖的package包/类
public WriteOptions getWriteOptions() {
    WriteOptions options = new WriteOptions();
    options.sync(sync);
    return options;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:LevelDBFile.java


注:本文中的org.iq80.leveldb.WriteOptions.sync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。