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


Java Cursor.dup方法代碼示例

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


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

示例1: dupCursor

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * Duplicates a cursor for a given database.
 *
 * @param writeCursor true to open a write cursor in a CDB environment, and
 * ignored for other environments.
 *
 * @param samePosition is passed through to Cursor.dup().
 *
 * @return the open cursor.
 *
 * @throws DatabaseException if a database problem occurs.
 */
Cursor dupCursor(Cursor cursor, boolean writeCursor, boolean samePosition)
    throws DatabaseException {

    if (cdbMode) {
        WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
        if (cdbCursorsMap != null) {
            Database db = cursor.getDatabase();
            CdbCursors cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
            if (cdbCursors != null) {
                List cursors = writeCursor ? cdbCursors.writeCursors
                                           : cdbCursors.readCursors;
                if (cursors.contains(cursor)) {
                    Cursor newCursor = cursor.dup(samePosition);
                    cursors.add(newCursor);
                    return newCursor;
                }
            }
        }
        throw new IllegalStateException("cursor to dup not tracked");
    } else {
        return cursor.dup(samePosition);
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:36,代碼來源:CurrentTransaction.java

示例2: testCursorDupAndCloseDb

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

       initEnv(false);
       DatabaseConfig dbConfig = new DatabaseConfig();
       dbConfig.setAllowCreate(true);
       Database myDb = exampleEnv.openDatabase(null, "fooDb", dbConfig);

myDb.put(null, new StringDbt("blah"), new StringDbt("blort"));
Cursor cursor = myDb.openCursor(null, null);
OperationStatus status = cursor.getNext(new DatabaseEntry(),
                                               new DatabaseEntry(),
                                               LockMode.DEFAULT);
Cursor cursorDup = cursor.dup(true);
cursor.close();
cursorDup.close();
myDb.close();
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:19,代碼來源:DbCursorDupTest.java

示例3: dupCursor

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * Duplicates a cursor for a given database.
 *
 * @param writeCursor true to open a write cursor in a CDB environment, and
 * ignored for other environments.
 *
 * @param samePosition is passed through to Cursor.dup().
 *
 * @return the open cursor.
 *
 * @throws DatabaseException if a database problem occurs.
 */
Cursor dupCursor(Cursor cursor, boolean writeCursor, boolean samePosition)
    throws DatabaseException {

    if (cdbMode) {
        WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
        if (cdbCursorsMap != null) {
            Database db = cursor.getDatabase();
            CdbCursors cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
            if (cdbCursors != null) {
                List cursors = writeCursor ? cdbCursors.writeCursors
                                           : cdbCursors.readCursors;
                if (cursors.contains(cursor)) {
                    Cursor newCursor = cursor.dup(samePosition);
                    cursors.add(newCursor);
                    return newCursor;
                }
            }
        }
        throw new IllegalStateException("Cursor to dup not tracked");
    } else {
        return cursor.dup(samePosition);
    }
}
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:36,代碼來源:CurrentTransaction.java

示例4: dupCursor

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * Dups the given cursor.
 */
protected Cursor dupCursor(Cursor cursor, boolean samePosition)
    throws DatabaseException {

    return cursor.dup(samePosition);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:9,代碼來源:RangeCursor.java


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