/** * Converts the bin/index slot, whether a singleton LN or a DIN root. * * <p>Enter/leave with bin field latched, although bin field may change. * * <p>When a singleton LN is converted, leaves with bin/index fields unchanged. * * <p>When a dup tree is converted, leaves with bin/index fields set to last inserted slot. This * is the slot of the highest key in the dup tree. */ private void convertBinSlot() { if (DEBUG) { System.out.println( "DupConvert BIN LSN " + DbLsn.getNoFormatString(bin.getLsn(index)) + " index " + index + " nEntries " + bin.getNEntries()); } /* Delete slot if LN is deleted. */ final boolean isDeleted; if (isLNDeleted(bin, index)) { deleteSlot(); return; } final Node node = bin.fetchLNOrDIN(index, CacheMode.DEFAULT); if (!node.containsDuplicates()) { if (DEBUG) { System.out.println("DupConvert BIN LN " + Key.dumpString(bin.getKey(index), 0)); } /* Fetching a non-deleted LN updates the slot key; we're done. */ assert node instanceof LN; nConverted += 1; return; } /* * Delete the slot containing the DIN before re-inserting the dup tree, * so that the DIN slot key doesn't interfere with insertions. * * The DIN is evicted and memory usage is decremented. This is not * exactly correct because we keep a local reference to the DIN until * the dup tree is converted, but we tolerate this temporary * inaccuracy. */ final byte[] binKey = bin.getKey(index); final DIN din = (DIN) node; deleteSlot(); convertDin(din, binKey); }