### Question:
TransientAdjacencyList implements AdjacencyList { public static MemoryEstimation uncompressedMemoryEstimation(boolean undirected) { return uncompressedMemoryEstimation(ALL_RELATIONSHIPS, undirected); } TransientAdjacencyList(byte[][] pages); static MemoryEstimation compressedMemoryEstimation(long avgDegree, long nodeCount); static MemoryEstimation compressedMemoryEstimation(boolean undirected); static MemoryEstimation compressedMemoryEstimation(RelationshipType relationshipType, boolean undirected); static MemoryEstimation uncompressedMemoryEstimation(boolean undirected); static MemoryEstimation uncompressedMemoryEstimation(RelationshipType relationshipType, boolean undirected); @Override int degree(long index); @Override void close(); @Override Cursor cursor(long offset); @Override DecompressingCursor rawDecompressingCursor(); @Override DecompressingCursor decompressingCursor(long offset); static final int PAGE_SHIFT; static final int PAGE_SIZE; static final long PAGE_MASK; }### Answer:
@Test void shouldComputeUncompressedMemoryEstimationForSinglePage() { GraphDimensions dimensions = ImmutableGraphDimensions.builder() .nodeCount(100) .maxRelCount(100) .build(); MemoryTree memRec = TransientAdjacencyList.uncompressedMemoryEstimation(false).estimate(dimensions, 1); long classSize = 24; long uncompressedAdjacencySize = 1200; int pages = PageUtil.numPagesFor(uncompressedAdjacencySize, PAGE_SHIFT, PAGE_MASK); long bytesPerPage = BitUtil.align(16 + 262144L, 8); long memoryReqs = pages * bytesPerPage + BitUtil.align(16 + pages * 4, 8); MemoryRange expected = MemoryRange.of(memoryReqs + classSize); assertEquals(expected, memRec.memoryUsage()); }
@Test void shouldComputeUncompressedMemoryEstimationForMultiplePage() { GraphDimensions dimensions = ImmutableGraphDimensions.builder() .nodeCount(100_000_000L) .maxRelCount(100_000_000_000L) .build(); MemoryTree memRec = TransientAdjacencyList.uncompressedMemoryEstimation(false).estimate(dimensions, 1); long classSize = 24; long uncompessedAdjacencySize = 800_400_000_000L; int pages = PageUtil.numPagesFor(uncompessedAdjacencySize, PAGE_SHIFT, PAGE_MASK); long bytesPerPage = BitUtil.align(16 + 262144L, 8); long memoryReqs = pages * bytesPerPage + BitUtil.align(16 + pages * 4, 8); MemoryRange expected = MemoryRange.of(memoryReqs + classSize); assertEquals(expected, memRec.memoryUsage()); }