public static String preambleToString()

in src/main/java/org/apache/datasketches/vector/decomposition/PreambleUtil.java [94:142]


  public static String preambleToString(final Memory mem) {

    final int preLongs = getAndCheckPreLongs(mem);  // make sure we can get the assumed preamble
    final MatrixFamily family = MatrixFamily.idToFamily(extractFamilyID(mem));

    final int serVer = extractSerVer(mem);
    final int flags = extractFlags(mem);
    final String flagsStr = Integer.toBinaryString(flags) + ", " + flags;
    final boolean isEmpty = (flags & EMPTY_FLAG_MASK) > 0;

    final int k = extractK(mem);
    final int d = extractNumColumns(mem);
    final int numRows = extractNumRows(mem);

    long n = 0;
    double svAdjustment = 0.0;
    if (!isEmpty) {
      n = extractN(mem);
      svAdjustment = extractSVAdjustment(mem);
    }

    final StringBuilder sb = new StringBuilder();
    sb.append(LS)
            .append("### START ")
            .append(family.getFamilyName().toUpperCase())
            .append(" PREAMBLE SUMMARY").append(LS)
            .append("Byte  0: Preamble Longs       : ").append(preLongs).append(LS)
            .append("Byte  1: Serialization Version: ").append(serVer).append(LS)
            .append("Byte  2: Family               : ").append(family.toString()).append(LS)
            .append("Byte  3: Flags Field          : ").append(flagsStr).append(LS)
            .append("  EMPTY                       : ").append(isEmpty).append(LS)
            .append("Bytes  4-7 : Sketch Size (k)  : ").append(k).append(LS)
            .append("Bytes  8-11: Num Rows         : ").append(numRows).append(LS)
            .append("Bytes 12-15: Num Dimensions   : ").append(d).append(LS);

    if (!isEmpty) {
      sb.append("Bytes 16-23: Items Seen(n)    : ").append(n).append(LS);
      sb.append("Bytes 24-31: SV Adjustment    : ").append(svAdjustment).append(LS);
    }

    final long numBytes = (long)numRows * d * Double.BYTES;
    sb.append("TOTAL Sketch Bytes            : ").append(mem.getCapacity()).append(LS)
            .append("  Preamble Bytes              : ").append(preLongs << 3).append(LS)
            .append("  Data Bytes                  : ").append(numBytes).append(LS)
            .append("### END ")
            .append(family.getFamilyName().toUpperCase())
            .append(" PREAMBLE SUMMARY").append(LS);
    return sb.toString();
  }