本文整理了Java中com.sleepycat.je.Cursor.getNext()
方法的一些代码示例,展示了Cursor.getNext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cursor.getNext()
方法的具体详情如下:
包路径:com.sleepycat.je.Cursor
类名称:Cursor
方法名:getNext
[英]Moves the cursor to the next key/data pair and returns that pair.
Calling this method is equivalent to calling #get(DatabaseEntry,DatabaseEntry,Get,ReadOptions) with Get#NEXT.
If the cursor is not yet initialized, move the cursor to the first key/data pair of the database, and return that pair. Otherwise, the cursor is moved to the next key/data pair of the database, and that pair is returned. In the presence of duplicate key values, the value of the key may not change.
[中]将光标移动到下一个键/数据对并返回该对。
调用此方法相当于使用get#NEXT调用#get(DatabaseEntry、DatabaseEntry、get、ReadOptions)。
如果光标尚未初始化,请将光标移动到数据库的第一个键/数据对,然后返回该对。否则,光标将移动到数据库的下一个键/数据对,并返回该对。存在重复的键值时,键值可能不会更改。
代码示例来源:origin: voldemort/voldemort
@Override
public void transfer() throws Exception {
cursor = srcDB.openCursor(null, null);
DatabaseEntry keyEntry = new DatabaseEntry();
DatabaseEntry valueEntry = new DatabaseEntry();
List<Versioned<byte[]>> vals;
long startTime = System.currentTimeMillis();
int scanCount = 0;
int keyCount = 0;
while(cursor.getNext(keyEntry, valueEntry, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
keyCount++;
vals = StoreBinaryFormat.fromByteArray(valueEntry.getData());
scanCount += vals.size();
// pull out the real key
byte[] stripedKey = StoreBinaryFormat.extractKey(keyEntry.getData());
OperationStatus putStatus = dstDB.put(null, new DatabaseEntry(stripedKey), valueEntry);
if(OperationStatus.SUCCESS != putStatus) {
String errorStr = "Put failed with " + putStatus + " for key"
+ BdbConvertData.writeAsciiString(keyEntry.getData());
logger.error(errorStr);
throw new Exception(errorStr);
}
if(scanCount % 1000000 == 0)
logger.info("Reverted " + scanCount + " entries in "
+ (System.currentTimeMillis() - startTime) / 1000 + " secs");
}
logger.info("Reverted " + scanCount + " entries and " + keyCount + " keys in "
+ (System.currentTimeMillis() - startTime) / 1000 + " secs");
}
代码示例来源:origin: internetarchive/heritrix3
/**
* @return the key to the first item in the database
* @throws DatabaseException
*/
protected DatabaseEntry getFirstKey() throws DatabaseException {
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
Cursor cursor = pendingUrisDB.openCursor(null,null);
OperationStatus status = cursor.getNext(key,value,null);
cursor.close();
if(status == OperationStatus.SUCCESS) {
return key;
}
return null;
}
代码示例来源:origin: yasserg/crawler4j
public List<WebURL> get(int max) {
synchronized (mutex) {
List<WebURL> results = new ArrayList<>(max);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
Transaction txn = beginTransaction();
try (Cursor cursor = openCursor(txn)) {
OperationStatus result = cursor.getFirst(key, value, null);
int matches = 0;
while ((matches < max) && (result == OperationStatus.SUCCESS)) {
if (value.getData().length > 0) {
results.add(webURLBinding.entryToObject(value));
matches++;
}
result = cursor.getNext(key, value, null);
}
}
commit(txn);
return results;
}
}
代码示例来源:origin: internetarchive/heritrix3
protected OperationStatus getNextNearestItem(DatabaseEntry headKey,
DatabaseEntry result) throws DatabaseException {
Cursor cursor = null;
OperationStatus status;
try {
cursor = this.pendingUrisDB.openCursor(null, null);
// get cap; headKey at this point should always point to
// a queue-beginning cap entry (zero-length value)
status = cursor.getSearchKey(headKey, result, null);
if (status != OperationStatus.SUCCESS) {
LOGGER.severe("bdb queue cap missing: "
+ status.toString() + " " + new String(headKey.getData()));
return status;
}
if (result.getData().length > 0) {
LOGGER.severe("bdb queue has nonzero size: "
+ result.getData().length);
return OperationStatus.KEYEXIST;
}
// get next item (real first item of queue)
status = cursor.getNext(headKey,result,null);
} finally {
if(cursor!=null) {
cursor.close();
}
}
return status;
}
代码示例来源:origin: ltsopensource/light-task-scheduler
DatabaseEntry foundKey = new DatabaseEntry();
DatabaseEntry foundValue = new DatabaseEntry();
while (cursor.getNext(foundKey, foundValue, LockMode.DEFAULT) ==
OperationStatus.SUCCESS) {
String key = new String(foundKey.getData(), "UTF-8");
代码示例来源:origin: ltsopensource/light-task-scheduler
DatabaseEntry foundKey = new DatabaseEntry();
DatabaseEntry foundValue = new DatabaseEntry();
while (cursor.getNext(foundKey, foundValue, LockMode.DEFAULT) ==
OperationStatus.SUCCESS) {
String key = new String(foundKey.getData(), "UTF-8");
代码示例来源:origin: voldemort/voldemort
while(cursor.getNext(keyEntry, valueEntry, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
keyCount++;
代码示例来源:origin: voldemort/voldemort
int scanCount = 0;
int keyCount = 0;
while(cursor.getNext(keyEntry, valueEntry, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
keyCount++;
代码示例来源:origin: voldemort/voldemort
while(cursor.getNext(keyEntry, valueEntry, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
keyCount++;
代码示例来源:origin: internetarchive/heritrix3
result = cursor.getNext(key, value, null);
代码示例来源:origin: voldemort/voldemort
int scanCount = 0;
int keyCount = 0;
while(cursor.getNext(keyEntry, valueEntry, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
scanCount++;
if(scanCount % 1000000 == 0)
代码示例来源:origin: yasserg/crawler4j
public void delete(int count) {
synchronized (mutex) {
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
Transaction txn = beginTransaction();
try (Cursor cursor = openCursor(txn)) {
OperationStatus result = cursor.getFirst(key, value, null);
int matches = 0;
while ((matches < count) && (result == OperationStatus.SUCCESS)) {
cursor.delete();
matches++;
result = cursor.getNext(key, value, null);
}
}
commit(txn);
}
}
代码示例来源:origin: thinkaurelius/titan
break;
status = cursor.getNext(foundKey, foundData, getLockMode(txh));
代码示例来源:origin: internetarchive/heritrix3
/**
* Utility method to perform action for all pending CrawlURI instances.
* @param c Closure action to perform
* @throws DatabaseException
*/
protected void forAllPendingDo(Closure c) throws DatabaseException {
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
Cursor cursor = pendingUrisDB.openCursor(null, null);
while (cursor.getNext(key, value, null) == OperationStatus.SUCCESS) {
if (value.getData().length == 0) {
continue;
}
CrawlURI item = (CrawlURI) crawlUriBinding.entryToObject(value);
c.execute(item);
}
cursor.close();
}
}
代码示例来源:origin: voldemort/voldemort
protected boolean makeMore() {
DatabaseEntry keyEntry = new DatabaseEntry();
DatabaseEntry valueEntry = new DatabaseEntry();
try {
OperationStatus status = cursor.getNext(keyEntry,
valueEntry,
LockMode.READ_UNCOMMITTED);
if(OperationStatus.NOTFOUND == status) {
// we have reached the end of the cursor
return false;
}
ByteArray key = null;
if(bdbEngine.isPartitionScanSupported())
key = new ByteArray(StoreBinaryFormat.extractKey(keyEntry.getData()));
else
key = new ByteArray(keyEntry.getData());
for(Versioned<byte[]> val: StoreBinaryFormat.fromByteArray(valueEntry.getData()))
this.cache.add(Pair.create(key, val));
return true;
} catch(DatabaseException e) {
bdbEngine.bdbEnvironmentStats.reportException(e);
logger.error(e);
throw new PersistenceFailureException(e);
}
}
}
代码示例来源:origin: internetarchive/heritrix3
status = cursor.getNext(key, value, null)) {
代码示例来源:origin: voldemort/voldemort
private boolean fetchNextKey() {
DatabaseEntry keyEntry = new DatabaseEntry();
DatabaseEntry valueEntry = new DatabaseEntry();
valueEntry.setPartial(true);
try {
OperationStatus status = cursor.getNext(keyEntry,
valueEntry,
LockMode.READ_UNCOMMITTED);
if(OperationStatus.NOTFOUND == status) {
// we have reached the end of the cursor
return false;
}
if(bdbEngine.isPartitionScanSupported())
current = new ByteArray(StoreBinaryFormat.extractKey(keyEntry.getData()));
else
current = new ByteArray(keyEntry.getData());
return true;
} catch(DatabaseException e) {
bdbEngine.bdbEnvironmentStats.reportException(e);
logger.error(e);
throw new PersistenceFailureException(e);
}
}
}
代码示例来源:origin: yasserg/crawler4j
counterValues.put(name, counterValue);
result = cursor.getNext(key, value, null);
代码示例来源:origin: voldemort/voldemort
LockMode.READ_UNCOMMITTED);
} else {
status = cursor.getNext(keyEntry, valueEntry, LockMode.READ_UNCOMMITTED);
代码示例来源:origin: voldemort/voldemort
LockMode.READ_UNCOMMITTED);
} else {
status = cursor.getNext(keyEntry, valueEntry, LockMode.READ_UNCOMMITTED);
内容来源于网络,如有侵权,请联系作者删除!