public static HyperLogLog deserializeHLL(InputStream in) throws IOException {
    checkMagicString(in);
    int fourthByte = in.read() & 0xff;
    int p = fourthByte >>> 4;

    // read type of encoding
    int enc = fourthByte & 7;
    EncodingType encoding = null;
    int bitSize = 0;
    if (enc == 0) {
      encoding = EncodingType.SPARSE;
    } else if (enc > 0 && enc < 7) {
      bitSize = enc;
      encoding = EncodingType.DENSE;
    } else {
      // bit packing disabled
      bitSize = 8;
      encoding = EncodingType.DENSE;
    }

    // estimated count
    long estCount = readVulong(in);

    HyperLogLog result = null;
    if (encoding.equals(EncodingType.SPARSE)) {
      result = HyperLogLog.builder().setNumRegisterIndexBits(p)
          .setEncoding(EncodingType.SPARSE).build();
      int numRegisterEntries = (int) readVulong(in);
      int[] reg = new int[numRegisterEntries];
      int prev = 0;

      // reconstruct the sparse map from delta encoded and varint input stream
      if (numRegisterEntries > 0) {
        prev = (int) readVulong(in);
        reg[0] = prev;
      }
      int delta = 0;
      int curr = 0;
      for (int i = 1; i < numRegisterEntries; i++) {
        delta = (int) readVulong(in);
        curr = prev + delta;
        reg[i] = curr;
        prev = curr;
      }
      result.setHLLSparseRegister(reg);
    } else {

      // explicitly disable bit packing
      if (bitSize == 8) {
        result = HyperLogLog.builder().setNumRegisterIndexBits(p)
            .setEncoding(EncodingType.DENSE).enableBitPacking(false).build();
      } else {
        result = HyperLogLog.builder().setNumRegisterIndexBits(p)
            .setEncoding(EncodingType.DENSE).enableBitPacking(true).build();
      }
      int m = 1 << p;
      byte[] register = unpackHLLRegister(in, m, bitSize);
      result.setHLLDenseRegister(register);
    }

    result.setCount(estCount);

    return result;
  }
Refer serializeHLL() for format of serialization. This function
deserializes the serialized hyperloglogs
@param in
         - input stream
@return deserialized hyperloglog
@throws IOException
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/common/ndv/hll/HyperLogLogUtils.java