/** * Changes all keys to "prefix keys" in the given IN. Called after reading an IN from disk via * IN.postFetchInit. * * <p>The conversion of IN keys is invoked from the IN class when an IN is fetched, rather than * invoked from the DupConvert class directly, for performance and simplicity. If it were invoked * from the DupConvert class, we would have to iterate over all INs in a separate initial pass. * This is both more time consuming, and more complex to implement properly so that eviction is * possible. Instead, conversion occurs when an old format IN is loaded. * * <p>Enter/leave with 'in' unlatched. */ public static void convertInKeys(final DatabaseImpl dbImpl, final IN in) { /* Nothing to convert for non-duplicates DB. */ if (!dbImpl.getSortedDuplicates()) { return; } /* DIN/DBIN do not need conversion either. */ if (in instanceof DIN || in instanceof DBIN) { return; } in.latch(); try { for (int i = 0; i < in.getNEntries(); i += 1) { byte[] oldKey = in.getKey(i); byte[] newKey = DupKeyData.makePrefixKey(oldKey, 0, oldKey.length); in.updateEntry(i, in.getTarget(i), in.getLsn(i), newKey); } byte[] oldKey = in.getIdentifierKey(); byte[] newKey = DupKeyData.makePrefixKey(oldKey, 0, oldKey.length); in.setIdentifierKey(newKey); assert in.verifyMemorySize(); } finally { in.releaseLatch(); } }