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


Java Cursor.putNoDupData方法代碼示例

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


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

示例1: putAndVerifyCursor

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
protected OperationStatus putAndVerifyCursor(Cursor cursor, StringDbt key,
					 StringDbt data,
                                                boolean putVariant)
throws DatabaseException {

OperationStatus status;
if (duplicatesAllowed) {
    status = cursor.putNoDupData(key, data);
} else {
    status = cursor.putNoOverwrite(key, data);
}

if (status == OperationStatus.SUCCESS) {
    StringDbt keyCheck = new StringDbt();
    StringDbt dataCheck = new StringDbt();

    assertEquals(OperationStatus.SUCCESS, cursor.getCurrent
		 (keyCheck, dataCheck, LockMode.DEFAULT));
    assertEquals(key.getString(), keyCheck.getString());
    assertEquals(data.getString(), dataCheck.getString());
}

return status;
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:25,代碼來源:DbCursorTestBase.java

示例2: insertData

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private void insertData(Cursor cursor, int numRecords, int dataVal)
    throws DatabaseException {

    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();

    for (int i = 0; i < numRecords; i++) {
        byte[] keyData = TestUtils.getTestArray(i);
        byte[] dataData = new byte[1];
        dataData[0] = (byte) dataVal;
        key.setData(keyData);
        data.setData(dataData);
        OperationStatus status = cursor.putNoDupData(key, data);
        assertEquals(OperationStatus.SUCCESS, status);
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:17,代碼來源:CursorTxnTest.java

示例3: writeData

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
    * Writes data to create INITIAL_FILES number of files, storing the first
    * key for each file in the firstKeysInFiles list.  One extra file is
    * actually created, to ensure that the firstActiveLSN is not in any of
    * INITIAL_FILES files.
    */
   private void writeData()
       throws DatabaseException {

       DatabaseEntry key = new DatabaseEntry();
       DatabaseEntry data = new DatabaseEntry(new byte[DATA_SIZE]);
       firstKeysInFiles = new ArrayList();
       existingKeys = new HashSet();

       Transaction txn = env.beginTransaction(null, null);
       Cursor cursor = db.openCursor(txn, null);
       int fileNum = -1;

       for (int nextKey = 0; fileNum < INITIAL_FILES; nextKey += 1) {

           OperationStatus status;
           if (dups) {
               key.setData(MAIN_KEY_FOR_DUPS);
               data.setData(TestUtils.getTestArray(nextKey));
               status = cursor.putNoDupData(key, data);
           } else {
               key.setData(TestUtils.getTestArray(nextKey));
               data.setData(new byte[DATA_SIZE]);
               status = cursor.putNoOverwrite(key, data);
           }

           assertEquals(OperationStatus.SUCCESS, status);
           existingKeys.add(new Integer(nextKey));

           long lsn = getLsn(cursor);
           if (DbLsn.getFileNumber(lsn) != fileNum) {
               assertTrue(fileNum < DbLsn.getFileNumber(lsn));
               fileNum = (int) DbLsn.getFileNumber(lsn);
               assertEquals(fileNum, firstKeysInFiles.size());
               firstKeysInFiles.add(new Integer(nextKey));
           }
       }

       cursor.close();
       txn.commit();
env.checkpoint(forceConfig);

       long firstActiveLsn = envImpl.getCheckpointer().getFirstActiveLsn();
       assertTrue(firstActiveLsn != DbLsn.NULL_LSN);
       assertTrue(DbLsn.getFileNumber(firstActiveLsn) >= INITIAL_FILES);
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:52,代碼來源:FileSelectionTest.java

示例4: writeData

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
    * Writes data to create INITIAL_FILES number of files, storing the first
    * key for each file in the firstKeysInFiles list.  One extra file is
    * actually created, to ensure that the firstActiveLSN is not in any of
    * INITIAL_FILES files.
    */
   private void writeData()
       throws DatabaseException {

       DatabaseEntry key = new DatabaseEntry();
       DatabaseEntry data = new DatabaseEntry(new byte[DATA_SIZE]);
       firstKeysInFiles = new ArrayList();
       existingKeys = new HashSet();

       Transaction txn = env.beginTransaction(null, null);
       Cursor cursor = db.openCursor(txn, null);
       int fileNum = -1;

       for (int nextKey = 0; fileNum < INITIAL_FILES; nextKey += 1) {
           
           OperationStatus status;
           if (dups) {
               key.setData(MAIN_KEY_FOR_DUPS);
               data.setData(TestUtils.getTestArray(nextKey));
               status = cursor.putNoDupData(key, data);
           } else {
               key.setData(TestUtils.getTestArray(nextKey));
               data.setData(new byte[DATA_SIZE]);
               status = cursor.putNoOverwrite(key, data);
           }

           assertEquals(OperationStatus.SUCCESS, status);
           existingKeys.add(new Integer(nextKey));

           long lsn = getLsn(cursor);
           if (DbLsn.getFileNumber(lsn) != fileNum) {
               assertTrue(fileNum < DbLsn.getFileNumber(lsn));
               fileNum = (int) DbLsn.getFileNumber(lsn);
               assertEquals(fileNum, firstKeysInFiles.size());
               firstKeysInFiles.add(new Integer(nextKey));
           }
       }

       cursor.close();
       txn.commit();
env.checkpoint(forceConfig);

       long firstActiveLsn = envImpl.getCheckpointer().getFirstActiveLsn();
       assertTrue(firstActiveLsn != DbLsn.NULL_LSN);
       assertTrue(DbLsn.getFileNumber(firstActiveLsn) >= INITIAL_FILES);
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:52,代碼來源:FileSelectionTest.java


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