Source:
public long sizeAsLong() { TransactionStore store = transaction.store; MVMap<Long, Object[]> undo = transaction.store.undoLog; BitSet committingTransactions; MVMap.RootReference mapRootReference; MVMap.RootReference undoLogRootReference; do { committingTransactions = store.committingTransactions.get(); mapRootReference = map.getRoot(); undoLogRootReference = store.undoLog.getRoot(); } while(committingTransactions != store.committingTransactions.get() || mapRootReference != map.getRoot()); Page undoRootPage = undoLogRootReference.root; long undoLogSize = undoRootPage.getTotalCount(); Page mapRootPage = mapRootReference.root; long size = mapRootPage.getTotalCount(); if (undoLogSize == 0) { return size; } if (undoLogSize > size) { size = 0; Cursor<K, VersionedValue> cursor = map.cursor(null); while (cursor.hasNext()) { K key = cursor.next(); VersionedValue data = cursor.getValue(); data = getValue(mapRootPage, undoRootPage, key, readLogId, data, committingTransactions); if (data != null && data.value != null) { size++; } } return size; } MVMap<Object, Integer> temp = transaction.store .createTempMap(); try { Cursor cursor = new Cursor<Long, Object[]>(undoRootPage, null); while (cursor.hasNext()) { cursor.next(); Object[] op = (Object[]) cursor.getValue(); int m = (Integer) op[0]; if (m != mapId) { continue; } @SuppressWarnings("unchecked") K key = (K) op[1]; VersionedValue data = map.get(mapRootPage, key); data = getValue(mapRootPage, undoRootPage, key, readLogId, data, committingTransactions); if (data == null || data.value == null) { Integer old = temp.put(key, 1); if (old == null) { size--; } } } } finally { transaction.store.store.removeMap(temp); } return size; }

Target:
public long sizeAsLong() { TransactionStore store = transaction.store; BitSet committingTransactions; MVMap.RootReference mapRootReference; MVMap.RootReference undoLogRootReference; do { committingTransactions = store.committingTransactions.get(); mapRootReference = map.getRoot(); undoLogRootReference = store.undoLog.getRoot(); } while(committingTransactions != store.committingTransactions.get() || mapRootReference != map.getRoot()); Page undoRootPage = undoLogRootReference.root; long undoLogSize = undoRootPage.getTotalCount(); Page mapRootPage = mapRootReference.root; long size = mapRootPage.getTotalCount(); if (undoLogSize == 0) { return size; } if (undoLogSize > size) { size = 0; Cursor<K, VersionedValue> cursor = map.cursor(null); while (cursor.hasNext()) { K key = cursor.next(); VersionedValue data = cursor.getValue(); data = getValue(mapRootPage, undoRootPage, key, readLogId, data, committingTransactions); if (data != null && data.value != null) { size++; } } return size; } MVMap<Object, Integer> temp = store.createTempMap(); try { Cursor<Long, Object[]> cursor = new Cursor<>(undoRootPage, null); while (cursor.hasNext()) { cursor.next(); Object[] op = cursor.getValue(); int m = (int) op[0]; if (m != mapId) { continue; } @SuppressWarnings("unchecked") K key = (K) op[1]; VersionedValue data = map.get(mapRootPage, key); data = getValue(mapRootPage, undoRootPage, key, readLogId, data, committingTransactions); if (data == null || data.value == null) { Integer old = temp.put(key, 1); if (old == null) { size--; } } } } finally { transaction.store.store.removeMap(temp); } return size; }