Package org.neo4j.gds.core.utils
Class PageReordering
- java.lang.Object
-
- org.neo4j.gds.core.utils.PageReordering
-
public final class PageReordering extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
PageReordering.PageOrdering
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <PAGE> void
reorder(PAGE[] pages, HugeLongArray offsets, HugeIntArray degrees)
This method aligns the given pages and offsets with the node id space.
-
-
-
Method Detail
-
reorder
public static <PAGE> void reorder(PAGE[] pages, HugeLongArray offsets, HugeIntArray degrees)
This method aligns the given pages and offsets with the node id space. Pages and offsets are changed in-place in O(nodeCount) time. Reordering happens in three steps:- The offsets are scanned to detect the current page ordering and the start and end indexes of a page within the offsets.
- The pages are swapped to end up in order.
- The offsets are rewritten to contain the new page id, but the same index within the page.
Example for page size = 8 Input: pages [ r g b s ] offsets [ 16, 18, 22, 0, 3, 6, 24, 28, 30, 8, 13, 15 ] Lookup: node 0 -> offset 16 -> page id 2 -> index in page 0 -> page b node 4 -> offset 3 -> page id 0 -> index in page 3 -> page r Output: page ordering [ 2 0 3 1 ] ordered pages [ b r s g ] rewritten offsets [ 0, 2, 6, 8, 11, 14, 16, 20, 22, 24, 29, 31 ] Lookup: node 0 -> offset 0 -> page id 0 -> index in page 0 -> page b node 4 -> offset 11 -> page id 1 -> index in page 3 -> page r
-
-