Package com.sleepycat.je.tree

Examples of com.sleepycat.je.tree.BIN


         * We need at least 2 BINs, otherwise empty BINs won't be deleted.  So
         * we add keys until the BIN splits, then delete everything in the
         * first BIN except the first two keys.  Those are the keys we'll use
         * for testing, and are key values 0 and 1.
         */
        BIN firstBin = null;
        OperationStatus status;
        for (int i = 0;; i += 1) {
            DatabaseEntry key = new DatabaseEntry(new byte[] { (byte) i });
            status = db.put(null, key, entry0);
            assertEquals(OperationStatus.SUCCESS, status);
            Cursor cursor = db.openCursor(null, null);
            status = cursor.getLast(keyFound, dataFound, null);
            assertEquals(OperationStatus.SUCCESS, status);
            BIN b = DbInternal.getCursorImpl(cursor).getBIN();
            cursor.close();
            if (firstBin == null) {
                firstBin = b;
            } else if (firstBin != b) {
                /* Now delete all but the first two keys in the first BIN. */
 
View Full Code Here


     * non-provisionally.  Used to simulate a partial checkpoint or eviction.
     */
    public static void logBINAndIN(Environment env, Cursor cursor)
        throws DatabaseException {

        BIN bin = getBIN(cursor);
        Tree tree = bin.getDatabase().getTree();
        bin.latch();
        SearchResult result = tree.getParentINForChildIN(bin, true, true);
        assert result.parent != null;
        result.parent.releaseLatch();
        assert result.exactParentFound;
        IN in = result.parent;
View Full Code Here

     */
    public static BIN getBIN(Cursor cursor)
        throws DatabaseException {

        CursorImpl impl = DbTestProxy.dbcGetCursorImpl(cursor);
        BIN bin = impl.getDupBIN();
        if (bin == null) {
            bin = impl.getBIN();
            assert bin != null;
        }
        return bin;
View Full Code Here

  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 {
      int index = bin.findEntry(key, false, true);
      if (index == -1) {
    return false;
      }
      return true;
  } finally {
      bin.releaseLatch();
      TestUtils.checkLatchCount();
  }
    }
View Full Code Here

        assertEquals(OperationStatus.SUCCESS, db.put(null, key, data));
        IntegerBinding.intToEntry(20, key);
        assertEquals(OperationStatus.SUCCESS, db.put(null, key, data));
       
        EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
        BIN bin = (BIN)tree.getFirstNode();
        bin.log(envImpl.getLogManager(), true, false, false, null);
        bin = tree.getNextBin(bin, null);
        bin.log(envImpl.getLogManager(), true, false, false, null);
        bin.releaseLatch();

        /*
         * Delete all of left hand side of the tree, so that the subtree root
         * headed by IN2 is compressed.
         */
 
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

    public DBIN latchDBIN()
        throws DatabaseException {

  while (dupBin != null) {
      BIN waitingOn = dupBin;
      waitingOn.latch();
      if (dupBin == waitingOn) {
    return dupBin;
      }
      waitingOn.releaseLatch();
  }
  return null;
    }
View Full Code Here

    }

    private void removeCursorBIN()
  throws DatabaseException {

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

                        latchBIN();
                    }
                    binToBeRemoved = bin;
                    bin = null;

                    BIN newBin;

                    /*
                     * SR #12736
                     * Prune away oldBin. Assert has intentional side effect
                     */
                    assert TestHookExecute.doHookIfSet(testHook);

                    if (forward) {
                        newBin = database.getTree().getNextBin
                            (binToBeRemoved, null);
                    } else {
                        newBin = database.getTree().getPrevBin
                            (binToBeRemoved, null);
                    }
                    if (newBin == null) {
                        result.status = OperationStatus.NOTFOUND;
                        break;
                    } else {
                        if (forward) {
                            index = -1;
                        } else {
                            index = newBin.getNEntries();
                        }
                        addCursor(newBin);
                        /* Ensure that setting bin is under newBin's latch */
                        bin = newBin;
                        alreadyLatched = true;
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.