public static ApproximateHistogram fromBytes ( ByteBuffer buf ) { // negative size indicates compact representation // this works regardless of whether we use int or short for the size since the leftmost bit is the sign bit if ( buf . getShort ( buf . position ( ) ) < 0 ) { return fromBytesCompact ( buf ) ; } else { // ignore size, determine if sparse or dense based on sign of binCount if ( buf . getInt ( buf . position ( ) + Integer . BYTES ) < 0 ) { return fromBytesSparse ( buf ) ; } else { return fromBytesDense ( buf ) ; } } }
Constructs an ApproximateHistogram object from the given byte - buffer representation