Examples of CursorImpl


Examples of com.sleepycat.je.dbi.CursorImpl

        throws DatabaseException {

        assert locker != null;
        assert dbImpl != null;

        cursorImpl = new CursorImpl(dbImpl,
                                    locker,
                                    false /*retainNonTxnLocks*/);

        readUncommittedDefault =
            cursorConfig.getReadUncommitted() ||
View Full Code Here

Examples of com.sleepycat.je.dbi.CursorImpl

     * Counts duplicates without parameter checking.
     */
    int countInternal()
        throws DatabaseException {
       
        CursorImpl original = null;
        CursorImpl dup = null;

        try {
            // Latch and clone
            original = cursorImpl;
            dup = original.cloneCursor(true);
            return dup.count();
        } finally {
            if (original != null) {
                original.releaseBINs();
            }
      dup.close();
        }
    }
View Full Code Here

Examples of com.sleepycat.je.dbi.CursorImpl

     * cursors.  Does not notify triggers (does not perform secondary updates).
     */
    OperationStatus deleteNoNotify()
        throws DatabaseException {

        CursorImpl original = null;
        CursorImpl dup = null;
  OperationStatus status = OperationStatus.KEYEMPTY;
        try {
            // Clone, add dup to cursor
            original = cursorImpl;
            dup = original.cloneCursor(true);

            // Latch the bins and do the delete with the dup
            dup.latchBINs();
            status = dup.delete();

            return status;
        } finally {
            if (original != null) {
                original.releaseBINs();
            }
            if (dup != null) {
                dup.releaseBINs();
            }

            // Swap if it was a success
            if (status == OperationStatus.SUCCESS) {
                original.close();
                cursorImpl = dup;
            } else {
                dup.close();
            }
        }
    }
View Full Code Here

Examples of com.sleepycat.je.dbi.CursorImpl

                                PutMode putMode,
                                DatabaseEntry returnOldData)
        throws DatabaseException {

        Locker nextKeyLocker = null;
        CursorImpl nextKeyCursor = null;
        try {
            /* If other transactions are serializable, lock the next key. */
            Locker cursorLocker = cursorImpl.getLocker();
            if (putMode != PutMode.CURRENT &&
                dbImpl.getDbEnvironment()
                      .getTxnManager()
                      .areOtherSerializableTransactionsActive(cursorLocker)) {
                nextKeyLocker = new BuddyLocker
                    (dbImpl.getDbEnvironment(), cursorLocker);
                nextKeyCursor = new CursorImpl(dbImpl, nextKeyLocker);
                nextKeyCursor.lockNextKeyForInsert(key, data);
            }

            /* Perform the put operation. */
            return putAllowPhantoms
                (key, data, putMode, returnOldData, nextKeyCursor);
        } finally {
            /* Release the next-key lock. */
            if (nextKeyCursor != null) {
                nextKeyCursor.close();
            }
            if (nextKeyLocker != null) {
                nextKeyLocker.operationEnd();
            }
        }
View Full Code Here

Examples of com.sleepycat.je.dbi.CursorImpl

        if (putMode != PutMode.CURRENT && key == null) {
            throw new IllegalArgumentException
                ("put passed a null DatabaseEntry arg");
        }

        CursorImpl original = null;
        OperationStatus status = OperationStatus.NOTFOUND;
        CursorImpl dup = null;
        try {
            /* Latch and clone. */
            original = cursorImpl;

            if (putMode == PutMode.CURRENT) {
                /* Call addCursor for putCurrent. */
                dup = original.cloneCursor(true);
            } else {

                /*
                 * Do not call addCursor when inserting.  Copy the position of
                 * nextKeyCursor if available.
                 */
                dup = original.cloneCursor(false, nextKeyCursor);
            }

            /* Perform operation. */
            if (putMode == PutMode.CURRENT) {
                status = dup.putCurrent(data, key, returnOldData);
            } else if (putMode == PutMode.OVERWRITE) {
                status = dup.put(key, data, returnOldData);
            } else if (putMode == PutMode.NOOVERWRITE) {
                status = dup.putNoOverwrite(key, data);
            } else if (putMode == PutMode.NODUP) {
                status = dup.putNoDupData(key, data);
            } else {
                throw new InternalException("unknown PutMode");
            }
                   
            return status;
        } finally {
            if (original != null) {
                original.releaseBINs();
            }

            if (status == OperationStatus.SUCCESS) {
                original.close();
                cursorImpl = dup;
            } else {
                if (dup != null) {
                    dup.close();
                }
            }
        }
    }
