Package com.sleepycat.je.dbi

Examples of com.sleepycat.je.dbi.CursorImpl


    /**
     * FUTURE: use internal skip method instead, saving a btree lookup.
     */
    private void sampleNextBIN(CursorImpl beginOrEndCursor,
                               boolean moveForward) {
        final CursorImpl cursor = beginOrEndCursor.cloneCursor
            (true /*addCursor*/, CacheMode.UNCHANGED);
        try {
            final BIN bin = cursor.latchBIN();
            if (moveForward) {
                cursor.setIndex(bin.getNEntries() - 1);
            } else {
                cursor.setIndex(0);
            }
            final OperationStatus status = cursor.getNext
                (null /*foundKey*/, null /*foundData*/, LockType.NONE,
                 moveForward, true /*alreadyLatched*/,
                 null /*rangeConstraint*/);
            if (status == OperationStatus.SUCCESS && cursor.getBIN() != bin) {
                final List<TrackingInfo> stack = getParentStack(cursor);
                if (stack != null) {
                    addAvgEntriesSample(stack);
                }
            }
        } finally {
            cursor.close();
        }
    }
View Full Code Here


        } catch (RuntimeException e) {
            locker.operationEnd();
            throw e;
        }

        cursorImpl = new CursorImpl(databaseImpl, locker, retainNonTxnLocks);

        transaction = locker.getTransaction();

        cacheMode = databaseImpl.getDefaultCacheMode();
View Full Code Here

                              final LockMode lockMode) {
        final LockType lockType = getLockType(lockMode, false);
        synchronized (getTxnSynchronizer()) {
            checkTxnState();
            while (true) {
                final CursorImpl dup = beginMoveCursor(true);
                boolean success = false;
                try {
                    final long count = dup.skip(forward, maxCount,
                                                null /*rangeConstraint*/);
                    if (count <= 0) {
                        return 0;
                    }
                    final OperationStatus status =
View Full Code Here

            }
        };

        OperationStatus status = OperationStatus.NOTFOUND;
        final LockType lockType = getLockType(lockMode, false);
        final CursorImpl dup =
            beginMoveCursor(false /* searchAndPosition will add cursor */);
        try {
            final KeyChangeStatus result =
                searchInternal(dup, key, data,
                               lockType /*searchLockType*/,
 
View Full Code Here

        assert ln != null;
        assert putMode != null;
        assert putMode != PutMode.CURRENT;

        Locker nextKeyLocker = null;
        CursorImpl nextKeyCursor = null;
        try {
            /* If other transactions are serializable, lock the next key. */
            Locker cursorLocker = cursorImpl.getLocker();
            if (dbImpl.getDbEnvironment().
                getTxnManager().
                areOtherSerializableTransactionsActive(cursorLocker)) {
                nextKeyLocker = BuddyLocker.createBuddyLocker
                    (dbImpl.getDbEnvironment(), cursorLocker);
                nextKeyCursor = new CursorImpl(dbImpl, nextKeyLocker);
                /* Perform eviction for user cursors. */
                nextKeyCursor.setAllowEviction(true);
                nextKeyCursor.lockNextKeyForInsert(key);
            }

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

        /*
         * Do not call addCursor when inserting.  Copy the position of
         * nextKeyCursor if available.
         */
        final CursorImpl dup = beginMoveCursor(false, nextKeyCursor);
        try {
            /* Perform operation. */
            status = dup.put(key, data, ln, putMode, returnOldData,
                             returnNewData, repContext);
            /* Note that status is used in the finally. */
            return status;
        } finally {
            endMoveCursor(dup, status == OperationStatus.SUCCESS);
View Full Code Here

        /*
         * Pass false: no need to call addCursor here because
         * CursorImpl.position will be adding it after it finds the bin.
         */
        final CursorImpl dup = beginMoveCursor(false);
        try {
            /* Search for first or last. */
            if (!dup.positionFirstOrLast(first)) {
                /* Tree is empty. */
                status = OperationStatus.NOTFOUND;
                assert LatchSupport.countLatchesHeld() == 0:
                    LatchSupport.latchesHeldToString();
            } else {
                /* Found something in this tree. */
                assert LatchSupport.countLatchesHeld() == 1:
                    LatchSupport.latchesHeldToString();

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

View Full Code Here

                                final Comparator<byte[]> searchComparator) {
        KeyChangeStatus result = null;
        DatabaseEntry origData = new DatabaseEntry
            (data.getData(), data.getOffset(), data.getSize());

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

        try {

            /*
 
View Full Code Here

                            final RangeConstraint rangeConstraint) {
        OperationStatus status = OperationStatus.NOTFOUND;
        DatabaseEntry origData = new DatabaseEntry
            (data.getData(), data.getOffset(), data.getSize());

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

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

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

        OperationStatus status;
        CursorImpl dup = cursorImpl.cloneCursor(true /*addCursor*/, cacheMode);
        try {
            status = dup.getCurrent
                (tempKey, tempData, LockType.RANGE_READ);
            if (status != OperationStatus.SUCCESS) {
                while (true) {
                    assert LatchSupport.countLatchesHeld() == 0;

                    status = dup.getNext
                        (tempKey, tempData, LockType.RANGE_READ, true, false,
                         null /*rangeConstraint*/);

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

        if (status != OperationStatus.SUCCESS) {
            cursorImpl.lockEof(LockType.RANGE_READ);
        }
View Full Code Here

TOP

Related Classes of com.sleepycat.je.dbi.CursorImpl

Copyright © 2018 www.massapicom. 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.