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


Java Cursor.putCurrent方法代碼示例

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


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

示例1: modifyRecords

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
    * Modify the data, just to dirty the BIN.
    */
   private void modifyRecords(int start, int end, int increment)
       throws DatabaseException {

       Transaction txn = env.beginTransaction(null, null);
       Cursor cursor = db.openCursor(txn, null);
       DatabaseEntry searchKey = new DatabaseEntry();
       DatabaseEntry foundData = new DatabaseEntry();
       DatabaseEntry newData = new DatabaseEntry();

       for (int i = start; i <= end; i++) {
           searchKey.setData(TestUtils.getTestArray(i));
           assertEquals(OperationStatus.SUCCESS,
                        cursor.getSearchKey(searchKey, foundData,
                                            LockMode.DEFAULT));
           newData.setData(TestUtils.getTestArray(i+increment));
           cursor.putCurrent(newData);
       }
cursor.close();
       txn.commit();
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:24,代碼來源:BinDeltaTest.java

示例2: modifyRecords

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
    * Modify the data, just to dirty the BIN.
    */
   private void modifyRecords(int start, int end, int increment)
       throws DatabaseException {

       Transaction txn = env.beginTransaction(null, null);
       Cursor cursor = db.openCursor(txn, null);
       DatabaseEntry searchKey = new DatabaseEntry();
       DatabaseEntry foundData = new DatabaseEntry();
       DatabaseEntry newData = new DatabaseEntry();
       
       for (int i = start; i <= end; i++) {
           searchKey.setData(TestUtils.getTestArray(i));
           assertEquals(OperationStatus.SUCCESS,
                        cursor.getSearchKey(searchKey, foundData,
                                            LockMode.DEFAULT));
           newData.setData(TestUtils.getTestArray(i+increment));
           cursor.putCurrent(newData);
       }
cursor.close();
       txn.commit();
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:24,代碼來源:BinDeltaTest.java

示例3: doUpdate

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private long doUpdate(int key, int data, Transaction txn)
    throws DatabaseException {

    Cursor cursor = db.openCursor(txn, null);
    IntegerBinding.intToEntry(key, keyEntry);
    IntegerBinding.intToEntry(data, dataEntry);
    assertEquals(OperationStatus.SUCCESS,
                 cursor.getSearchBoth(keyEntry, dataEntry, null));
    cursor.putCurrent(dataEntry);
    long file = getFile(cursor);
    cursor.close();
    return file;
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:14,代碼來源:UtilizationTest.java

示例4: updateData

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * Updates the specified keys.
 */
private void updateData(int firstKey, int keyCount)
    throws DatabaseException {

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

    Transaction txn = env.beginTransaction(null, null);
    Cursor cursor = db.openCursor(txn, null);

    for (int i = 0; i < keyCount; i += 1) {
        int nextKey = firstKey + i;
        OperationStatus status;
        if (dups) {
            key.setData(MAIN_KEY_FOR_DUPS);
            data.setData(TestUtils.getTestArray(nextKey));
            status = cursor.getSearchBoth(key, data, null);
            assertEquals(OperationStatus.SUCCESS, status);
            assertEquals(MAIN_KEY_FOR_DUPS.length, key.getSize());
            assertEquals(nextKey, TestUtils.getTestVal(data.getData()));
        } else {
            key.setData(TestUtils.getTestArray(nextKey));
            status = cursor.getSearchKey(key, data, null);
            assertEquals(OperationStatus.SUCCESS, status);
            assertEquals(nextKey, TestUtils.getTestVal(key.getData()));
            assertEquals(DATA_SIZE, data.getSize());
        }
        status = cursor.putCurrent(data);
        assertEquals(OperationStatus.SUCCESS, status);
    }

    cursor.close();
    txn.commit();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:37,代碼來源:FileSelectionTest.java

示例5: evolveIndex

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private void evolveIndex(Format format,
                         EvolveEvent event,
                         EvolveListener listener)
    throws DatabaseException {

    Class entityClass = format.getType();
    String entityClassName = format.getClassName();
    EntityMetadata meta = model.getEntityMetadata(entityClassName);
    String keyClassName = meta.getPrimaryKey().getClassName();
    keyClassName = SimpleCatalog.keyClassName(keyClassName);
    DatabaseConfig dbConfig = getPrimaryConfig(meta);

    PrimaryIndex<Object,Object> index = getPrimaryIndex
        (Object.class, keyClassName, entityClass, entityClassName);
    Database db = index.getDatabase();

    EntityBinding binding = index.getEntityBinding();
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();

    Cursor readCursor = db.openCursor(null, CursorConfig.READ_UNCOMMITTED);
    try {
        while (readCursor.getNext(key, data, null) ==
               OperationStatus.SUCCESS) {
            if (evolveNeeded(key, data, binding)) {
                Transaction txn = null;
                if (dbConfig.getTransactional()) {
                    boolean success = false;
                    txn = env.beginTransaction(null, null);
                }
                boolean written = false;
                Cursor writeCursor = null;
                try {
                    writeCursor = db.openCursor(txn, null);
                    if (writeCursor.getSearchKey
                            (key, data, LockMode.RMW) ==
                            OperationStatus.SUCCESS) {
                        if (evolveNeeded(key, data, binding)) {
                            writeCursor.putCurrent(data);
                            written = true;
                        }
                        if (listener != null) {
                            EvolveInternal.updateEvent
                                (event, entityClassName, 1,
                                 written ? 1 : 0);
                            if (!listener.evolveProgress(event)) {
                                break;
                            }
                        }
                    }
                } finally {
                    if (writeCursor != null) {
                        writeCursor.close();
                    }
                    if (txn != null) {
                        if (written) {
                            txn.commit();
                        } else {
                            txn.abort();
                        }
                    }
                }
            }
        }
    } finally {
        readCursor.close();
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:69,代碼來源:Store.java

示例6: evolveIndex

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private void evolveIndex(Format format,
                         EvolveEvent event,
                         EvolveListener listener)
    throws DatabaseException {

    Class entityClass = format.getType();
    String entityClassName = format.getClassName();
    EntityMetadata meta = model.getEntityMetadata(entityClassName);
    String keyClassName = meta.getPrimaryKey().getClassName();
    keyClassName = SimpleCatalog.keyClassName(keyClassName);
    DatabaseConfig dbConfig = getPrimaryConfig(meta);

    PrimaryIndex<Object,Object> index = getPrimaryIndex
        (Object.class, keyClassName, entityClass, entityClassName);
    Database db = index.getDatabase();

    EntityBinding binding = index.getEntityBinding();
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();

    Cursor readCursor = db.openCursor(null, CursorConfig.READ_UNCOMMITTED);
    try {
        while (readCursor.getNext(key, data, null) ==
               OperationStatus.SUCCESS) {
            if (evolveNeeded(key, data, binding)) {
                Transaction txn = null;
                if (dbConfig.getTransactional()) {
                    boolean success = false;
                    txn = env.beginTransaction(null, null);
                }
                boolean doCommit = false;
                Cursor writeCursor = null;
                try {
                    writeCursor = db.openCursor(txn, null);
                    if (writeCursor.getSearchKey
                            (key, data, LockMode.RMW) ==
                            OperationStatus.SUCCESS) {
                        boolean written = false;
                        if (evolveNeeded(key, data, binding)) {
                            writeCursor.putCurrent(data);
                            written = true;
                        }
                        if (listener != null) {
                            EvolveInternal.updateEvent
                                (event, entityClassName, 1,
                                 written ? 1 : 0);
                            if (!listener.evolveProgress(event)) {
                                break;
                            }
                        }
                    }
                } finally {
                    if (writeCursor != null) {
                        writeCursor.close();
                    }
                    if (txn != null) {
                        if (doCommit) {
                            txn.commit();
                        } else {
                            txn.abort();
                        }
                    }
                }
            }
        }
    } finally {
        readCursor.close();
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:70,代碼來源:Store.java

示例7: evolveIndex

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private void evolveIndex(Format format,
                         EvolveEvent event,
                         EvolveListener listener)
    throws DatabaseException {

    /* We may make this configurable later. */
    final int WRITES_PER_TXN = 1;

    Class entityClass = format.getType();
    String entityClassName = format.getClassName();
    EntityMetadata meta = model.getEntityMetadata(entityClassName);
    String keyClassName = meta.getPrimaryKey().getClassName();
    keyClassName = SimpleCatalog.keyClassName(keyClassName);
    DatabaseConfig dbConfig = getPrimaryConfig(meta);

    PrimaryIndex<Object, Object> index = getPrimaryIndex
        (Object.class, keyClassName, entityClass, entityClassName);
    Database db = index.getDatabase();

    EntityBinding binding = index.getEntityBinding();
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();

    CursorConfig cursorConfig = null;
    Transaction txn = null;
    if (dbConfig.getTransactional()) {
        txn = env.beginTransaction(null, autoCommitTxnConfig);
        cursorConfig = CursorConfig.READ_COMMITTED;
    }

    Cursor cursor = null;
    int nWritten = 0;
    try {
        cursor = db.openCursor(txn, cursorConfig);
        OperationStatus status = cursor.getFirst(key, data, null);
        while (status == OperationStatus.SUCCESS) {
            boolean oneWritten = false;
            if (evolveNeeded(key, data, binding)) {
                cursor.putCurrent(data);
                oneWritten = true;
                nWritten += 1;
            }
            /* Update event stats, even if no listener. [#17024] */
            EvolveInternal.updateEvent
                (event, entityClassName, 1, oneWritten ? 1 : 0);
            if (listener != null) {
                if (!listener.evolveProgress(event)) {
                    break;
                }
            }
            if (txn != null && nWritten >= WRITES_PER_TXN) {
                cursor.close();
                cursor = null;
                txn.commit();
                txn = null;
                txn = env.beginTransaction(null, autoCommitTxnConfig);
                cursor = db.openCursor(txn, cursorConfig);
                DatabaseEntry saveKey = KeyRange.copy(key);
                status = cursor.getSearchKeyRange(key, data, null);
                if (status == OperationStatus.SUCCESS &&
                    KeyRange.equalBytes(key, saveKey)) {
                    status = cursor.getNext(key, data, null);
                }
            } else {
                status = cursor.getNext(key, data, null);
            }
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
        if (txn != null) {
            if (nWritten > 0) {
                txn.commit();
            } else {
                txn.abort();
            }
        }
    }
}
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:81,代碼來源:Store.java


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