View Full Code Here

Examples of com.sleepycat.je.dbi.CursorImpl

        throws DatabaseException {

        assert (key != null && data != null);

        OperationStatus status = OperationStatus.NOTFOUND;
        CursorImpl dup = null;
        try {

            /*
             * Pass false: no need to call addCursor here because
             * CursorImpl.position will be adding it after it finds the bin.
             */
            dup = beginRead(false);

            /* Search for first or last. */
            if (!dup.positionFirstOrLast(first, null)) {
                /* Tree is empty. */
                status = OperationStatus.NOTFOUND;
                assert Latch.countLatchesHeld() == 0:
                    Latch.latchesHeldToString();

            } else {
                /* Found something in this tree. */
                assert Latch.countLatchesHeld() == 1:
                    Latch.latchesHeldToString();
                status = dup.getCurrentAlreadyLatched
                    (key, data, lockType, first);

                if (status == OperationStatus.SUCCESS) {
        if (dup.getDupBIN() != null) {
      dup.incrementLNCount();
        }
                } else {
                    /* The record we're pointing at may be deleted. */
                    status = dup.getNext(key, data, lockType, first, false);
    }
            }
        } finally {

            /*
 
View Full Code Here

Examples of com.sleepycat.je.dbi.CursorImpl

            SearchMode.SET_RANGE : SearchMode.BOTH_RANGE;

        KeyChangeStatus result = null;
        boolean noNextKeyFound;

        CursorImpl dup =
            beginRead(false /* searchAndPosition will add cursor */);

        try {

            /*
 
View Full Code Here

Examples of com.sleepycat.je.dbi.CursorImpl

                                                SearchMode searchMode)
        throws DatabaseException {

        OperationStatus status = OperationStatus.NOTFOUND;

        CursorImpl dup =
            beginRead(false /* searchAndPosition will add cursor */);

        try {
            KeyChangeStatus result = searchInternal
                (dup, key, data, searchLockType, advanceLockType, searchMode);
View Full Code Here

Examples of com.sleepycat.je.dbi.CursorImpl

         * Perform a NEXT and return NOTFOUND if the key changes
         * during the search.
         */
        while (true) {
            assert Latch.countLatchesHeld() == 0;
            CursorImpl dup = beginRead(true);

      try {
                KeyChangeStatus result = dup.getNextWithKeyChangeStatus
                    (tryKey, tryData, lockType, true, false);
                status = result.status;
                noNextKeyFound = (status != OperationStatus.SUCCESS);
                if (result.keyChange && status == OperationStatus.SUCCESS) {
                    status = OperationStatus.NOTFOUND;
View Full Code Here

Examples of com.sleepycat.je.dbi.CursorImpl

        DatabaseEntry tempData = new DatabaseEntry();
        tempKey.setPartial(0, 0, true);
        tempData.setPartial(0, 0, true);

        OperationStatus status;
        CursorImpl dup = cursorImpl.cloneCursor(true);
        try {
            if (getMode == GetMode.PREV_NODUP) {
                status = dup.getFirstDuplicate
                    (tempKey, tempData, LockType.RANGE_READ);
            } else {
                status = dup.getCurrent
                    (tempKey, tempData, LockType.RANGE_READ);
            }
            if (status != OperationStatus.SUCCESS) {
                while (true) {
                    assert Latch.countLatchesHeld() == 0;

                    status = dup.getNext
                        (tempKey, tempData, LockType.RANGE_READ, true, false);

                    if (checkForInsertion(GetMode.NEXT, cursorImpl, dup)) {
                        dup.close();
                        dup = cursorImpl.cloneCursor(true);
                        continue;
                    } else {
                        assert Latch.countLatchesHeld() == 0;
                        break;
                    }
                }
            }
        } finally {
            dup.close();
        }

        if (status != OperationStatus.SUCCESS) {
            cursorImpl.lockEofNode(LockType.RANGE_READ);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.