本文整理匯總了Java中com.sleepycat.je.Cursor.getNextNoDup方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.getNextNoDup方法的具體用法?Java Cursor.getNextNoDup怎麽用?Java Cursor.getNextNoDup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sleepycat.je.Cursor
的用法示例。
在下文中一共展示了Cursor.getNextNoDup方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetNextNoDup_Success
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testGetNextNoDup_Success()
throws DatabaseException, InterruptedException {
openEnv(false);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
OperationStatus status;
/* Insert key 1 and 3. */
insert(1);
insert(3);
/* getNextNoDup returns key 3. */
Transaction readerTxn = env.beginTransaction(null, txnConfig);
Cursor cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchKey(cursor, 1));
status = cursor.getNextNoDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(3, IntegerBinding.entryToInt(key));
/* Insert key 2 in a writer thread. */
startInsert(2);
/*
* If serializable, getNextNoDup should return key 3 again; otherwise
* getNextNoDup should see key 2.
*/
assertEquals(OperationStatus.SUCCESS, searchKey(cursor, 1));
status = cursor.getNextNoDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
if (txnSerializable) {
assertEquals(3, IntegerBinding.entryToInt(key));
} else {
assertEquals(2, IntegerBinding.entryToInt(key));
}
/* Close reader to allow writer to finish. */
cursor.close();
readerTxn.commitNoSync();
waitForInsert();
/* getNextNoDup returns key 2. */
readerTxn = env.beginTransaction(null, txnConfig);
cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchKey(cursor, 1));
status = cursor.getNextNoDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(2, IntegerBinding.entryToInt(key));
cursor.close();
readerTxn.commit();
closeEnv();
}
示例2: testGetNextNoDup_Success_Dup
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testGetNextNoDup_Success_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(3, 1);
insert(3, 2);
/* getNextNoDup returns {3,1}. */
Transaction readerTxn = env.beginTransaction(null, txnConfig);
Cursor cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextNoDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(3, IntegerBinding.entryToInt(key));
assertEquals(1, IntegerBinding.entryToInt(data));
/* Insert {2,1} in a writer thread. */
startInsert(2, 1);
/*
* If serializable, getNextNoDup should return {3,1} again; otherwise
* getNextNoDup should see {2,1}.
*/
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextNoDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
if (txnSerializable) {
assertEquals(3, IntegerBinding.entryToInt(key));
assertEquals(1, IntegerBinding.entryToInt(data));
} else {
assertEquals(2, IntegerBinding.entryToInt(key));
assertEquals(1, IntegerBinding.entryToInt(data));
}
/* Close reader to allow writer to finish. */
cursor.close();
readerTxn.commitNoSync();
waitForInsert();
/* getNextNoDup returns {2,1}. */
readerTxn = env.beginTransaction(null, txnConfig);
cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextNoDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(2, IntegerBinding.entryToInt(key));
assertEquals(1, IntegerBinding.entryToInt(data));
cursor.close();
readerTxn.commit();
closeEnv();
}
示例3: testGetNextNoDup_NotFound
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testGetNextNoDup_NotFound()
throws DatabaseException, InterruptedException {
openEnv(false);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
OperationStatus status;
/* Insert key 1. */
insert(1);
/* getNextNoDup returns NOTFOUND. */
Transaction readerTxn = env.beginTransaction(null, txnConfig);
Cursor cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchKey(cursor, 1));
status = cursor.getNextNoDup(key, data, null);
assertEquals(OperationStatus.NOTFOUND, status);
/* Insert key 2 in a writer thread. */
startInsert(2);
/*
* If serializable, getNextNoDup should return NOTFOUND again;
* otherwise getNextNoDup should see key 2.
*/
assertEquals(OperationStatus.SUCCESS, searchKey(cursor, 1));
status = cursor.getNextNoDup(key, data, null);
if (txnSerializable) {
assertEquals(OperationStatus.NOTFOUND, status);
} else {
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(2, IntegerBinding.entryToInt(key));
}
/* Close reader to allow writer to finish. */
cursor.close();
readerTxn.commitNoSync();
waitForInsert();
/* getNextNoDup returns key 2. */
readerTxn = env.beginTransaction(null, txnConfig);
cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchKey(cursor, 1));
status = cursor.getNextNoDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(2, IntegerBinding.entryToInt(key));
cursor.close();
readerTxn.commit();
closeEnv();
}
示例4: testGetNextNoDup_NotFound_Dup
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testGetNextNoDup_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);
/* getNextNoDup returns NOTFOUND. */
Transaction readerTxn = env.beginTransaction(null, txnConfig);
Cursor cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextNoDup(key, data, null);
assertEquals(OperationStatus.NOTFOUND, status);
/* Insert {2,1} in a writer thread. */
startInsert(2, 1);
/*
* If serializable, getNextNoDup should return NOTFOUND again;
* otherwise getNextNoDup should see {2,1}.
*/
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextNoDup(key, data, null);
if (txnSerializable) {
assertEquals(OperationStatus.NOTFOUND, status);
} else {
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(2, IntegerBinding.entryToInt(key));
assertEquals(1, IntegerBinding.entryToInt(data));
}
/* Close reader to allow writer to finish. */
cursor.close();
readerTxn.commitNoSync();
waitForInsert();
/* getNextNoDup returns {2,1}. */
readerTxn = env.beginTransaction(null, txnConfig);
cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextNoDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(2, IntegerBinding.entryToInt(key));
assertEquals(1, IntegerBinding.entryToInt(data));
cursor.close();
readerTxn.commit();
closeEnv();
}