• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ReadOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: replace

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
public static <T extends D_Level> void replace(String cluster, Class<T> clazz, List<T> data) throws IOException {
	DB db = getDB(path(cluster, clazz));
	ReadOptions readOptions = new ReadOptions().snapshot(db.getSnapshot());
	DBIterator iterator = db.iterator(readOptions);
	WriteBatch write = db.createWriteBatch();
	try {
		iterator.seekToFirst();
		iterator.forEachRemaining(entry ->{
			byte[] key = entry.getKey();
			write.delete(key);
		});
		data.forEach(t->{
			write.put(t.key().getBytes(), t.value());
		});
		db.write(write, new WriteOptions().sync(true));
	} finally {
		iterator.close();
		write.close();
	}
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:21,代码来源:LevelTable.java


示例2: last

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T extends D_TimeLine> T last(String cluster, Class<T> clazz) throws IOException {
	DB db = getDB(path(cluster, clazz));
	ReadOptions readOptions = new ReadOptions().snapshot(db.getSnapshot());
	DBIterator iterator = db.iterator(readOptions);
	try {
		iterator.seekToLast();
		if(!iterator.hasNext()){
			return null;
		}
		Entry<byte[], byte[]> entry = iterator.next();
		byte[] v = entry.getValue();
		return (T)D_Level.deserialize(clazz, v);
	} finally {
		iterator.close();
	}
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:18,代码来源:LevelTable.java


示例3: getAll

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T extends D_Level> List<T> getAll(String cluster, Class<T> clazz)throws IOException {
	DB db = getDB(path(cluster, clazz));
	ReadOptions readOptions = new ReadOptions().snapshot(db.getSnapshot());
	DBIterator iterator = db.iterator(readOptions);
	List<T> list = new ArrayList<T>();
	try {
		iterator.seekToFirst();
		iterator.forEachRemaining(entry ->{
			byte[] v = entry.getValue();
			list.add((T)D_Level.deserialize(clazz, v));
		});
	} finally {
		iterator.close();
	}
	return list;
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:18,代码来源:LevelTable.java


示例4: prevWith

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T extends D_TimeLine> void prevWith(String cluster, Class<T> clazz, Long start, Consumer<T> action) throws IOException {
	DB db = getDB(path(cluster, clazz));
	ReadOptions readOptions = new ReadOptions().snapshot(db.getSnapshot());
	DBIterator iterator = db.iterator(readOptions);
	try {
		iterator.seek((start + "").getBytes());
		while(iterator.hasPrev()){
			Entry<byte[], byte[]> entry = iterator.prev();
			byte[] v = entry.getValue();
			action.accept((T)D_Level.deserialize(clazz, v));
		}
	} finally {
		iterator.close();
	}
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:17,代码来源:LevelTable.java


示例5: deletePrev

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
public static <T extends D_TimeLine> void deletePrev(String cluster, Class<T> clazz, Long start) throws IOException {
	DB db = getDB(path(cluster, clazz));
	ReadOptions readOptions = new ReadOptions().snapshot(db.getSnapshot());
	DBIterator iterator = db.iterator(readOptions);
	WriteBatch write = db.createWriteBatch();
	try {
		iterator.seek((start + "").getBytes());
		while(iterator.hasPrev()){
			byte[] key = iterator.prev().getKey();
			write.delete(key);
		}
		db.write(write, new WriteOptions().sync(true));
	} finally {
		iterator.close();
		write.close();
	}
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:18,代码来源:LevelTable.java


示例6: startWith

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T extends D_TimeLine> void startWith(String cluster, Class<T> clazz, Long start, Consumer<T> action) throws IOException {
	DB db = getDB(path(cluster, clazz));
	ReadOptions readOptions = new ReadOptions().snapshot(db.getSnapshot());
	DBIterator iterator = db.iterator(readOptions);
	try {
		iterator.seek((start + "").getBytes());
		iterator.forEachRemaining(entry ->{
			byte[] v = entry.getValue();
			action.accept((T)D_Level.deserialize(clazz, v));
		});
	} finally {
		iterator.close();
	}
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:16,代码来源:LevelTable.java


示例7: closeSnapshot

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
public static void closeSnapshot(ReadOptions ro) {
	try {
		ro.snapshot().close();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:SimbaService,项目名称:Simba,代码行数:8,代码来源:SimbaLevelDB.java


示例8: getChunk

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
public static byte[] getChunk(ReadOptions ro, long obj_id, int chunk_num) {
	String key = Long.toString(obj_id) + "," + Integer.toString(chunk_num);
	byte[] buf = db.get(bytes(key), ro);
	Log.d(TAG, "GET <" + key + ">, buffer[" + buf.length + "]");

	return buf;
}
 
开发者ID:SimbaService,项目名称:Simba,代码行数:8,代码来源:SimbaLevelDB.java


示例9: LeveldbIterator

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
/**
 * Create an iterator for the specified database
 */
public LeveldbIterator(DB db, ReadOptions options) {
  iter = db.iterator(options);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:LeveldbIterator.java


示例10: 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


示例11: 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


示例12: 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


示例13: write_sync_oneshot

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
private void write_sync_oneshot(SimbaTable mtbl, int dt) {
	Map<Integer, Long> obj_list = new HashMap<Integer, Long>();
	SyncHeader d = mtbl.buildDataForSyncing(obj_list);

	if (!d.getDirtyRows().isEmpty() || !d.getDeletedRows().isEmpty()) {
		SyncRequest r = SyncRequest.newBuilder().setData(d).build();
		SimbaMessage.Builder mmsg = SimbaMessage.newBuilder()
				.setType(SimbaMessage.Type.SYNC_REQUEST).setSyncRequest(r);

		// SimbaLogger.log("up, " + mmsg.toString() + ", " +
		// mmsg.build().toString() + ", " + mmsg.build().computeSize());

		syncScheduler.schedule(mmsg, true, dt);

		if (!obj_list.isEmpty()) {

			/* object fragments */
			/* create ObjectFragments */
			ReadOptions ro = SimbaLevelDB.takeSnapshot();
			for (Map.Entry<Integer, Long> entry : obj_list.entrySet()) {
				int oid = entry.getKey();
				long objID = entry.getValue();

				BitSet dirtyChunkList = SimbaChunkList
						.getDirtyChunks(objID);
				for (int i = dirtyChunkList.nextSetBit(0); i >= 0;) {
					int chunk_num = i;
					byte[] buffer = SimbaLevelDB.getChunk(ro, objID,
							chunk_num);
					i = dirtyChunkList.nextSetBit(i + 1);

					ObjectFragment of = ObjectFragment
							.newBuilder()
							.setTrans_id(r.getData().getTrans_id())
							.setOid(oid)
							.setOffset(
									chunk_num
											* SimbaLevelDB.getChunkSize())
							.setData(ByteString.copyFrom(buffer))
							.setEof(i == -1 ? true : false).build();

					Log.d(TAG,
							"Sending OBJECT_FRAGMENT! trans_id: "
									+ of.getTrans_id() + ", oid: "
									+ of.getOid() + ", offset: "
									+ of.getOffset());

					SimbaMessage.Builder mb_of = SimbaMessage
							.newBuilder()
							.setType(SimbaMessage.Type.OBJECT_FRAGMENT)
							.setObjectFragment(of);
					// SimbaLogger.log("up, " + mb_of.toString() + ", " +
					// mb_of.build().toString() + ", " +
					// mb_of.build().computeSize());

					syncScheduler.schedule(mb_of, true, dt);
				}
			}
			SimbaLevelDB.closeSnapshot(ro);
		} else {
			Log.d(TAG, "write_sync_oneshot no objects to sync");
		}
	}
}
 
开发者ID:SimbaService,项目名称:Simba,代码行数:65,代码来源:SimbaContentService.java


示例14: takeSnapshot

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
public static ReadOptions takeSnapshot() {
	return (new ReadOptions().snapshot(db.getSnapshot()));
}
 
开发者ID:SimbaService,项目名称:Simba,代码行数:4,代码来源:SimbaLevelDB.java


示例15: get

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
@Override
public byte[] get(byte[] arg0, ReadOptions arg1) throws DBException {
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:6,代码来源:MockDB.java


示例16: iterator

import org.iq80.leveldb.ReadOptions; //导入依赖的package包/类
@Override
public DBIterator iterator(ReadOptions arg0) {
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:6,代码来源:MockDB.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExpressionParser类代码示例发布时间:2022-05-21
下一篇:
Java DeferredProcessingAware类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap