Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ static String preambleToString(final MemorySegment seg) {
final int seedHash = extractSeedHash(seg);

//assumes preLongs == 1; empty or singleItem
int curCount = singleItem ? 1 : 0;
int curCount = empty ? 0 : 1;
float p = (float) 1.0; //preLongs 1 or 2
long thetaLong = Long.MAX_VALUE; //preLongs 1 or 2
long thetaULong = thetaLong; //preLongs 1, 2 or 3
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ public void checkToStringWithPrelongsOf2() {
println(ThetaSketch.toString(bytes));
}

@Test
public void checkHistoricalSingleItemToString() {
final byte[] bytes = SingleItemSketch.create(1).toByteArray();
bytes[5] &= (byte) ~PreambleUtil.SINGLEITEM_FLAG_MASK;

final String summary = PreambleUtil.preambleToString(bytes);
assertTrue(summary.contains(" 5 SINGLE_ITEM : false"));
assertTrue(summary.contains("Bytes 8-11 : CurrentCount : 1"));
}

@Test
public void checkPreambleToStringExceptions() {
byte[] byteArr = new byte[7];
Expand Down
Loading