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


Java Cursor.getDatabase方法代碼示例

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


在下文中一共展示了Cursor.getDatabase方法的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: closeCursor

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * Closes a cursor.
 *
 * @param cursor the cursor to close.
 *
 * @throws DatabaseException if a database problem occurs.
 */
void closeCursor(Cursor cursor)
    throws DatabaseException {

    if (cursor == null) {
        return;
    }
    if (cdbMode) {
        WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
        if (cdbCursorsMap != null) {
            Database db = cursor.getDatabase();
            CdbCursors cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
            if (cdbCursors != null) {
                if (cdbCursors.readCursors.remove(cursor) ||
                    cdbCursors.writeCursors.remove(cursor)) {
                    cursor.close();
                    return;
                }
            }
        }
        throw new IllegalStateException(
          "closing CDB cursor that was not known to be open");
    } else {
        cursor.close();
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:33,代碼來源:CurrentTransaction.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: closeCursor

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * Closes a cursor.
 *
 * @param cursor the cursor to close.
 *
 * @throws DatabaseException if a database problem occurs.
 */
void closeCursor(Cursor cursor)
    throws DatabaseException {

    if (cursor == null) {
        return;
    }
    if (cdbMode) {
        WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
        if (cdbCursorsMap != null) {
            Database db = cursor.getDatabase();
            CdbCursors cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
            if (cdbCursors != null) {
                if (cdbCursors.readCursors.remove(cursor) ||
                    cdbCursors.writeCursors.remove(cursor)) {
                    cursor.close();
                    return;
                }
            }
        }
        throw new IllegalStateException
            ("Closing CDB cursor that was not known to be open");
    } else {
        cursor.close();
    }
}
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:33,代碼來源:CurrentTransaction.java


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