in src/main/java/org/apache/datasketches/memory/internal/ResourceImpl.java [256:297]
static final String toHex(final ResourceImpl resourceImpl, final String comment, final long offsetBytes,
final int lengthBytes, final boolean withData) {
final MemorySegment seg = resourceImpl.seg;
final long capacity = seg.byteSize();
checkBounds(offsetBytes, lengthBytes, capacity);
final StringBuilder sb = new StringBuilder();
final String theComment = (comment != null) ? comment : "";
final String addHCStr = Integer.toHexString(Long.hashCode(seg.address()));
final MemoryRequestServer memReqSvr = resourceImpl.getMemoryRequestServer();
final String memReqStr = memReqSvr != null
? memReqSvr.getClass().getSimpleName() + ", " + Integer.toHexString(memReqSvr.hashCode())
: "null";
sb.append(LS + "### DataSketches Memory Component SUMMARY ###").append(LS);
sb.append("Optional Comment : ").append(theComment).append(LS);
sb.append("TypeId String : ").append(typeDecode(resourceImpl.typeId)).append(LS);
sb.append("OffsetBytes : ").append(offsetBytes).append(LS);
sb.append("LengthBytes : ").append(lengthBytes).append(LS);
sb.append("Capacity : ").append(capacity).append(LS);
sb.append("MemoryAddress hashCode : ").append(addHCStr).append(LS);
sb.append("MemReqSvr, hashCode : ").append(memReqStr).append(LS);
sb.append("Read Only : ").append(resourceImpl.isReadOnly()).append(LS);
sb.append("Type Byte Order : ").append(resourceImpl.getTypeByteOrder().toString()).append(LS);
sb.append("Native Byte Order : ").append(ByteOrder.nativeOrder().toString()).append(LS);
sb.append("JDK Runtime Version : ").append(JDK).append(LS);
//Data detail
if (withData) {
sb.append("Data, LittleEndian : 0 1 2 3 4 5 6 7");
for (long i = 0; i < lengthBytes; i++) {
final int b = seg.get(ValueLayout.JAVA_BYTE, offsetBytes + i) & 0XFF;
if (i % 8 == 0) { //row header
sb.append(String.format("%n%23s: ", offsetBytes + i));
}
sb.append(String.format("%02x ", b));
}
}
sb.append(LS + "### END SUMMARY ###");
sb.append(LS);
return sb.toString();
}