Source:
public long sizeAsLong() { if (!transaction.isReadCommitted() && !transaction.isReadUncommitted()) { return sizeAsLongSlow(); } Snapshot<K,VersionedValue<V>> snapshot; RootReference<Long,Record<?,?>>[] undoLogRootReferences; do { snapshot = getSnapshot(); undoLogRootReferences = getTransaction().getUndoLogRootReferences(); } while (!snapshot.equals(getSnapshot())); RootReference<K,VersionedValue<V>> mapRootReference = snapshot.root; BitSet committingTransactions = snapshot.committingTransactions; long size = mapRootReference.getTotalCount(); long undoLogsTotalSize = undoLogRootReferences == null ? size : TransactionStore.calculateUndoLogsTotalSize(undoLogRootReferences); if (undoLogsTotalSize == 0) { return size; } if (transaction.isReadUncommitted()) { return size; } if (2 * undoLogsTotalSize > size) { Cursor<K, VersionedValue<V>> cursor = map.cursor(mapRootReference, null, null, false); while(cursor.hasNext()) { cursor.next(); VersionedValue<?> currentValue = cursor.getValue(); assert currentValue != null; long operationId = currentValue.getOperationId(); if (operationId != 0 && isIrrelevant(operationId, currentValue, committingTransactions)) { --size; } } } else { assert undoLogRootReferences != null; for (RootReference<Long,Record<?,?>> undoLogRootReference : undoLogRootReferences) { if (undoLogRootReference != null) { Cursor<Long, Record<?, ?>> cursor = undoLogRootReference.root.map.cursor(undoLogRootReference, null, null, false); while (cursor.hasNext()) { cursor.next(); Record<?,?> op = cursor.getValue(); if (op.mapId == map.getId()) { @SuppressWarnings("unchecked") VersionedValue<V> currentValue = map.get(mapRootReference.root, (K)op.key); if (currentValue != null) { long operationId = cursor.getKey(); assert operationId != 0; if (currentValue.getOperationId() == operationId && isIrrelevant(operationId, currentValue, committingTransactions)) { --size; } } } } } } } return size; }

Target:
public long sizeAsLong() { if (!transaction.allowNonRepeatableRead()) { return sizeAsLongSlow(); } Snapshot<K,VersionedValue<V>> snapshot; RootReference<Long,Record<?,?>>[] undoLogRootReferences; do { snapshot = getSnapshot(); undoLogRootReferences = getTransaction().getUndoLogRootReferences(); } while (!snapshot.equals(getSnapshot())); RootReference<K,VersionedValue<V>> mapRootReference = snapshot.root; BitSet committingTransactions = snapshot.committingTransactions; long size = mapRootReference.getTotalCount(); if (!transaction.isReadCommitted()) { return size; } long undoLogsTotalSize = undoLogRootReferences == null ? size : TransactionStore.calculateUndoLogsTotalSize(undoLogRootReferences); if (undoLogsTotalSize == 0) { return size; } if (2 * undoLogsTotalSize > size) { Cursor<K, VersionedValue<V>> cursor = map.cursor(mapRootReference, null, null, false); while(cursor.hasNext()) { cursor.next(); VersionedValue<?> currentValue = cursor.getValue(); assert currentValue != null; long operationId = currentValue.getOperationId(); if (operationId != 0 && isIrrelevant(operationId, currentValue, committingTransactions)) { --size; } } } else { assert undoLogRootReferences != null; for (RootReference<Long,Record<?,?>> undoLogRootReference : undoLogRootReferences) { if (undoLogRootReference != null) { Cursor<Long, Record<?, ?>> cursor = undoLogRootReference.root.map.cursor(undoLogRootReference, null, null, false); while (cursor.hasNext()) { cursor.next(); Record<?,?> op = cursor.getValue(); if (op.mapId == map.getId()) { @SuppressWarnings("unchecked") VersionedValue<V> currentValue = map.get(mapRootReference.root, (K)op.key); if (currentValue != null) { long operationId = cursor.getKey(); assert operationId != 0; if (currentValue.getOperationId() == operationId && isIrrelevant(operationId, currentValue, committingTransactions)) { --size; } } } } } } } return size; }