code: static CompactSketch compact(final UpdateSketch sketch) {
      final int curCount = sketch.getRetainedEntries(true);
      long thetaLong = sketch.getThetaLong();
      boolean empty = sketch.isEmpty();
      thetaLong = thetaOnCompact(empty, curCount, thetaLong);
      empty = emptyOnCompact(curCount, thetaLong);
      final short seedHash = sketch.getSeedHash();
      final long[] cache = sketch.getCache();
      final boolean ordered = true;
      final long[] cacheOut = CompactSketch.compactCache(cache, curCount, thetaLong, ordered);
      if ((curCount == 1) && (thetaLong == Long.MAX_VALUE)) {
        return new SingleItemSketch(cacheOut[0], seedHash);
      }
      return new HeapCompactOrderedSketch(cacheOut, empty, seedHash, curCount, thetaLong);
    }
docs: Converts the given UpdateSketch to this compact form.
  @param sketch the given UpdateSketch
  @return a CompactSketch