static ArrayOfDoublesUnion heapifyUnion ( final Memory mem , final long seed ) { final SerializerDeserializer . SketchType type = SerializerDeserializer . getSketchType ( mem ) ; // compatibility with version 0.9.1 and lower if ( type == SerializerDeserializer . SketchType . ArrayOfDoublesQuickSelectSketch ) { final ArrayOfDoublesQuickSelectSketch sketch = new HeapArrayOfDoublesQuickSelectSketch ( mem , seed ) ; return new HeapArrayOfDoublesUnion ( sketch ) ; } final byte version = mem . getByte ( SERIAL_VERSION_BYTE ) ; if ( version != serialVersionUID ) { throw new SketchesArgumentException ( "Serial version mismatch. Expected: " + serialVersionUID + ", actual: " + version ) ; } SerializerDeserializer . validateFamily ( mem . getByte ( FAMILY_ID_BYTE ) , mem . getByte ( PREAMBLE_LONGS_BYTE ) ) ; SerializerDeserializer . validateType ( mem . getByte ( SKETCH_TYPE_BYTE ) , SerializerDeserializer . SketchType . ArrayOfDoublesUnion ) ; final long unionTheta = mem . getLong ( THETA_LONG ) ; final Memory sketchMem = mem . region ( PREAMBLE_SIZE_BYTES , mem . getCapacity ( ) - PREAMBLE_SIZE_BYTES ) ; final ArrayOfDoublesQuickSelectSketch sketch = new HeapArrayOfDoublesQuickSelectSketch ( sketchMem , seed ) ; final ArrayOfDoublesUnion union = new HeapArrayOfDoublesUnion ( sketch ) ; union . theta_ = unionTheta ; return union ; }
This is to create an instance given a serialized form and a custom seed