Class PageReordering


  • public final class PageReordering
    extends java.lang.Object
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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:
        1. The offsets are scanned to detect the current page ordering and the start and end indexes of a page within the offsets.
        2. The pages are swapped to end up in order.
        3. The offsets are rewritten to contain the new page id, but the same index within the page.
        Note that only offsets for nodes with degree > 0 are being rewritten. Nodes with degree = 0 will have offset = 0.
         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