code: static void checkCompact(final int serVer, final int flags) {
      final int compactFlagMask = COMPACT_FLAG_MASK | ORDERED_FLAG_MASK;
      if ((serVer != 2)
              && ((flags & EMPTY_FLAG_MASK) == 0)
              && ((flags & compactFlagMask) != compactFlagMask)) {
        throw new SketchesArgumentException(
                "Possible corruption: Must be v2, empty, or compact and ordered. Flags field: "
                        + Integer.toBinaryString(flags) + ", SerVer: " + serVer);
      }
    }
docs: Checks a sketch's serial version and flags to see if the sketch can be wrapped as a
  DirectCompactDoubleSketch. Throws an exception if the sketch is neither empty nor compact
  and ordered, unles the sketch uses serialization version 2.
  @param serVer the serialization version
  @param flags Flags from the sketch to evaluate