Examples of DBIN


Examples of com.sleepycat.je.tree.DBIN

                        }
                    }
        assert (LatchSupport.countLatchesHeld() == 0);

        dupBinToBeRemoved.latch();
        DBIN newDupBin;

        if (forward) {
      newDupBin = (DBIN) database.getTree().getNextBin
          (dupBinToBeRemoved,  
              true /* traverseWithinDupTree*/);
        } else {
      newDupBin = (DBIN) database.getTree().getPrevBin
          (dupBinToBeRemoved,
           true /* traverseWithinDupTree*/);
        }

        if (newDupBin == null) {
      return OperationStatus.NOTFOUND;
        } else {
      if (forward) {
          dupIndex = -1;
      } else {
          dupIndex = newDupBin.getNEntries();
      }
      addCursor(newDupBin);

      /*
       * Ensure that setting dupBin is under newDupBin's
View Full Code Here

Examples of com.sleepycat.je.tree.DBIN

            return (BIN) in;
        }

        /* We need to descend down into a duplicate tree. */
        DIN duplicateRoot = null;
        DBIN duplicateBin = null;
        BIN bin = (BIN) in;
        try {
            int index = bin.findEntry(mainKey, false, true);
            if (index >= 0) {
                Node node = null;
    if (!bin.isEntryKnownDeleted(index)) {
                    /* If fetchTarget returns null, a deleted LN was cleaned. */
                    node = bin.fetchTarget(index);
                }
                if (node == null) {
        bin.releaseLatch();
        return null;
    }
                if (node.containsDuplicates()) {
                    /* It's a duplicate tree. */
                    duplicateRoot = (DIN) node;
                    duplicateRoot.latch();
                    bin.releaseLatch();
                    duplicateBin = (DBIN) tree.searchSubTree
                        (duplicateRoot, dupKey, SearchType.NORMAL, -1, null,
                         false /*updateGeneration*/);

                    return duplicateBin;
                } else {
                    /* We haven't migrated to a duplicate tree yet.
                     * XXX, isn't this taken care of above? */
                    return bin;
                }
            } else {
                bin.releaseLatch();
                return null;
            }
        } catch (DatabaseException DBE) {
            if (bin != null) {
                bin.releaseLatchIfOwner();
            }
            if (duplicateRoot != null) {
                duplicateRoot.releaseLatchIfOwner();
            }

      /*
       * FindBugs whines about Redundent comparison to null below, but
       * for stylistic purposes we'll leave it in.
       */
            if (duplicateBin != null) {
                duplicateBin.releaseLatchIfOwner();
            }
            throw DBE;
        }
    }
View Full Code Here

Examples of com.sleepycat.je.tree.DBIN

    }

    private void removeCursorDBIN()
        throws DatabaseException {

        DBIN abin = latchDBIN();
        if (abin != null) {
            abin.removeCursor(this);
            abin.releaseLatch();
        }
    }
View Full Code Here

Examples of com.sleepycat.je.tree.DBIN

                        }
                    }
                    assert (LatchSupport.countLatchesHeld() == 0);

                    dupBinToBeRemoved.latch(cacheMode);
                    DBIN newDupBin;

                    if (forward) {
                        newDupBin = (DBIN) databaseImpl.getTree().getNextBin
                            (dupBinToBeRemoved,
                             true /*traverseWithinDupTree*/,
                             cacheMode);
                    } else {
                        newDupBin = (DBIN) databaseImpl.getTree().getPrevBin
                            (dupBinToBeRemoved,
                             true /*traverseWithinDupTree*/,
                             cacheMode);
                    }

                    if (newDupBin == null) {
                        return OperationStatus.NOTFOUND;
                    } else {
                        if (forward) {
                            dupIndex = -1;
                        } else {
                            dupIndex = newDupBin.getNEntries();
                        }
                        addCursor(newDupBin);

                        /*
                         * Ensure that setting dupBin is under newDupBin's
View Full Code Here

Examples of com.sleepycat.je.tree.DBIN

        }

        /* We need to descend down into a duplicate tree. */
        DIN duplicateRoot = null;
        boolean duplicateRootIsLatched = false;
        DBIN duplicateBin = null;
        BIN bin = (BIN) in;
        boolean binIsLatched = true;
        try {
            int index = bin.findEntry(mainKey, false, true);
            if (index >= 0) {
                Node node = null;
                if (!bin.isEntryKnownDeleted(index)) {

                    /*
                     * If fetchTarget returns null, a deleted LN was cleaned.
                     */
                    node = bin.fetchTarget(index);
                }
                if (node == null) {
                    bin.releaseLatch();
                    binIsLatched = false;
                    return null;
                }
                if (node.containsDuplicates()) {
                    /* It's a duplicate tree. */
                    duplicateRoot = (DIN) node;
                    duplicateRoot.latch(CacheMode.UNCHANGED);
                    duplicateRootIsLatched = true;
                    bin.releaseLatch();
                    binIsLatched = false;
                    duplicateBin = (DBIN) tree.searchSubTree
                        (duplicateRoot, dupKey, SearchType.NORMAL, -1, null,
                         CacheMode.UNCHANGED);
                    duplicateRootIsLatched = false;

                    return duplicateBin;
                } else {
                    /* We haven't migrated to a duplicate tree yet. */
                    return bin;
                }
            } else {
                bin.releaseLatch();
                binIsLatched = false;
                return null;
            }
        } catch (DatabaseException DBE) {
            if (bin != null &&
                binIsLatched) {
                bin.releaseLatch();
            }

            if (duplicateRoot != null &&
                duplicateRootIsLatched) {
                duplicateRoot.releaseLatch();
            }

            /*
             * FindBugs whines about Redundent comparison to null below, but
             * for stylistic purposes we'll leave it in.
             */
            if (duplicateBin != null) {
                duplicateBin.releaseLatch();
            }
            throw DBE;
        }
    }
