本文整理了Java中com.sleepycat.je.Cursor.getFirst()
方法的一些代码示例,展示了Cursor.getFirst()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cursor.getFirst()
方法的具体详情如下:
包路径:com.sleepycat.je.Cursor
类名称:Cursor
方法名:getFirst
[英]Moves the cursor to the first key/data pair of the database, and returns that pair. If the first key has duplicate values, the first data item in the set of duplicates is returned.
Calling this method is equivalent to calling #get(DatabaseEntry,DatabaseEntry,Get,ReadOptions) with Get#FIRST.
[中]将光标移动到数据库的第一个键/数据对,并返回该对。如果第一个键具有重复值,则返回重复集合中的第一个数据项。
调用此方法相当于使用get#FIRST调用#get(DatabaseEntry,DatabaseEntry,get,ReadOptions)。
代码示例来源: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: 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: yasserg/crawler4j
Transaction tnx = env.beginTransaction(null, null);
Cursor cursor = statisticsDB.openCursor(tnx, null);
result = cursor.getFirst(key, value, null);
代码示例来源:origin: com.amazon.carbonado/carbonado-sleepycat-je
@Override
protected boolean cursor_getFirst() throws Exception {
return cursor().getFirst(mSearchKey, mData, mLockMode) == SUCCESS;
}
代码示例来源:origin: com.projectdarkstar.server/sgs-server
/** {@inheritDoc} */
public boolean findFirst() {
try {
OperationStatus status =
cursor.getFirst(keyEntry, valueEntry, null);
if (status == SUCCESS) {
isCurrent = true;
return true;
} else if (status == NOTFOUND) {
return false;
} else {
throw new DbDatabaseException("Operation failed: " + status);
}
} catch (DatabaseException e) {
throw JeEnvironment.convertException(e, true);
}
}
代码示例来源:origin: org.reddwarfserver.server/sgs-server
/** {@inheritDoc} */
public boolean findFirst() {
try {
OperationStatus status =
cursor.getFirst(keyEntry, valueEntry, null);
if (status == SUCCESS) {
isCurrent = true;
return true;
} else if (status == NOTFOUND) {
return false;
} else {
throw new DbDatabaseException("Operation failed: " + status);
}
} catch (DatabaseException e) {
throw JeEnvironment.convertException(e, true);
}
}
代码示例来源:origin: dworkin/reddwarf
/** {@inheritDoc} */
public boolean findFirst() {
try {
OperationStatus status =
cursor.getFirst(keyEntry, valueEntry, null);
if (status == SUCCESS) {
isCurrent = true;
return true;
} else if (status == NOTFOUND) {
return false;
} else {
throw new DbDatabaseException("Operation failed: " + status);
}
} catch (DatabaseException e) {
throw JeEnvironment.convertException(e, true);
}
}
代码示例来源:origin: com.amazon.carbonado/carbonado-sleepycat-je
@Override
protected boolean db_isEmpty(JE_Transaction jetxn, Object database, boolean rmw)
throws Exception
{
Cursor cursor = ((Database) database).openCursor(jetxn == null ? null : jetxn.mTxn, null);
OperationStatus status = cursor.getFirst
(new DatabaseEntry(), new DatabaseEntry(), rmw ? LockMode.RMW : null);
cursor.close();
return status == OperationStatus.NOTFOUND;
}
代码示例来源:origin: com.fasterxml.storemate/storemate-backend-bdb-je
OperationStatus status = crsr.getFirst(keyEntry, valueEntry, null);
try {
int index = 0;
代码示例来源:origin: addthis/hydra
/**
* return first key or value
*/
private byte[] first(boolean key) {
Cursor c = bdb.openCursor(null, cursorConfig);
try {
DatabaseEntry dk = new DatabaseEntry();
DatabaseEntry dv = new DatabaseEntry();
if (c.getFirst(dk, dv, lockMode) == opSuccess) {
gets.incrementAndGet();
bytesIn.addAndGet(dk.getSize() + dv.getSize());
return key ? dk.getData() : dv.getData();
}
return null;
} finally {
c.close();
}
}
代码示例来源:origin: addthis/hydra
/**
* return first key or value
*/
private byte[] first(boolean key) {
Cursor c = bdb.openCursor(null, CursorConfig.READ_UNCOMMITTED);
try {
DatabaseEntry dk = new DatabaseEntry();
DatabaseEntry dv = new DatabaseEntry();
if (c.getFirst(dk, dv, lockMode) == opSuccess) {
gets.incrementAndGet();
bytesIn.addAndGet(dk.getSize() + dv.getSize());
return key ? dk.getData() : dv.getData();
}
return null;
} finally {
c.close();
}
}
代码示例来源:origin: itisaid/Doris
public BDBCursorIterator(Cursor cursor, boolean noValues) {
this.cursor = cursor;
isOpen = true;
this.noValues = noValues;
DatabaseEntry keyEntry = new DatabaseEntry();
DatabaseEntry valueEntry = new DatabaseEntry();
if (noValues) {
valueEntry.setPartial(true);
}
try {
cursor.getFirst(keyEntry, valueEntry, LockMode.READ_UNCOMMITTED);
} catch (DatabaseException e) {
logger.error("", e);
throw new BDBStorageException(e);
}
if (keyEntry.getData() != null) {
currentValue = getRecord(keyEntry, valueEntry);
}
}
代码示例来源:origin: edu.uci.ics/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: addthis/hydra
boolean useAltKey = false;
if (start == null || start.length == 0) {
status = cursor.getFirst(dk, dvs, lockMode);
} else {
status = cursor.getSearchKeyRange(dk, dvs, lockMode);
代码示例来源:origin: edu.uci.ics/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: edu.uci.ics/crawler4j
Transaction tnx = env.beginTransaction(null, null);
Cursor cursor = statisticsDB.openCursor(tnx, null);
result = cursor.getFirst(key, value, null);
代码示例来源:origin: stackoverflow.com
OperationStatus status = cursor.getFirst(key, value, null);
int count = 0;
while (status.equals(OperationStatus.SUCCESS))
代码示例来源:origin: com.sleepycat/je
if (c.getFirst(key, noData, lockMode) !=
OperationStatus.SUCCESS) {
return 0;
代码示例来源:origin: com.fasterxml.storemate/storemate-backend-bdb-je
if (firstKey == null) { // from beginning (i.e. no ranges)
keyEntry = new DatabaseEntry();
status = crsr.getFirst(keyEntry, data, null);
} else {
keyEntry = dbKey(firstKey);
代码示例来源:origin: com.sleepycat/je
try {
cursor = db.openCursor(txn, cursorConfig);
OperationStatus status = cursor.getFirst(key, data, null);
while (status == OperationStatus.SUCCESS) {
boolean oneWritten = false;
内容来源于网络,如有侵权,请联系作者删除!