本文整理汇总了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;
}
示例2: getDbIterator
import org.iq80.leveldb.ReadOptions; //导入方法依赖的package包/类
@VisibleForTesting
DBIterator getDbIterator(boolean fillCache) {
ReadOptions readOptions = new ReadOptions();
readOptions.fillCache(fillCache);
return db.iterator(readOptions);
}
示例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;
}