in src/main/java/org/apache/datasketches/hll/PreambleUtil.java [159:251]
static String toString(final Memory mem) {
//First 8 bytes
final int preInts = mem.getByte(PREAMBLE_INTS_BYTE);
final int serVer = mem.getByte(SER_VER_BYTE);
final Family family = Family.idToFamily(mem.getByte(FAMILY_BYTE));
final int lgK = mem.getByte(LG_K_BYTE);
final int lgArr = mem.getByte(LG_ARR_BYTE);
final int flags = mem.getByte(FLAGS_BYTE);
//Flags
final String flagsStr = zeroPad(Integer.toBinaryString(flags), 8) + ", " + (flags);
final boolean bigEndian = (flags & BIG_ENDIAN_FLAG_MASK) > 0;
final String nativeOrder = ByteOrder.nativeOrder().toString();
final boolean compact = (flags & COMPACT_FLAG_MASK) > 0;
final boolean oooFlag = (flags & OUT_OF_ORDER_FLAG_MASK) > 0;
final boolean readOnly = (flags & READ_ONLY_FLAG_MASK) > 0;
final boolean empty = (flags & EMPTY_FLAG_MASK) > 0;
final boolean rebuildKxQ = (flags & REBUILD_CURMIN_NUM_KXQ_MASK) > 0;
final int hllCurMin = mem.getByte(HLL_CUR_MIN_BYTE);
final int listCount = hllCurMin;
final int modeByte = mem.getByte(MODE_BYTE);
final CurMode curMode = CurMode.fromOrdinal(modeByte & 3);
final TgtHllType tgtHllType = TgtHllType.fromOrdinal((modeByte >>> 2) & 3);
double hipAccum = 0;
double kxq0 = 0;
double kxq1 = 0;
int hashSetCount = 0;
int curMinCount = 0;
int exceptionCount = 0;
if (curMode == CurMode.SET) {
hashSetCount = mem.getInt(HASH_SET_COUNT_INT);
}
else if (curMode == CurMode.HLL) {
hipAccum = mem.getDouble(HIP_ACCUM_DOUBLE);
kxq0 = mem.getDouble(KXQ0_DOUBLE);
kxq1 = mem.getDouble(KXQ1_DOUBLE);
curMinCount = mem.getInt(CUR_MIN_COUNT_INT);
exceptionCount = mem.getInt(AUX_COUNT_INT);
}
final StringBuilder sb = new StringBuilder();
sb.append(LS);
sb.append("### HLL SKETCH PREAMBLE:").append(LS);
sb.append("Byte 0: Preamble Ints : ").append(preInts).append(LS);
sb.append("Byte 1: SerVer : ").append(serVer).append(LS);
sb.append("Byte 2: Family : ").append(family).append(LS);
sb.append("Byte 3: lgK : ").append(lgK).append(LS);
//expand byte 4: LgArr
if (curMode == CurMode.LIST) {
sb.append("Byte 4: LgArr: List Arr : ").append(lgArr).append(LS);
}
if (curMode == CurMode.SET) {
sb.append("Byte 4: LgArr: Hash Set Arr : ").append(lgArr).append(LS);
}
if (curMode == CurMode.HLL) {
sb.append("Byte 4: LgArr or Aux LgArr : ").append(lgArr).append(LS);
}
//expand byte 5: Flags
sb.append("Byte 5: Flags: : ").append(flagsStr).append(LS);
sb.append(" BIG_ENDIAN_STORAGE : ").append(bigEndian).append(LS);
sb.append(" (Native Byte Order) : ").append(nativeOrder).append(LS);
sb.append(" READ_ONLY : ").append(readOnly).append(LS);
sb.append(" EMPTY : ").append(empty).append(LS);
sb.append(" COMPACT : ").append(compact).append(LS);
sb.append(" OUT_OF_ORDER : ").append(oooFlag).append(LS);
sb.append(" REBUILD_KXQ : ").append(rebuildKxQ).append(LS);
//expand byte 6: ListCount, CurMin
if (curMode == CurMode.LIST) {
sb.append("Byte 6: List Count/CurMin : ").append(listCount).append(LS);
}
if (curMode == CurMode.SET) {
sb.append("Byte 6: (not used) : ").append(LS);
}
if (curMode == CurMode.HLL) {
sb.append("Byte 6: Cur Min : ").append(hllCurMin).append(LS);
}
final String modes = curMode.toString() + ", " + tgtHllType.toString();
sb.append("Byte 7: Mode : ").append(modes).append(LS);
if (curMode == CurMode.SET) {
sb.append("Hash Set Count : ").append(hashSetCount).append(LS);
}
if (curMode == CurMode.HLL) {
sb.append("HIP Accum : ").append(hipAccum).append(LS);
sb.append("KxQ0 : ").append(kxq0).append(LS);
sb.append("KxQ1 : ").append(kxq1).append(LS);
sb.append("Num At Cur Min : ").append(curMinCount).append(LS);
sb.append("Aux Count : ").append(exceptionCount).append(LS);
}
sb.append("### END HLL SKETCH PREAMBLE").append(LS);
return sb.toString();
}