當前位置: 首頁>>代碼示例>>Java>>正文


Java Cursor.getNextNoDup方法代碼示例

本文整理匯總了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();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:54,代碼來源:PhantomTest.java

示例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();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:60,代碼來源:PhantomTest.java

示例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();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:52,代碼來源:PhantomTest.java

示例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();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:55,代碼來源:PhantomTest.java


注:本文中的com.sleepycat.je.Cursor.getNextNoDup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。