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


Java ReadOptions.fillCache方法代码示例

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


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

示例1: evictOldStartTimes

import org.iq80.leveldb.ReadOptions; //导入方法依赖的package包/类
@VisibleForTesting
long evictOldStartTimes(long minStartTime) throws IOException {
  LOG.info("Searching for start times to evict earlier than " + minStartTime);

  long batchSize = 0;
  long totalCount = 0;
  long startTimesCount = 0;

  WriteBatch writeBatch = null;
  DBIterator iterator = null;

  try {
    writeBatch = starttimedb.createWriteBatch();
    ReadOptions readOptions = new ReadOptions();
    readOptions.fillCache(false);
    iterator = starttimedb.iterator(readOptions);
    // seek to the first start time entry
    iterator.seekToFirst();

    // evaluate each start time entry to see if it needs to be evicted or not
    while (iterator.hasNext()) {
      Map.Entry<byte[], byte[]> current = iterator.next();
      byte[] entityKey = current.getKey();
      byte[] entityValue = current.getValue();
      long startTime = readReverseOrderedLong(entityValue, 0);
      if (startTime < minStartTime) {
        ++batchSize;
        ++startTimesCount;
        writeBatch.delete(entityKey);

        // a large delete will hold the lock for too long
        if (batchSize >= writeBatchSize) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Preparing to delete a batch of " + batchSize
                + " old start times");
          }
          starttimedb.write(writeBatch);
          if (LOG.isDebugEnabled()) {
            LOG.debug("Deleted batch of " + batchSize
                + ". Total start times deleted so far this cycle: "
                + startTimesCount);
          }
          IOUtils.cleanup(LOG, writeBatch);
          writeBatch = starttimedb.createWriteBatch();
          batchSize = 0;
        }
      }
      ++totalCount;
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("Preparing to delete a batch of " + batchSize
          + " old start times");
    }
    starttimedb.write(writeBatch);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Deleted batch of " + batchSize
          + ". Total start times deleted so far this cycle: "
          + startTimesCount);
    }
    LOG.info("Deleted " + startTimesCount + "/" + totalCount
        + " start time entities earlier than " + minStartTime);
  } finally {
    IOUtils.cleanup(LOG, writeBatch);
    IOUtils.cleanup(LOG, iterator);
  }
  return startTimesCount;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:68,代码来源:RollingLevelDBTimelineStore.java

示例2: getDbIterator

import org.iq80.leveldb.ReadOptions; //导入方法依赖的package包/类
@VisibleForTesting
DBIterator getDbIterator(boolean fillCache) {
  ReadOptions readOptions = new ReadOptions();
  readOptions.fillCache(fillCache);
  return db.iterator(readOptions);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:7,代码来源:LeveldbTimelineStore.java

示例3: evictOldStartTimes

import org.iq80.leveldb.ReadOptions; //导入方法依赖的package包/类
@VisibleForTesting
long evictOldStartTimes(long minStartTime) throws IOException {
  LOG.info("Searching for start times to evict earlier than " + minStartTime);

  long batchSize = 0;
  long totalCount = 0;
  long startTimesCount = 0;

  WriteBatch writeBatch = null;

  ReadOptions readOptions = new ReadOptions();
  readOptions.fillCache(false);
  try (DBIterator iterator = starttimedb.iterator(readOptions)) {

    // seek to the first start time entry
    iterator.seekToFirst();
    writeBatch = starttimedb.createWriteBatch();

    // evaluate each start time entry to see if it needs to be evicted or not
    while (iterator.hasNext()) {
      Map.Entry<byte[], byte[]> current = iterator.next();
      byte[] entityKey = current.getKey();
      byte[] entityValue = current.getValue();
      long startTime = readReverseOrderedLong(entityValue, 0);
      if (startTime < minStartTime) {
        ++batchSize;
        ++startTimesCount;
        writeBatch.delete(entityKey);

        // a large delete will hold the lock for too long
        if (batchSize >= writeBatchSize) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Preparing to delete a batch of " + batchSize
                + " old start times");
          }
          starttimedb.write(writeBatch);
          if (LOG.isDebugEnabled()) {
            LOG.debug("Deleted batch of " + batchSize
                + ". Total start times deleted so far this cycle: "
                + startTimesCount);
          }
          IOUtils.cleanup(LOG, writeBatch);
          writeBatch = starttimedb.createWriteBatch();
          batchSize = 0;
        }
      }
      ++totalCount;
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("Preparing to delete a batch of " + batchSize
          + " old start times");
    }
    starttimedb.write(writeBatch);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Deleted batch of " + batchSize
          + ". Total start times deleted so far this cycle: "
          + startTimesCount);
    }
    LOG.info("Deleted " + startTimesCount + "/" + totalCount
        + " start time entities earlier than " + minStartTime);
  } finally {
    IOUtils.cleanup(LOG, writeBatch);
  }
  return startTimesCount;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:66,代码来源:RollingLevelDBTimelineStore.java


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