本文整理匯總了Java中com.sleepycat.je.Cursor.getNextDup方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.getNextDup方法的具體用法?Java Cursor.getNextDup怎麽用?Java Cursor.getNextDup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sleepycat.je.Cursor
的用法示例。
在下文中一共展示了Cursor.getNextDup方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mergeDuplicateEntries
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void mergeDuplicateEntries() {
try {
System.out.println("Starting to merge duplicate entries in the Database " + StringUtilities.now());
Cursor myCursor = conceptToConceptVectorIndexStore.openCursor(null, null);
DatabaseEntry searchKey = new DatabaseEntry();
DatabaseEntry foundData = new DatabaseEntry();
for (Integer key: indexedConceptsWithDuplicates) {
myIntegerBinding.objectToEntry(key, searchKey);
if (myCursor.getSearchKey(searchKey, foundData, null) == OperationStatus.SUCCESS) {
if (myCursor.count() > 1) {
ConceptToConceptVectorRecordIndexEntry entry = (ConceptToConceptVectorRecordIndexEntry) myDataBinding.entryToObject(foundData);
//OperationStatus status = myCursor.delete();
while (myCursor.getNextDup(searchKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
ConceptToConceptVectorRecordIndexEntry addition = (ConceptToConceptVectorRecordIndexEntry) myDataBinding.entryToObject(foundData);
entry.conceptVectorRecordIDs.addAll(addition.conceptVectorRecordIDs);
entry.sumOfValuesInRecords += addition.sumOfValuesInRecords;
myCursor.delete();
}
setEntryInStore(key, entry);
}
}
}
System.out.println("Done merging duplicate entries in the Database " + StringUtilities.now());
myCursor.close();
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例2: testGetNextDup_Success_Dup
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testGetNextDup_Success_Dup()
throws DatabaseException, InterruptedException {
openEnv(true);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
OperationStatus status;
/* Insert dups. */
insert(1, 1);
insert(1, 3);
/* getNextDup returns {1,3}. */
Transaction readerTxn = env.beginTransaction(null, txnConfig);
Cursor cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(1, IntegerBinding.entryToInt(key));
assertEquals(3, IntegerBinding.entryToInt(data));
/* Insert {1,2} in a writer thread. */
startInsert(1, 2);
/*
* If serializable, getNextDup should return {1,3} again; otherwise
* getNextDup should see {1,2}.
*/
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
if (txnSerializable) {
assertEquals(1, IntegerBinding.entryToInt(key));
assertEquals(3, IntegerBinding.entryToInt(data));
} else {
assertEquals(1, IntegerBinding.entryToInt(key));
assertEquals(2, IntegerBinding.entryToInt(data));
}
/* Close reader to allow writer to finish. */
cursor.close();
readerTxn.commitNoSync();
waitForInsert();
/* getNextDup returns {1,2}. */
readerTxn = env.beginTransaction(null, txnConfig);
cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(1, IntegerBinding.entryToInt(key));
assertEquals(2, IntegerBinding.entryToInt(data));
cursor.close();
readerTxn.commit();
closeEnv();
}
示例3: testGetNextDup_NotFound_Dup
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testGetNextDup_NotFound_Dup()
throws DatabaseException, InterruptedException {
openEnv(true);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
OperationStatus status;
/* Insert dups. */
insert(1, 1);
insert(1, 2);
insert(2, 1);
insert(2, 2);
/* getNextDup returns NOTFOUND. */
Transaction readerTxn = env.beginTransaction(null, txnConfig);
Cursor cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 2));
status = cursor.getNextDup(key, data, null);
assertEquals(OperationStatus.NOTFOUND, status);
/* Insert {1,3} in a writer thread. */
startInsert(1, 3);
/*
* If serializable, getNextDup should return NOTFOUND again; otherwise
* getNextDup should see {1,3}.
*/
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 2));
status = cursor.getNextDup(key, data, null);
if (txnSerializable) {
assertEquals(OperationStatus.NOTFOUND, status);
} else {
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(1, IntegerBinding.entryToInt(key));
assertEquals(3, IntegerBinding.entryToInt(data));
}
/* Close reader to allow writer to finish. */
cursor.close();
readerTxn.commitNoSync();
waitForInsert();
/* getNextDup returns {1,3}. */
readerTxn = env.beginTransaction(null, txnConfig);
cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 2));
status = cursor.getNextDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(1, IntegerBinding.entryToInt(key));
assertEquals(3, IntegerBinding.entryToInt(data));
cursor.close();
readerTxn.commit();
closeEnv();
}