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


Java Cursor.getFirst方法代碼示例

本文整理匯總了Java中com.sleepycat.je.Cursor.getFirst方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.getFirst方法的具體用法?Java Cursor.getFirst怎麽用?Java Cursor.getFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sleepycat.je.Cursor的用法示例。


在下文中一共展示了Cursor.getFirst方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initInternalNodes

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * Initialize in, bin, dbin.
 */
private void initInternalNodes()
    throws DatabaseException {

    /* Find the BIN/DBIN. */
    Cursor cursor = db.openCursor(null, null);
    OperationStatus status = cursor.getFirst(keyFound, dataFound, null);
    assertEquals(OperationStatus.SUCCESS, status);
    bin = DbInternal.getCursorImpl(cursor).getBIN();
    dbin = DbInternal.getCursorImpl(cursor).getDupBIN();
    cursor.close();

    /* Find the IN parent of the BIN. */
    bin.latch();
    in = DbInternal.dbGetDatabaseImpl(db)
                   .getTree()
                   .getParentINForChildIN(bin, true, true)
                   .parent;
    assertNotNull(in);
    in.releaseLatch();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:24,代碼來源:INCompressorTest.java

示例2: checkSerializable

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private void checkSerializable(boolean expectSerializable,
                               EnvironmentConfig envConfig,
                               CursorConfig cursorConfig,
                               LockMode lockMode)
    throws DatabaseException, InterruptedException {

    openEnv(false, envConfig);
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    OperationStatus status;

    /* Insert key 2. */
    insert(2);

    /* getFirst returns key 2. */
    Transaction readerTxn = env.beginTransaction(null, null);
    Cursor cursor = db.openCursor(readerTxn, cursorConfig);
    status = cursor.getFirst(key, data, lockMode);
    assertEquals(OperationStatus.SUCCESS, status);
    assertEquals(2, IntegerBinding.entryToInt(key));

    /* Should deadlock iff serializable. */
    try {
        insert(1);
        assertTrue(!expectSerializable);
    } catch (DeadlockException e) {
        assertTrue(expectSerializable);
    }

    cursor.close();
    readerTxn.commit();

    /* This method is called multiple times so remove the database. */
    db.close();
    db = null;
    env.removeDatabase(null, DB_NAME);

    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:40,代碼來源:PhantomTest.java

示例3: testDeleteNonTransactional

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testDeleteNonTransactional()
    throws DatabaseException {

    /* Non-transactional no-dups, 2 keys. */
    openAndInit(false, false);
    OperationStatus status;

    /* Cursor appears on BIN. */
    Cursor cursor = db.openCursor(null, null);
    status = cursor.getFirst(keyFound, dataFound, null);
    assertEquals(OperationStatus.SUCCESS, status);
    checkBinEntriesAndCursors(bin, 2, 1);

    /* Delete without closing the cursor does not compress. */
    status = cursor.delete();
    assertEquals(OperationStatus.SUCCESS, status);
    env.compress();
    checkBinEntriesAndCursors(bin, 2, 1);

    /* Closing the cursor without calling compress does not compress. */
    cursor.close();
    checkBinEntriesAndCursors(bin, 2, 0);

    /* Finally compress can compress. */
    env.compress();
    checkBinEntriesAndCursors(bin, 1, 0);

    /* Should be no change in parent nodes. */
    assertEquals(2, in.getNEntries());

    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:33,代碼來源:INCompressorTest.java

示例4: testDeleteTransactional

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testDeleteTransactional()
    throws DatabaseException {

    /* Transactional no-dups, 2 keys. */
    openAndInit(true, false);
    OperationStatus status;

    /* Cursor appears on BIN. */
    Transaction txn = env.beginTransaction(null, null);
    Cursor cursor = db.openCursor(txn, null);
    status = cursor.getFirst(keyFound, dataFound, null);
    assertEquals(OperationStatus.SUCCESS, status);
    checkBinEntriesAndCursors(bin, 2, 1);

    /* Delete without closing the cursor does not compress. */
    status = cursor.delete();
    assertEquals(OperationStatus.SUCCESS, status);
    env.compress();
    checkBinEntriesAndCursors(bin, 2, 1);

    /* Closing the cursor without commit does not compress. */
    cursor.close();
    env.compress();
    checkBinEntriesAndCursors(bin, 2, 0);

    /* Commit without calling compress does not compress. */
    txn.commit();
    checkBinEntriesAndCursors(bin, 2, 0);

    /* Finally compress can compress. */
    env.compress();
    checkBinEntriesAndCursors(bin, 1, 0);

    /* Should be no change in parent nodes. */
    assertEquals(2, in.getNEntries());

    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:39,代碼來源:INCompressorTest.java

示例5: testEmptyNodes

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testEmptyNodes()
throws Throwable {

       initEnv(true);
synchronized (DbInternal.envGetEnvironmentImpl(exampleEnv).
	      getINCompressor()) {
    writeEmptyNodeData();

    BIN bin = null;
    try {
	bin = (BIN) DbInternal.dbGetDatabaseImpl(exampleDb)
	    .getTree()
	    .getFirstNode();
	DIN dupRoot = (DIN) bin.fetchTarget(0);
	bin.releaseLatch();
	bin = null;
	dupRoot.latch();
	bin = (BIN) DbInternal.dbGetDatabaseImpl(exampleDb)
	    .getTree()
	    .getFirstNode(dupRoot);
	bin.compress(null, true, null);
	bin.releaseLatch();
	bin = null;

	Cursor cursor = exampleDb.openCursor(null, null);
	DatabaseEntry foundKey = new DatabaseEntry();
	DatabaseEntry foundData = new DatabaseEntry();
	OperationStatus status = cursor.getFirst(foundKey, foundData,
						 LockMode.DEFAULT);
	cursor.close();
	assertEquals(OperationStatus.SUCCESS, status);
    } finally {
	if (bin != null) {
	    bin.releaseLatch();
	}
    }
}
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:39,代碼來源:DbCursorDuplicateDeleteTest.java

示例6: checkData

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
    * Check what's in the database against what's in the expected map.
    */
   private void checkData(Map expectedMap) 
       throws DatabaseException {

       StringDbt foundKey = new StringDbt();
       StringDbt foundData = new StringDbt();
       Cursor cursor = exampleDb.openCursor(null, null);
       OperationStatus status = cursor.getFirst(foundKey, foundData,
                                                LockMode.DEFAULT);

       /* 
        * Make a copy of expectedMap so that we're free to delete out
        * of the set of expected results when we verify.
        * Also make a set of counts for each key value, to test count.
        */

       Map checkMap = new HashMap();
       Map countMap = new HashMap();
       Iterator iter = expectedMap.entrySet().iterator();
       while (iter.hasNext()) {
           Map.Entry entry = (Map.Entry) iter.next();
           Set copySet = new HashSet();
           copySet.addAll((Set) entry.getValue());
           checkMap.put(entry.getKey(), copySet);
           countMap.put(entry.getKey(), new Integer(copySet.size()));
       }     

       while (status == OperationStatus.SUCCESS) {
           String foundKeyString = foundKey.getString();
           String foundDataString = foundData.getString();

           /* Check that the current value is in the check values map */
           Set dataVals = (Set) checkMap.get(foundKeyString);
           if (dataVals == null) {
               fail("Couldn't find " +
                    foundKeyString + "/" + foundDataString);
           } else if (dataVals.contains(foundDataString)) {
               dataVals.remove(foundDataString);
               if (dataVals.size() == 0) {
                   checkMap.remove(foundKeyString);
               }
           } else {
               fail("Couldn't find " +
                    foundKeyString + "/" + 
                    foundDataString +
                    " in data vals");
           }

           /* Check that the count is right. */
           int count = cursor.count();
           assertEquals(((Integer)countMap.get(foundKeyString)).intValue(),
                        count);

           status = cursor.getNext(foundKey, foundData, LockMode.DEFAULT);
       }

cursor.close();

if (checkMap.size() != 0) {
    dumpExpected(checkMap);
    fail("checkMapSize = " + checkMap.size());
    		
}
       assertEquals(0, checkMap.size());
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:68,代碼來源:CleanerTest.java

示例7: testRollForwardDeleteDuplicate

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testRollForwardDeleteDuplicate()
    throws DatabaseException {

    /* Non-transactional dups, 2 keys and 2 dups for 1st key. */
    openAndInit(false, true);
    OperationStatus status;

    /* Checkpoint to preserve internal nodes through recovery. */
    CheckpointConfig config = new CheckpointConfig();
    config.setForce(true);
    env.checkpoint(config);

    /* Cursor appears on DBIN. */
    Cursor cursor = db.openCursor(null, null);
    status = cursor.getFirst(keyFound, dataFound, null);
    assertEquals(OperationStatus.SUCCESS, status);
    checkBinEntriesAndCursors(dbin, 2, 1);

    /* Delete without closing the cursor does not compress. */
    status = cursor.delete();
    assertEquals(OperationStatus.SUCCESS, status);
    env.compress();
    checkBinEntriesAndCursors(dbin, 2, 1);

    /* Closing the cursor without calling compress does not compress. */
    cursor.close();
    checkBinEntriesAndCursors(dbin, 2, 0);

    /* 
     * Shutdown and reopen to run recovery. This will call a checkpoint,
     * but it doesn't compress because the child is not resident.
     */
    db.close();
    DbInternal.envGetEnvironmentImpl(env).close(false);
    openEnv(false, true, null);
    initInternalNodes();
    checkBinEntriesAndCursors(dbin, 2, 0);

    /* Finally compress can compress. */
    env.compress();
    checkBinEntriesAndCursors(dbin, 1, 0);

    /* Should be no change in parent nodes. */
    assertEquals(2, in.getNEntries());
    checkBinEntriesAndCursors(bin, 2, 0);

    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:49,代碼來源:INCompressorTest.java

示例8: deleteData

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * Delete data.
 */
private void deleteData(Map expectedMap,
                        boolean everyOther,
                        boolean commit)
    throws DatabaseException {

    Transaction txn = exampleEnv.beginTransaction(null, null);

    StringDbt foundKey = new StringDbt();
    StringDbt foundData = new StringDbt();

    Cursor cursor = exampleDb.openCursor(txn, null);
    OperationStatus status = cursor.getFirst(foundKey, foundData,
                                             LockMode.DEFAULT);

    boolean toggle = true;
    while (status == OperationStatus.SUCCESS) {
        if (toggle) {

            String foundKeyString = foundKey.getString();
            String foundDataString = foundData.getString();

            /* If committing, adjust the expected map */
            if (commit) {

                Set dataVals = (Set) expectedMap.get(foundKeyString);
                if (dataVals == null) {
                    fail("Couldn't find " +
                         foundKeyString + "/" + foundDataString);
                } else if (dataVals.contains(foundDataString)) {
                    dataVals.remove(foundDataString);
                    if (dataVals.size() == 0) {
   expectedMap.remove(foundKeyString);
                    }
                } else {
                    fail("Couldn't find " +
                         foundKeyString + "/" + foundDataString);
                }
            }

            assertEquals(OperationStatus.SUCCESS, cursor.delete());
        }

        if (everyOther) {
            toggle = toggle? false: true;
        }

        status = cursor.getNext(foundKey, foundData, LockMode.DEFAULT);
    }

    cursor.close();
    if (commit) {
        txn.commit();
    } else {
        txn.abort();
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:60,代碼來源:CleanerTest.java

示例9: verifyData

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
protected void verifyData(Hashtable expectedData,
                             boolean checkInList,
		      int startDb,
                             int endDb)
       throws DatabaseException  {

       /* Run verify. */
       if (checkInList) {
           assertTrue(env.verify(null, System.err));
       } else {
           assertTrue(env.verify(null, System.err));
       }

       /*
        * Get a deep copy of expected data (cloning the data sets, not the
        * items within dataSet, since verifyData will remove items, and we
        * need to keep the expectedData set intact because we call verify
        * repeatedly.
        */
       Map useData = new Hashtable();
       Iterator iter = expectedData.entrySet().iterator();
       while (iter.hasNext()) {
           Map.Entry entry = (Map.Entry) iter.next();
           useData.put(entry.getKey(), ((HashSet) entry.getValue()).clone());
       }

       /* Generate an expected count map. */
       Map countMap = generateCountMap(expectedData);

       /* Check each db in turn. */
       DatabaseConfig dbConfig = new DatabaseConfig();
if (btreeComparisonFunction != null) {
    dbConfig.setBtreeComparator(btreeComparisonFunction.getClass());
}
       dbConfig.setTransactional(env.getConfig().getTransactional());
       dbConfig.setSortedDuplicates(true);
       dbConfig.setReadOnly(true);
       for (int d = startDb; d < endDb; d++) {
           Database checkDb = env.openDatabase(null, DB_NAME + d,
					dbConfig);
           Cursor myCursor = checkDb.openCursor(null, null);
           DatabaseEntry key = new DatabaseEntry();
           DatabaseEntry data = new DatabaseEntry();
           OperationStatus status =
	myCursor.getFirst(key, data, LockMode.DEFAULT);
           DbInternal.envGetEnvironmentImpl(env).verifyCursors();
           int numSeen = 0;

           while (status == OperationStatus.SUCCESS) {

               /* The key should have been in the expected data set. */
               removeExpectedData(useData, d, key, data, true);

               /* The count should be right. */
               int count = myCursor.count();
               assertEquals("Count not right for key " +
                            TestUtils.dumpByteArray(key.getData()),
                            getExpectedCount(countMap, d, key), count);
               
               status = myCursor.getNext(key, data, LockMode.DEFAULT);
               numSeen++;
           }

           myCursor.close();

           /* Should be nothing left in the expected data map. */
           if (DEBUG) {
               System.out.println("Finished db" + d + " numSeen=" +numSeen);
               dumpExpected(useData);
           }
           checkDb.close();
       }

       assertEquals(0, useData.size());
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:76,代碼來源:RecoveryTestBase.java

示例10: testRemoveEmptyDBINandBIN

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testRemoveEmptyDBINandBIN()
       throws DatabaseException {

       /* Non-transactional dups, 2 keys and 2 dups for 1st key. */
       openAndInit(false, true);
       OperationStatus status;

       /* Delete key 1, cursor appears on BIN, no compression yet. */
       Cursor cursor = db.openCursor(null, null);
       status = cursor.getSearchKey(entry1, dataFound, null);
       assertEquals(OperationStatus.SUCCESS, status);
       status = cursor.delete();
       assertEquals(OperationStatus.SUCCESS, status);
       env.compress();
       checkBinEntriesAndCursors(bin, 2, 1);
       checkBinEntriesAndCursors(dbin, 2, 0);

       /* Move cursor to 1st dup, cursor moves to DBIN, no compresion yet. */
       status = cursor.getFirst(keyFound, dataFound, null);
       assertEquals(OperationStatus.SUCCESS, status);
       env.compress();
       checkBinEntriesAndCursors(bin, 2, 1);
       checkBinEntriesAndCursors(dbin, 2, 1);

       /* Delete the duplicates for key 0, no compression yet. */
       status = cursor.delete();
       assertEquals(OperationStatus.SUCCESS, status);
       status = cursor.getNext(keyFound, dataFound, null);
       assertEquals(OperationStatus.SUCCESS, status);
       status = cursor.delete();
       assertEquals(OperationStatus.SUCCESS, status);
       env.compress();
       checkBinEntriesAndCursors(bin, 2, 1);
       checkBinEntriesAndCursors(dbin, 2, 1);

       /* Closing the cursor without calling compress does not compress. */
       cursor.close();
       checkBinEntriesAndCursors(bin, 2, 0);
       checkBinEntriesAndCursors(dbin, 2, 0);

       /* Finally compress can compress. */
       env.compress();
/* 
 * Do this twice.  The test is depending on the iterator in
 * doCompress() getting the DBINReference first and the BINReference
 * second.  In JRockit, it's the opposite so the compress of the BIN
 * doesn't do any good on the first time around.  So take two
 * iterations to get the job done.
 */
       env.compress();

       checkBinEntriesAndCursors(bin, 0, 0);
       checkBinEntriesAndCursors(dbin, 0, 0);

       /* BIN is empty so parent entry should be gone also. */
       assertEquals(1, in.getNEntries());

       closeEnv();
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:60,代碼來源:INCompressorTest.java

示例11: testSR10553

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 */
public void testSR10553()
    throws DatabaseException {

    openEnv();

    /* Put some duplicates, enough to fill a log file. */
    final int COUNT = 10;
    DatabaseEntry key = new DatabaseEntry(TestUtils.getTestArray(0));
    DatabaseEntry data = new DatabaseEntry();
    for (int i = 0; i < COUNT; i += 1) {
        data.setData(TestUtils.getTestArray(i));
        db.put(null, key, data);
    }
    Cursor cursor = db.openCursor(null, null);
    assertEquals(OperationStatus.SUCCESS,
                 cursor.getSearchKey(key, data, null));
    assertEquals(COUNT, cursor.count());
    cursor.close();

    /* Delete everything.  Do not compress. */
    db.delete(null, key);

    /* Checkpoint and clean. */
    env.checkpoint(forceConfig);
    int cleaned = env.cleanLog();
    assertTrue("cleaned=" + cleaned, cleaned > 0);

    /* Force eviction. */
    env.evictMemory();

    /* Scan all values. */
    cursor = db.openCursor(null, null);
    for (OperationStatus status = cursor.getFirst(key, data, null);
                         status == OperationStatus.SUCCESS;
                         status = cursor.getNext(key, data, null)) {
    }
    cursor.close();

    /*
     * Before the fix to 10553, while scanning over deleted records, a
     * LogFileNotFoundException would occur when faulting in a deleted
     * record, if the log file had been cleaned.  This was because the
     * cleaner was not setting knownDeleted for deleted records.
     */
    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:49,代碼來源:SR10553Test.java

示例12: count

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * For future use as API method.  Implementation is incomplete.
 *
 * Counts entries in a key range by positioning a cursor on the beginning
 * key and skipping entries until the ending key is encountered.
 */
private long count(DatabaseEntry beginKey,
                   boolean beginInclusive,
                   DatabaseEntry endKey,
                   boolean endInclusive) {

    final DatabaseEntry key = new DatabaseEntry();
    final DatabaseEntry noData = new DatabaseEntry();
    noData.setPartial(0, 0, true);
    final Locker locker = BasicLocker.createBasicLocker(envImpl);
    try {
        final Cursor c = DbInternal.makeCursor(this, locker,
                                               null /*cursorConfig*/);
        try {
            /* Position cursor on beginning key. */
            if (beginKey != null) {
                key.setData(beginKey.getData(), beginKey.getOffset(),
                            beginKey.getSize());
                if (c.getSearchKeyRange(key, noData,
                                        LockMode.READ_UNCOMMITTED) !=
                    OperationStatus.SUCCESS) {
                    return 0;
                }
                if (!beginInclusive && key.equals(beginKey)) {
                    if (c.getNext(key, noData,
                                  LockMode.READ_UNCOMMITTED) !=
                        OperationStatus.SUCCESS) {
                        return 0;
                    }
                }
            } else {
                if (c.getFirst(key, noData, LockMode.READ_UNCOMMITTED) !=
                    OperationStatus.SUCCESS) {
                    return 0;
                }
            }

            /* Create RangeConstraint for ending key. */
            RangeConstraint rangeConstraint = null; // INCOMPLETE

            /* Skip entries to get count. */
            return DbInternal.getCursorImpl(c).skip
                (true /*forward*/, 0 /*maxCount*/, rangeConstraint);
        } finally {
            c.close();
        }
    } finally {
        locker.operationEnd(true);
    }
}
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:56,代碼來源:DatabaseImpl.java

示例13: testRollForwardDelete

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testRollForwardDelete()
    throws DatabaseException {

    /* Non-transactional no-dups, 2 keys. */
    openAndInit(false, false);
    OperationStatus status;

    /* Checkpoint to preserve internal nodes through recovery. */
    CheckpointConfig config = new CheckpointConfig();
    config.setForce(true);
    env.checkpoint(config);

    /* Cursor appears on BIN. */
    Cursor cursor = db.openCursor(null, null);
    status = cursor.getFirst(keyFound, dataFound, null);
    assertEquals(OperationStatus.SUCCESS, status);
    checkBinEntriesAndCursors(bin, 2, 1);

    /* Delete without closing the cursor does not compress. */
    status = cursor.delete();
    assertEquals(OperationStatus.SUCCESS, status);
    env.compress();
    checkBinEntriesAndCursors(bin, 2, 1);

    /* Closing the cursor without calling compress does not compress. */
    cursor.close();
    checkBinEntriesAndCursors(bin, 2, 0);

    /*
     * Shutdown and reopen to run recovery. This will call a checkpoint,
     * but it doesn't compress because the child is not resident.
     */
    db.close();
    DbInternal.envGetEnvironmentImpl(env).close(false);
    openEnv(false, false, null);
    initInternalNodes();
    checkBinEntriesAndCursors(bin, 2, 0);

    /* Finally compress can compress. */
    env.compress();
    checkBinEntriesAndCursors(bin, 1, 0);

    /* Should be no change in parent nodes. */
    assertEquals(2, in.getNEntries());

    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:48,代碼來源:INCompressorTest.java

示例14: testGetFirst_Success_Dup

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testGetFirst_Success_Dup()
    throws DatabaseException, InterruptedException {

    openEnv(true);
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    OperationStatus status;

    /* Insert dups. */
    insert(1, 2);
    insert(1, 3);

    /* getFirst returns {1,2}. */
    Transaction readerTxn = env.beginTransaction(null, txnConfig);
    Cursor cursor = db.openCursor(readerTxn, null);
    status = cursor.getFirst(key, data, null);
    assertEquals(OperationStatus.SUCCESS, status);
    assertEquals(1, IntegerBinding.entryToInt(key));
    assertEquals(2, IntegerBinding.entryToInt(data));

    /* Insert {1,1} in a writer thread. */
    startInsert(1, 1);

    /*
     * If serializable, getFirst should return {1,2} again; otherwise
     * getFirst should see {1,1}.
     */
    status = cursor.getFirst(key, data, null);
    assertEquals(OperationStatus.SUCCESS, status);
    if (txnSerializable) {
        assertEquals(1, IntegerBinding.entryToInt(key));
        assertEquals(2, IntegerBinding.entryToInt(data));
    } else {
        assertEquals(1, IntegerBinding.entryToInt(key));
        assertEquals(1, IntegerBinding.entryToInt(data));
    }

    /* Close reader to allow writer to finish. */
    cursor.close();
    readerTxn.commitNoSync();
    waitForInsert();

    /* getFirst returns {1,1}. */
    readerTxn = env.beginTransaction(null, txnConfig);
    cursor = db.openCursor(readerTxn, null);
    status = cursor.getFirst(key, data, null);
    assertEquals(OperationStatus.SUCCESS, status);
    assertEquals(1, IntegerBinding.entryToInt(key));
    assertEquals(1, IntegerBinding.entryToInt(data));
    cursor.close();
    readerTxn.commit();

    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:55,代碼來源:PhantomTest.java

示例15: testGetFirst_NotFound

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testGetFirst_NotFound()
    throws DatabaseException, InterruptedException {

    openEnv(false);
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    OperationStatus status;

    /* getFirst returns NOTFOUND. */
    Transaction readerTxn = env.beginTransaction(null, txnConfig);
    Cursor cursor = db.openCursor(readerTxn, null);
    status = cursor.getFirst(key, data, null);
    assertEquals(OperationStatus.NOTFOUND, status);

    /* Insert key 1 in a writer thread. */
    startInsert(1);

    /*
     * If serializable, getFirst should return NOTFOUND again; otherwise
     * getFirst should see key 1.
     */
    status = cursor.getFirst(key, data, null);
    if (txnSerializable) {
        assertEquals(OperationStatus.NOTFOUND, status);
    } else {
        assertEquals(OperationStatus.SUCCESS, status);
        assertEquals(1, IntegerBinding.entryToInt(key));
    }

    /* Close reader to allow writer to finish. */
    cursor.close();
    readerTxn.commitNoSync();
    waitForInsert();

    /* getFirst returns key 1. */
    readerTxn = env.beginTransaction(null, txnConfig);
    cursor = db.openCursor(readerTxn, null);
    status = cursor.getFirst(key, data, null);
    assertEquals(OperationStatus.SUCCESS, status);
    assertEquals(1, IntegerBinding.entryToInt(key));
    cursor.close();
    readerTxn.commit();

    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:46,代碼來源:PhantomTest.java


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