當前位置: 首頁>>代碼示例>>Java>>正文


Java DB.iterator方法代碼示例

本文整理匯總了Java中org.iq80.leveldb.DB.iterator方法的典型用法代碼示例。如果您正苦於以下問題:Java DB.iterator方法的具體用法?Java DB.iterator怎麽用?Java DB.iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.iq80.leveldb.DB的用法示例。


在下文中一共展示了DB.iterator方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: replace

import org.iq80.leveldb.DB; //導入方法依賴的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.DB; //導入方法依賴的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.DB; //導入方法依賴的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.DB; //導入方法依賴的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.DB; //導入方法依賴的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: getEntity

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
@Override
public TimelineEntity getEntity(String entityId, String entityType,
    EnumSet<Field> fields) throws IOException {
  Long revStartTime = getStartTimeLong(entityId, entityType);
  if (revStartTime == null) {
    return null;
  }
  byte[] prefix = KeyBuilder.newInstance().add(entityType)
      .add(writeReverseOrderedLong(revStartTime)).add(entityId)
      .getBytesForLookup();

  DBIterator iterator = null;
  try {
    DB db = entitydb.getDBForStartTime(revStartTime);
    if (db == null) {
      return null;
    }
    iterator = db.iterator();
    iterator.seek(prefix);

    return getEntity(entityId, entityType, revStartTime, fields, iterator,
        prefix, prefix.length);
  } finally {
    IOUtils.cleanup(LOG, iterator);
  }
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:27,代碼來源:RollingLevelDBTimelineStore.java

示例7: getEntity

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
@Override
public TimelineEntity getEntity(String entityId, String entityType,
    EnumSet<Field> fields) throws IOException {
  Long revStartTime = getStartTimeLong(entityId, entityType);
  if (revStartTime == null) {
    return null;
  }
  byte[] prefix = KeyBuilder.newInstance().add(entityType)
      .add(writeReverseOrderedLong(revStartTime)).add(entityId)
      .getBytesForLookup();

  DB db = entitydb.getDBForStartTime(revStartTime);
  if (db == null) {
    return null;
  }
  try (DBIterator iterator = db.iterator()) {
    iterator.seek(prefix);

    return getEntity(entityId, entityType, revStartTime, fields, iterator,
        prefix, prefix.length);
  }
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:23,代碼來源:RollingLevelDBTimelineStore.java

示例8: startWith

import org.iq80.leveldb.DB; //導入方法依賴的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

示例9: LeveldbIterator

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
/**
 * Create an iterator for the specified database
 */
public LeveldbIterator(DB db) {
  iter = db.iterator();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:7,代碼來源:LeveldbIterator.java


注:本文中的org.iq80.leveldb.DB.iterator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。