/** * Converts the given DBIN slot, leaving bin/index set to the inserted BIN slot. * * <p>Enter/leave with bin field latched, although bin field may change. * * <p>If slot is inserted into current bin, leave bin field unchanged and set index field to * inserted slot. * * <p>If slot is inserted into a different bin, set bin/index fields to inserted slot. */ private void convertDbinSlot(final DBIN dbin, final int dbinIndex, final byte[] binKey) { final byte[] newKey = DupKeyData.replaceData(binKey, dbin.getKey(dbinIndex)); if (DEBUG) { System.out.println("DupConvert DBIN LN " + Key.dumpString(newKey, 0)); } /* * If the current BIN can hold the new slot, don't bother to do a * search to find it. */ if (bin.needsSplitting() || !bin.isKeyInBounds(newKey)) { /* Compact keys after finishing with a BIN. */ bin.compactMemory(); /* Evict without latches, before moving to a new BIN. */ bin.releaseLatch(); envImpl.daemonEviction(false /*backgroundIO*/); /* Find a BIN for insertion, split if necessary. */ bin = dbin.getDatabase().getTree().searchSplitsAllowed(newKey, CacheMode.UNCHANGED); } final int newIndex = bin.insertEntry1( null /*ln*/, newKey, null /*data*/, dbin.getLsn(dbinIndex), dbin.getState(dbinIndex), false); if ((newIndex & IN.INSERT_SUCCESS) == 0) { throw EnvironmentFailureException.unexpectedState( "Key not inserted: " + Key.dumpString(newKey, 0) + " DB: " + dbin.getDatabase().getId()); } index = newIndex & ~IN.INSERT_SUCCESS; /* * Evict LN from DBIN slot. Although we don't explicitly load DBIN LNs, * it may have been loaded by recovery. */ dbin.detachNode(dbinIndex, false /*updateLsn*/, -1 /*lsn*/); nConverted += 1; }