* Calculate BIN size including LNs/data. The recalcKeyPrefix and
* compactMemory methods are called to simulate normal operation.
* Normally prefixes are recalculated when a IN is split, and
* compactMemory is called after fetching a IN or evicting an LN.
*/
final BIN bin = DbInternal.getCursorImpl(cursor).getBIN();
bin.recalcKeyPrefix();
bin.compactMemory();
minBinSizeWithData = bin.getInMemorySize();
/* Evict all LNs. */
for (int i = 0; i < nodeAvg; i += 1) {
assert status == OperationStatus.SUCCESS;
final CursorImpl cursorImpl = DbInternal.getCursorImpl(cursor);
assert bin == cursorImpl.getBIN();
assert duplicates ?
(bin.getTarget(i) == null) :
(bin.getTarget(i) != null);
if (!duplicates) {
cursorImpl.evict();
}
status = cursor.getNext(keyEntry, dataEntry, null);
}
assert status == OperationStatus.NOTFOUND;
cursor.close();
/*
* Calculate BIN size without LNs/data. The clearLsnCompaction method
* is called to artificially remove LSN compaction savings. The amount
* saved by LSN compaction is currently the only difference between the
* min and max memory sizes.
*/
bin.compactMemory();
minBinSize = bin.getInMemorySize();
bin.clearLsnCompaction();
maxBinSize = bin.getInMemorySize();
final long lsnSavings = maxBinSize - minBinSize;
maxBinSizeWithData = minBinSizeWithData + lsnSavings;
/*
* To calculate IN size, get parent/root IN and artificially fill the
* slots with nodeAvg entries.
*/
final IN in = DbInternal.getDatabaseImpl(db).
getTree().
getRootINLatchedExclusive(CacheMode.DEFAULT);
assert bin == in.getTarget(0);
for (int i = 1; i < nodeAvg; i += 1) {
final ChildReference child =
new ChildReference(bin, bin.getKey(i), bin.getLsn(i));
final int result = in.insertEntry1(child);
assert (result & IN.INSERT_SUCCESS) != 0;
assert i == (result & ~IN.INSERT_SUCCESS);
}
in.recalcKeyPrefix();