Package com.sleepycat.je.tree

Examples of com.sleepycat.je.tree.BIN


  DataWalker dw = new DataWalker(bins) {
    void perData(String foundKey, String foundData)
        throws DatabaseException {
                    CursorImpl cursorImpl = DbTestProxy.dbcGetCursorImpl(cursor);
        BIN lastBin = cursorImpl.getBIN();
        DBIN lastDupBin = cursorImpl.getDupBIN();
        if (rnd.nextInt(10) < 8) {
      cursor.delete();
        }
                    dataMap.put(lastBin, lastBin);
                    dataMap.put(lastDupBin, lastDupBin);
    }
      };
  dw.setIgnoreDataMap(true);
  dw.walkData();
  dw.close();
  Enumeration e = bins.keys();
  while (e.hasMoreElements()) {
      BIN b = (BIN) e.nextElement();
      assertFalse(b.getCursorSet().size() > 0);
  }
    }
View Full Code Here


    private boolean checkForInsertion(GetMode getMode,
                                      CursorImpl origCursor,
                                      CursorImpl dupCursor)
        throws DatabaseException {

        BIN origBIN = origCursor.getBIN();
        BIN dupBIN = dupCursor.getBIN();
        DBIN origDBIN = origCursor.getDupBIN();

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

        boolean forward = true;
View Full Code Here

    private long getFile(Cursor cursor)
        throws DatabaseException {

        CursorImpl impl = DbTestProxy.dbcGetCursorImpl(cursor);
        int index;
        BIN bin = impl.getDupBIN();
        if (bin != null) {
            index = impl.getDupIndex();
        } else {
            bin = impl.getBIN();
            assertNotNull(bin);
            index = impl.getIndex();
        }
        assertNotNull(bin.getTarget(index));
        long lsn = bin.getLsn(index);
        assertTrue(lsn != DbLsn.NULL_LSN);
        long file = DbLsn.getFileNumber(lsn);
        assert file > lastFileSeen;
        lastFileSeen = file;
        return file;
View Full Code Here

     */
    private long getLsn(Cursor cursor)
        throws DatabaseException {

        CursorImpl impl = DbTestProxy.dbcGetCursorImpl(cursor);
        BIN bin;
        int index;
        if (dups) {
            bin = impl.getDupBIN();
            index = impl.getDupIndex();
            if (bin == null) {
                bin = impl.getBIN();
                index = impl.getIndex();
                assertNotNull(bin);
            }
        } else {
            assertNull(impl.getDupBIN());
            bin = impl.getBIN();
            index = impl.getIndex();
            assertNotNull(bin);
        }
        assertTrue(index >= 0);
        long lsn = bin.getLsn(index);
        assertTrue(lsn != DbLsn.NULL_LSN);
        return lsn;
    }
View Full Code Here

     */
    private static VLSN getVLSN(Cursor cursor, LogManager logManager)
        throws Exception {

        CursorImpl cursorImpl = DbInternal.getCursorImpl(cursor);
        BIN bin = cursorImpl.getBIN();
        int index = cursorImpl.getIndex();
        DBIN dbin = cursorImpl.getDupBIN();
        int dupIndex = cursorImpl.getDupIndex();

        final long lsn =
            (dbin != null) ? dbin.getLsn(dupIndex) : bin.getLsn(index);

        WholeEntry entry = logManager.getLogEntryAllowInvisible(lsn);

        VLSN vlsn = entry.getHeader().getVLSN();
        if (vlsn == null) {
View Full Code Here

       
        /* Make a child reference as a candidate for insertion. */
        ChildReference newLNRef =
      new ChildReference(null, location.lnKey, logLsn);

        BIN parentBIN = location.bin;
        int entryIndex = parentBIN.insertEntry1(newLNRef);

        if ((entryIndex & IN.INSERT_SUCCESS) == 0) {

            /*
       * Entry may have been a duplicate. Insertion was not successful.
       */
            entryIndex &= ~IN.EXACT_MATCH;

            boolean canOverwrite = false;
            if (parentBIN.isEntryKnownDeleted(entryIndex)) {
                canOverwrite = true;
            } else {

                /*
                 * Read the LN that's in this slot to check for deleted
                 * status.  No need to lock, since this is recovery.  If
                 * fetchTarget returns null, a deleted LN was cleaned.
                 */
                LN currentLN = (LN) parentBIN.fetchTarget(entryIndex);

                if (currentLN == null || currentLN.isDeleted()) {
                    canOverwrite = true;
                }

                /*
     * Evict the target again manually, to reduce memory
     * consumption while the evictor is not running.
                 */
    parentBIN.updateEntry(entryIndex, null);
            }

            if (canOverwrite) {
                parentBIN.updateEntry(entryIndex, null, logLsn,
                                      location.lnKey);
                parentBIN.clearKnownDeleted(entryIndex);
                location.index = entryIndex;
                return true;
            } else {
                return false;
            }
View Full Code Here

        /* Status variables are used to generate debug tracing info. */
        boolean processedHere = true; // The LN was cleaned here.
        boolean obsolete = false;     // The LN is no longer in use.
        boolean completed = false;    // This method completed.

        BIN bin = null;
        DIN parentDIN = null;      // for DupCountLNs
        try {

            /*
             * If the DB is gone, this LN is obsolete.  If delete cleanup is in
             * progress, put the DB into the DB pending set; this LN will be
             * declared deleted after the delete cleanup is finished.
             */
            if (db == null || db.isDeleted()) {
                cleaner.addPendingDB(db);
                nLNsDeadThisRun++;
                obsolete = true;
                completed = true;
                return;
            }

            Tree tree = db.getTree();
            assert tree != null;

            /*
       * Search down to the bottom most level for the parent of this LN.
       */
            boolean parentFound = tree.getParentBINForChildLN
                (location, key, dupKey, ln,
                 false,  // splitsAllowed
                 true,   // findDeletedEntries
                 false,  // searchDupTree
                 Cleaner.UPDATE_GENERATION);
            bin = location.bin;
            int index = location.index;

            if (!parentFound) {
                nLNsDeadThisRun++;
    obsolete = true;
                completed = true;
    return;
            }

      /*
       * Now we're at the parent for this LN, whether BIN, DBIN or DIN.
       * If knownDeleted, LN is deleted and can be purged.
       */
      if (bin.isEntryKnownDeleted(index)) {
    nLNsDeadThisRun++;
    obsolete = true;
    completed = true;
                return;
      }

            /*
             * Determine whether the parent is the current BIN, or in the case
             * of a DupCountLN, a DIN.  Get the tree LSN in either case.
             */
            boolean isDupCountLN = ln.containsDuplicates();
            long treeLsn;
      if (isDupCountLN) {
    parentDIN = (DIN) bin.fetchTarget(index);
    parentDIN.latch(Cleaner.UPDATE_GENERATION);
                ChildReference dclRef = parentDIN.getDupCountLNRef();
                treeLsn = dclRef.getLsn();
      } else {
                treeLsn = bin.getLsn(index);
      }

            /* Process this LN that was found in the tree. */
            processedHere = false;
            processFoundLN(info, logLsn, treeLsn, bin, index, parentDIN);
            completed = true;

            /*
             * For all other non-deleted LNs in this BIN, lookup their LSN
             * in the LN queue and process any matches.
             */
            if (!isDupCountLN) {
                for (int i = 0; i < bin.getNEntries(); i += 1) {
                    long lsn = bin.getLsn(i);
                    if (i != index &&
                        !bin.isEntryKnownDeleted(i) &&
                        !bin.isEntryPendingDeleted(i) &&
                        DbLsn.getFileNumber(lsn) == fileNum.longValue()) {

                        Long myOffset = new Long(DbLsn.getFileOffset(lsn));
                        LNInfo myInfo = lookAheadCache.remove(myOffset);

                        if (myInfo != null) {
                            nLNQueueHitsThisRun++;
                            nLNsCleanedThisRun++;
                            processFoundLN(myInfo, lsn, lsn, bin, i, null);
                        }
                    }
                }
            }

            return;
        } finally {
            if (parentDIN != null) {
                parentDIN.releaseLatchIfOwner();
            }

            if (bin != null) {
                bin.releaseLatchIfOwner();
            }

            if (processedHere) {
                cleaner.trace
                    (cleaner.detailedTraceLevel, Cleaner.CLEAN_LN, ln, logLsn,
View Full Code Here

    private boolean checkForInsertion(GetMode getMode,
                                      CursorImpl origCursor,
                                      CursorImpl dupCursor)
        throws DatabaseException {

        BIN origBIN = origCursor.getBIN();
        BIN dupBIN = dupCursor.getBIN();
        DBIN origDBIN = origCursor.getDupBIN();

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

        boolean forward = true;
View Full Code Here

     * @param key on return contains the key if available, or null.
     * @param data on return contains the data if available, or null.
     */
    public boolean advanceCursor(DatabaseEntry key, DatabaseEntry data) {

        BIN oldBin = bin;
        BIN oldDupBin = dupBin;
        int oldIndex = index;
        int oldDupIndex = dupIndex;

        key.setData(null);
        data.setData(null);
View Full Code Here

    public BIN latchBIN()
        throws DatabaseException {

  while (bin != null) {
      BIN waitingOn = bin;
      waitingOn.latch();
      if (bin == waitingOn) {
    return bin;
      }
      waitingOn.releaseLatch();
  }

  return null;
    }
View Full Code Here

TOP

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

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.