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


Java DBIterator.seek方法代码示例

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


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

示例1: prevWith

import org.iq80.leveldb.DBIterator; //导入方法依赖的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

示例2: deletePrev

import org.iq80.leveldb.DBIterator; //导入方法依赖的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

示例3: getEntity

import org.iq80.leveldb.DBIterator; //导入方法依赖的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

示例4: size

import org.iq80.leveldb.DBIterator; //导入方法依赖的package包/类
private int size(final String repositoryName) {
    DBIterator it = levelDBFile.getDb().iterator();

    String prefix = repositoryName + '\0';
    int count = 0;
    try {
        for (it.seek(keyBuilder(repositoryName, "")); it.hasNext(); it.next()) {
            if (!asString(it.peekNext().getKey()).startsWith(prefix)) {
                break;
            }
            count++;
        }
    } finally {
        // Make sure you close the iterator to avoid resource leaks.
        IOHelper.close(it);
    }

    LOG.debug("Size of repository [{}] -> {}", repositoryName, count);
    return count;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:LevelDBAggregationRepository.java

示例5: getEntity

import org.iq80.leveldb.DBIterator; //导入方法依赖的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(ENTITY_ENTRY_PREFIX)
      .add(entityType).add(writeReverseOrderedLong(revStartTime))
      .add(entityId).getBytesForLookup();

  DBIterator iterator = null;
  try {
    iterator = db.iterator();
    iterator.seek(prefix);

    return getEntity(entityId, entityType, revStartTime, fields, iterator,
        prefix, prefix.length);
  } finally {
    IOUtils.cleanup(LOG, iterator);
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:23,代码来源:LeveldbTimelineStore.java

示例6: getNumChunks

import org.iq80.leveldb.DBIterator; //导入方法依赖的package包/类
public static int getNumChunks(long obj_id) {
	int num = 0;
	DBIterator iterator = db.iterator();
	// TODO: chunk for obj_id may not start with 0!
	String key = Long.toString(obj_id) + ",0";
	try {
		for (iterator.seek(bytes(key)); iterator.hasNext(); iterator.next()) {
			if (!(asString(iterator.peekNext().getKey()).startsWith(Long
					.toString(obj_id) + ",")))
				break;
			num++;
		}
		iterator.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return num;
}
 
开发者ID:SimbaService,项目名称:Simba,代码行数:19,代码来源:SimbaLevelDB.java

示例7: setObjectDirty

import org.iq80.leveldb.DBIterator; //导入方法依赖的package包/类
public static void setObjectDirty(long obj_id) {
	int chunk_num = 0;
	DBIterator iterator = db.iterator();
	String key = Long.toString(obj_id) + "," + Integer.toString(chunk_num);
	try {
		for (iterator.seek(bytes(key)); iterator.hasNext(); iterator.next()) {
			if (!(asString(iterator.peekNext().getKey()).startsWith(Long
					.toString(obj_id) + ",")))
				break;

			SimbaChunkList.addDirtyChunk(obj_id, chunk_num);
			chunk_num++;
		}
		iterator.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:SimbaService,项目名称:Simba,代码行数:19,代码来源:SimbaLevelDB.java

示例8: deleteObject

import org.iq80.leveldb.DBIterator; //导入方法依赖的package包/类
public static void deleteObject(long obj_id, int startChunk) {
	String key = Long.toString(obj_id) + "," + Integer.toString(startChunk);
	DBIterator iterator = db.iterator();

	try {
		for (iterator.seek(bytes(key)); iterator.hasNext(); iterator.next()) {
			if (!(asString(iterator.peekNext().getKey()).startsWith(Long
					.toString(obj_id) + ",")))
				break;
			Log.d(TAG, "DELETE <" + asString(iterator.peekNext().getKey())
					+ ">");
			db.delete(iterator.peekNext().getKey());
		}
		iterator.close();
	} catch (IOException e) {
		e.printStackTrace();
	}

	// delete object from dirtyChunkList
	SimbaChunkList.removeDirtyChunks(obj_id);
}
 
开发者ID:SimbaService,项目名称:Simba,代码行数:22,代码来源:SimbaLevelDB.java

示例9: doScan

import org.iq80.leveldb.DBIterator; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("resource")
@Override
protected void doScan(byte[] beginKey, byte[] endKey,
		IKeyValueCallback callback, boolean includeValue)
		throws StorageException {

	DBIterator iterator = null;
	try {
		iterator = database.iterator();
		iterator.seek(beginKey);
		while (iterator.hasNext()) {
			Entry<byte[], byte[]> keyValue = iterator.next();
			if (ByteArrayUtils.isLess(endKey, keyValue.getKey(), true)) {
				return;
			}
			callback.callback(keyValue.getKey(), keyValue.getValue());
		}
	} catch (DBException e) {
		throw new StorageException(e);
	} finally {
		FileSystemUtils.close(iterator);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:25,代码来源:DainLevelDBStore.java

示例10: startWith

import org.iq80.leveldb.DBIterator; //导入方法依赖的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

示例11: getDomain

import org.iq80.leveldb.DBIterator; //导入方法依赖的package包/类
@Override
public TimelineDomain getDomain(String domainId) throws IOException {
  DBIterator iterator = null;
  try {
    byte[] prefix = KeyBuilder.newInstance().add(domainId)
        .getBytesForLookup();
    iterator = domaindb.iterator();
    iterator.seek(prefix);
    return getTimelineDomain(iterator, domainId, prefix);
  } finally {
    IOUtils.cleanup(LOG, iterator);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:14,代码来源:RollingLevelDBTimelineStore.java

示例12: getKeys

import org.iq80.leveldb.DBIterator; //导入方法依赖的package包/类
public Set<String> getKeys() {
    final Set<String> keys = new LinkedHashSet<String>();

    // interval task could potentially be running while we are shutting down so check for that
    if (!isRunAllowed()) {
        return null;
    }

    DBIterator it = levelDBFile.getDb().iterator();

    String keyBuffer;
    try {
        String prefix = repositoryName + '\0';
        for (it.seek(keyBuilder(repositoryName, "")); it.hasNext(); it.next()) {
            if (!isRunAllowed()) {
                break;
            }
            keyBuffer = asString(it.peekNext().getKey());

            if (!keyBuffer.startsWith(prefix)) {
                break;
            }

            String key = keyBuffer.substring(prefix.length());

            LOG.trace("getKey [{}]", key);
            keys.add(key);
        }
    } finally {
        // Make sure you close the iterator to avoid resource leaks.
        IOHelper.close(it);
    }

    return Collections.unmodifiableSet(keys);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:36,代码来源:LevelDBAggregationRepository.java

示例13: scan

import org.iq80.leveldb.DBIterator; //导入方法依赖的package包/类
public Set<String> scan(CamelContext camelContext) {
    final Set<String> answer = new LinkedHashSet<String>();

    if (!isRunAllowed()) {
        return null;
    }

    DBIterator it = levelDBFile.getDb().iterator();

    String keyBuffer;
    try {
        String prefix = getRepositoryNameCompleted() + '\0';

        for (it.seek(keyBuilder(getRepositoryNameCompleted(), "")); it.hasNext(); it.next()) {
            keyBuffer = asString(it.peekNext().getKey());

            if (!keyBuffer.startsWith(prefix)) {
                break;
            }
            String exchangeId = keyBuffer.substring(prefix.length());

            LOG.trace("Scan exchangeId [{}]", exchangeId);
            answer.add(exchangeId);
        }
    } finally {
        // Make sure you close the iterator to avoid resource leaks.
        IOHelper.close(it);
    }

    if (answer.size() == 0) {
        LOG.trace("Scanned and found no exchange to recover.");
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Scanned and found {} exchange(s) to recover (note some of them may already be in progress).", answer.size());
        }
    }
    return answer;

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:40,代码来源:LevelDBAggregationRepository.java

示例14: getEntityTypes

import org.iq80.leveldb.DBIterator; //导入方法依赖的package包/类
@VisibleForTesting
List<String> getEntityTypes() throws IOException {
  DBIterator iterator = null;
  try {
    iterator = getDbIterator(false);
    List<String> entityTypes = new ArrayList<String>();
    iterator.seek(ENTITY_ENTRY_PREFIX);
    while (iterator.hasNext()) {
      byte[] key = iterator.peekNext().getKey();
      if (key[0] != ENTITY_ENTRY_PREFIX[0]) {
        break;
      }
      KeyParser kp = new KeyParser(key,
          ENTITY_ENTRY_PREFIX.length);
      String entityType = kp.getNextString();
      entityTypes.add(entityType);
      byte[] lookupKey = KeyBuilder.newInstance().add(ENTITY_ENTRY_PREFIX)
          .add(entityType).getBytesForLookup();
      if (lookupKey[lookupKey.length - 1] != 0x0) {
        throw new IOException("Found unexpected end byte in lookup key");
      }
      lookupKey[lookupKey.length - 1] = 0x1;
      iterator.seek(lookupKey);
    }
    return entityTypes;
  } finally {
    IOUtils.cleanup(LOG, iterator);
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:30,代码来源:LeveldbTimelineStore.java

示例15: deleteKeysWithPrefix

import org.iq80.leveldb.DBIterator; //导入方法依赖的package包/类
/**
 * Finds all keys in the db that have a given prefix and deletes them on
 * the given write batch.
 */
private void deleteKeysWithPrefix(WriteBatch writeBatch, byte[] prefix,
    DBIterator iterator) {
  for (iterator.seek(prefix); iterator.hasNext(); iterator.next()) {
    byte[] key = iterator.peekNext().getKey();
    if (!prefixMatches(prefix, prefix.length, key)) {
      break;
    }
    writeBatch.delete(key);
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:15,代码来源:LeveldbTimelineStore.java


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