static CompactSketch heapifyInstance ( final Memory srcMem , final long seed ) { final short memSeedHash = ( short ) extractSeedHash ( srcMem ) ; final short computedSeedHash = computeSeedHash ( seed ) ; checkSeedHashes ( memSeedHash , computedSeedHash ) ; final int preLongs = extractPreLongs ( srcMem ) ; final boolean empty = PreambleUtil . isEmpty ( srcMem ) ; int curCount = 0 ; long thetaLong = Long . MAX_VALUE ; long [ ] cache = new long [ 0 ] ; if ( preLongs == 1 ) { if ( ! empty ) { //singleItem return new SingleItemSketch ( srcMem . getLong ( 8 ) , memSeedHash ) ; } //else empty } else { //preLongs > 1 curCount = extractCurCount ( srcMem ) ; cache = new long [ curCount ] ; if ( preLongs == 2 ) { srcMem . getLongArray ( 16 , cache , 0 , curCount ) ; } else { //preLongs == 3 srcMem . getLongArray ( 24 , cache , 0 , curCount ) ; thetaLong = extractThetaLong ( srcMem ) ; } } return new HeapCompactOrderedSketch ( cache , empty , memSeedHash , curCount , thetaLong ) ; }
Heapifies the given source Memory with seed