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

     */
    protected boolean retrieveData(Tree tree, byte[] key)
  throws DatabaseException {

  TestUtils.checkLatchCount();
  Node n = tree.search(key, Tree.SearchType.NORMAL, -1, null, true);
  if (!(n instanceof BIN)) {
      fail("search didn't return a BIN for key: " + key);
  }
  BIN bin = (BIN) n;
  try {
View Full Code Here

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

                        DatabaseImpl database = origBIN.getDatabase();
                        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.
                         */
                        DatabaseImpl database = origBIN.getDatabase();
                        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.
                     */
                    DatabaseImpl database = origDBIN.getDatabase();
                    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.
                     */
                    DatabaseImpl database = origDBIN.getDatabase();
                    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

    in.isEntryKnownDeleted(i)) {
    continue;
      }

      long lsn = in.getLsn(i);
      Node node = in.getTarget(i);
      if (accumulate && (node == null)) {
                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(new Long(lsn), in, i);
                /* callback.processLSN is called when we fetch this LSN. */
            } else {

                /*
                 * If the child is resident, use that log type, else we can
                 * assume it's a LN.
                 */
                callback.processLSN(lsn,
                                    (node == null) ? LogEntryType.LOG_LN :
                                    node.getLogType());
            }
  }

        /* Handle the DupCountLN for a DIN root. */
        if (in instanceof DIN) {
View Full Code Here

     * it is an IN, accumulate LSNs for it.
     */
    private void fetchAndProcessLSN(long lsn)
  throws DatabaseException {

  Node node = fetchLSN(lsn);
  if (node != null) {
      callback.processLSN(lsn, node.getLogType());

      if (node instanceof IN) {
    accumulateLSNs((IN) node);
      }
  }
View Full Code Here

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

                        /*
                         * See if we need to descend further.  If fetchTarget
                         * returns null, a deleted LN was cleaned.
                         */
                        Node n = null;
                        if (!in.isEntryKnownDeleted(index)) {
                            n = in.fetchTarget(index);
                        }

                        if (n != null && n.containsDuplicates()) {
                            DIN dupRoot = (DIN) n;
                            dupRoot.latch();
                            in.releaseLatch();
                            in = null;
                            found = positionFirstOrLast(first, dupRoot);
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.