View Full Code Here

Examples of com.sleepycat.je.tree.DBIN

    private boolean checkForInsertion(final GetMode getMode,
                                      final CursorImpl origCursor,
                                      final CursorImpl dupCursor) {
        final BIN origBIN = origCursor.getBIN();
        final BIN dupBIN = dupCursor.getBIN();
        final DBIN origDBIN = origCursor.getDupBIN();

        /* If fetchTarget returns null below, a deleted LN was cleaned. */

        boolean forward = true;
        if (getMode == GetMode.PREV ||
            getMode == GetMode.PREV_DUP ||
            getMode == GetMode.PREV_NODUP) {
            forward = false;
        }
        boolean ret = false;
        if (origBIN != dupBIN) {
            /* We jumped to the next BIN during getNext(). */
            origCursor.latchBINs();

            try {
                if (origDBIN == null) {
                    if (forward) {
                        if (origBIN.getNEntries() - 1 >
                            origCursor.getIndex()) {

                            /*
                             * We were adjusted to something other than the
                             * last entry so some insertion happened.
                             */
                            for (int i = origCursor.getIndex() + 1;
                                 i < origBIN.getNEntries();
                                 i++) {
                                if (!origBIN.isEntryKnownDeleted(i)) {
                                    final Node n = origBIN.fetchTarget(i);
                                    if (n != null && !n.containsDuplicates()) {
                                        final LN ln = (LN) n;
                                        /* See comment above about locking. */
                                        if (!ln.isDeleted()) {
                                            ret = true;
                                            break;
                                        }
                                    }
                                } else {
                                    /* Need to check the DupCountLN. */
                                }
                            }
                        }
                    } else {
                        if (origCursor.getIndex() > 0) {

                            /*
                             * We were adjusted to something other than the
                             * first entry so some insertion happened.
                             */
                            for (int i = 0; i < origCursor.getIndex(); i++) {
                                if (!origBIN.isEntryKnownDeleted(i)) {
                                    final Node n = origBIN.fetchTarget(i);
                                    if (n != null && !n.containsDuplicates()) {
                                        final LN ln = (LN) n;
                                        /* See comment above about locking. */
                                        if (!ln.isDeleted()) {
                                            ret = true;
                                            break;
                                        }
                                    } else {
                                        /* Need to check the DupCountLN. */
                                    }
                                }
                            }
                        }
                    }
                }
            } finally {
                origCursor.releaseBINs();
            }
            return ret;
        }

        if (origDBIN != dupCursor.getDupBIN() &&
            origCursor.getIndex() == dupCursor.getIndex() &&
            getMode != GetMode.NEXT_NODUP &&
            getMode != GetMode.PREV_NODUP) {
            /* Same as above, only for the dupBIN. */
            origCursor.latchBINs();
            try {
                if (forward) {
                    if (origDBIN.getNEntries() - 1 >
                        origCursor.getDupIndex()) {

                        /*
                         * We were adjusted to something other than the last
                         * entry so some insertion happened.
                         */
                        for (int i = origCursor.getDupIndex() + 1;
                             i < origDBIN.getNEntries();
                             i++) {
                            if (!origDBIN.isEntryKnownDeleted(i)) {
                                final Node n = origDBIN.fetchTarget(i);
                                final LN ln = (LN) n;
                                /* See comment above about locking. */
                                if (n != null && !ln.isDeleted()) {
                                    ret = true;
                                    break;
                                }
                            }
                        }
                    }
                } else {
                    if (origCursor.getDupIndex() > 0) {

                        /*
                         * We were adjusted to something other than the first
                         * entry so some insertion happened.
                         */
                        for (int i = 0; i < origCursor.getDupIndex(); i++) {
                            if (!origDBIN.isEntryKnownDeleted(i)) {
                                final Node n = origDBIN.fetchTarget(i);
                                final LN ln = (LN) n;
                                /* See comment above about locking. */
                                if (n != null && !ln.isDeleted()) {
                                    ret = true;
                                    break;
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.