Package com.sleepycat.je.tree

Examples of com.sleepycat.je.tree.Node


        }

                    /*
         * If fetchTarget returns null, a deleted LN was cleaned.
         */
                    Node n = null;
                    if (!bin.isEntryKnownDeleted(index)) {
                        n = bin.fetchTarget(index);
                    }
                    if (n != null) {
                        containsDuplicates = n.containsDuplicates();
                        if (searchMode.isDataSearch()) {
                            if (foundExactKey) {
                                /* If the key matches, try the data. */
                                int searchResult = searchAndPositionBoth
                                    (containsDuplicates, n, matchData,
View Full Code Here


         *
         * The index may be negative if we're at an intermediate stage in an
         * higher level operation, and we expect a higher level method to do a
         * next or prev operation after this returns KEYEMPTY. [#11700]
   */
        Node n = null;

        if (targetIndex < 0 ||
            targetIndex >= targetBin.getNEntries() ||
      targetBin.isEntryKnownDeleted(targetIndex)) {
            /* Node is no longer present. */
        } else {

      /*
       * If we encounter a pendingDeleted entry, add it to the compressor
       * queue.
       */
      if (targetBin.isEntryPendingDeleted(targetIndex)) {
    EnvironmentImpl envImpl = database.getDbEnvironment();
    envImpl.addToCompressorQueue
        (targetBin, new Key(targetBin.getKey(targetIndex)), false);
      }

            /* If fetchTarget returns null, a deleted LN was cleaned. */
      try {
    n = targetBin.fetchTarget(targetIndex);
      } catch (DatabaseException DE) {
    targetBin.releaseLatchIfOwner();
    throw DE;
      }
        }
        if (n == null) {
      if (treeStatsAccumulator != null) {
    treeStatsAccumulator.incrementDeletedLNCount();
      }
            targetBin.releaseLatchIfOwner();
            return OperationStatus.KEYEMPTY;
        }

        /*
         * Note that since we have the BIN/DBIN latched, we can safely check
         * the node type. Any conversions from an LN to a dup tree must have
         * the bin latched.
         */
        addCursor(targetBin);
        if (n.containsDuplicates()) {
            assert !duplicateFetch;
            /* Descend down duplicate tree, doing latch coupling. */
            DIN duplicateRoot = (DIN) n;
            duplicateRoot.latch();
            targetBin.releaseLatch();
View Full Code Here

                         */
                        for (int i = origCursor.getIndex() + 1;
                             i < origBIN.getNEntries();
                             i++) {
                            if (!origBIN.isEntryKnownDeleted(i)) {
                                Node n = origBIN.fetchTarget(i);
                                if (n != null && !n.containsDuplicates()) {
                                    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)) {
                                Node n = origBIN.fetchTarget(i);
                                if (n != null && !n.containsDuplicates()) {
                                    LN ln = (LN) n;
                                    /* See comment above about locking. */
                                    if (!ln.isDeleted()) {
                                        ret = true;
                                        break;
                                    }
                                } else {
                                    /* Need to check the DupCountLN. */
                                }
                            }
                        }
                    }
                }
            }
            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();
            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)) {
                            Node n = origDBIN.fetchTarget(i);
                            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)) {
                            Node n = origDBIN.fetchTarget(i);
                            LN ln = (LN) n;
                            /* See comment above about locking. */
                            if (n != null && !ln.isDeleted()) {
                                ret = true;
                                break;
View Full Code Here

                         */
                        siblingsToLog = new TreeMap<Long,Integer>();
                        for (int index = 0;
                             index < parent.getNEntries();
                             index += 1) {
                            Node child = parent.getTarget(index);
                            if (child != null) {
                                Long childId = child.getNodeId();
                                if ((logTargetWithOtherSiblings &&
                                     targetRef.nodeId ==
                                     childId.longValue()) ||
                                    dirtyMap.containsNode
                                        (child.getLevel(), childId)) {
                                    siblingsToLog.put(childId, index);
                                }
                            }
                        }

                        if (logSiblingsWithParentLatchHeld) {
                            if (MULTI_LOG) {
                                mustLogParent |= logSiblings
                                    (envImpl, dirtyMap, parent,
                                     siblingsToLog.values(), allowDeltas,
                                     checkpointStart, highPriority,
                                     provisional, fstats, localTracker);
                            } else {
                                for (int index : siblingsToLog.values()) {
                                    IN child = (IN) parent.getTarget(index);
                                    CheckpointReference childRef =
                                        (targetRef.nodeId ==
                                         child.getNodeId()) ? targetRef :
                                        dirtyMap.removeNode(child.getLevel(),
                                                            child.getNodeId());
                                    assert childRef != null;
                                    mustLogParent |= logSiblings
                                        (envImpl, dirtyMap, parent,
                                         Collections.singleton(index),
                                         allowDeltas, checkpointStart,
View Full Code Here

            if (bin.getNEntries() <= index) {
                return 0;
            }

            /* If fetchTarget returns null, a deleted LN was cleaned. */
            Node n = bin.fetchTarget(index);
            if (n != null && n.containsDuplicates()) {
                DIN dupRoot = (DIN) n;

                /* Latch couple down the tree. */
                dupRoot.latch(cacheMode);
                releaseBIN();
View Full Code Here

                         *
                         * We do not need to fetch a known deleted entry.  We
                         * do need to fetch to determine if this is a dup
                         * database into which we will descend further.
                         */
                        Node n = null;
                        if (!bin.isEntryKnownDeleted(index) &&
                            duplicateRoot == null &&
                            databaseImpl.getSortedDuplicates()) {
                            n = bin.fetchTarget(index);
                        }

                        if (n != null && n.containsDuplicates()) {
                            DIN dupRoot = (DIN) n;
                            dupRoot.latch(cacheMode);
                            in.releaseLatch();
                            in = null;
                            found = positionFirstOrLast(first, dupRoot);
View Full Code Here

                        /*
                         * If fetchTarget returns null, a deleted LN was
                         * cleaned.
                         */
                        Node n = bin.fetchTarget(index);
                        if (n != null) {
                            containsDuplicates = n.containsDuplicates();
                            if (searchMode.isDataSearch()) {
                                if (foundExactKey) {
                                    /* If the key matches, try the data. */
                                    int searchResult = searchAndPositionBoth
                                        (containsDuplicates, n, matchData,
View Full Code Here

        if (in != null &&
            (processDupTree || !in.containsDuplicates())) {
            for (int i = 0; i < in.getNEntries(); i++) {

                long lsn = in.getLsn(i);
                Node node = in.getTarget(i);

                if (in.isEntryPendingDeleted(i) ||
                    in.isEntryKnownDeleted(i)) {

                    /* Dirty LNs (deferred write) get special treatment. */
                    if (node instanceof LN) {
                        LN ln = (LN) node;
                        if (ln.isDirty()) {
                            callback.processDirtyDeletedLN
                                (lsn, ln, in.getKey(i));
                        }
                    }
                    continue;
                }

                if (accumulate &&
                    (node == null) &&
                    lsn != DbLsn.NULL_LSN) {
                    if (accumulatedLSNFileNumbers == null) {
                        accumulatedLSNFileNumbers = new OffsetList();
                        accumulatedLSNFileOffsets = new OffsetList();
                    }

                    accumulatedLSNFileNumbers.add(DbLsn.getFileNumber(lsn),
                                                  false);
                    accumulatedLSNFileOffsets.add(DbLsn.getFileOffset(lsn),
                                                  false);

                    /*
                     * If we're maintaining a map from LSN to owning IN/index,
                     * then update the map here.
                     */
                    addToLsnINMap(Long.valueOf(lsn), in, i);
                    /* callback.processLSN is called when we fetch this LSN. */
                } else if (lsn != DbLsn.NULL_LSN ||
                           passNullLSNNodes) {

                    /*
                     * If the child is resident, use that log type, else we can
                     * assume it's an LN.
                     */
                    byte[] lnKey = (node == null || node instanceof LN) ?
                        in.getKey(i) : null;
                    callProcessLSNHandleExceptions
                        (lsn,
                         (node == null) ?
                          LogEntryType.LOG_LN :
                          node.getLogType(),
                         node, lnKey);
                    if (node instanceof IN) {
                        IN nodeAsIN = (IN) node;
                        try {
                            nodeAsIN.latch(CacheMode.UNCHANGED);
                            accumulateLSNs(nodeAsIN);
                        } finally {
                            nodeAsIN.releaseLatch();
                        }
                    }
                }
            }
        }

        /* Handle the DupCountLN for a DIN root. */
        if (isDINRoot) {
            DIN din = (DIN) in;
            ChildReference dupCountLNRef = din.getDupCountLNRef();
            long lsn = dupCountLNRef.getLsn();
            if (lsn == DbLsn.NULL_LSN) {
                DupCountLN dcl = din.getDupCountLN();
                callback.processDupCount(dcl.getDupCount());
            } else {
                /* Negative index signifies a DupCountLN. */
                addToLsnINMap(Long.valueOf(lsn), in, -1);
                Node node = fetchLSNHandleExceptions(lsn, lnKeyEntry);
                if (node != null) {
                    callProcessLSNHandleExceptions
                        (lsn, LogEntryType.LOG_DUPCOUNTLN, node,
                         dupCountLNRef.getKey());
                }
View Full Code Here

     */
    private void fetchAndProcessLSN(long lsn)
        throws DatabaseException {

        lnKeyEntry.setData(null);
        Node node = fetchLSNHandleExceptions(lsn, lnKeyEntry);
        if (node == null) {
            return;
        }
        boolean isIN = (node instanceof IN);
        IN in = null;
        try {
            if (isIN) {
                in = (IN) node;
                in.latch(CacheMode.UNCHANGED);
            }
            if (node != null) {
                callProcessLSNHandleExceptions
                    (lsn, node.getLogType(), node, lnKeyEntry.getData());

                if (isIN) {
                    accumulateLSNs(in);
                }
            }
View Full Code Here

        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();
View Full Code Here

TOP

Related Classes of com.sleepycat.je.tree.Node

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.