Skip to content

Commit 861462f

Browse files
Merge pull request #649 from apache/compressed_iterator
test toByteArray()
2 parents 41d7183 + 8b13d16 commit 861462f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/test/java/org/apache/datasketches/theta/CompactSketchTest.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -589,36 +589,38 @@ public void serializeDeserializeDirectV4() {
589589

590590
@Test
591591
public void serializeWrapBytesV3() {
592-
UpdateSketch sk = Sketches.updateSketchBuilder().build();
592+
final UpdateSketch sk = Sketches.updateSketchBuilder().build();
593593
for (int i = 0; i < 10000; i++) {
594594
sk.update(i);
595595
}
596-
CompactSketch cs1 = sk.compact();
597-
byte[] bytes = cs1.toByteArray();
598-
CompactSketch cs2 = new WrappedCompactSketch(bytes);
596+
final CompactSketch cs1 = sk.compact();
597+
final byte[] bytes = cs1.toByteArray();
598+
final CompactSketch cs2 = new WrappedCompactSketch(bytes);
599599
assertEquals(cs1.getRetainedEntries(), cs2.getRetainedEntries());
600-
HashIterator it1 = cs1.iterator();
601-
HashIterator it2 = cs2.iterator();
600+
final HashIterator it1 = cs1.iterator();
601+
final HashIterator it2 = cs2.iterator();
602602
while (it1.next() && it2.next()) {
603603
assertEquals(it2.get(), it2.get());
604604
}
605+
assertEquals(bytes, cs2.toByteArray());
605606
}
606607

607608
@Test
608609
public void serializeWrapBytesV4() {
609-
UpdateSketch sk = Sketches.updateSketchBuilder().build();
610+
final UpdateSketch sk = Sketches.updateSketchBuilder().build();
610611
for (int i = 0; i < 10000; i++) {
611612
sk.update(i);
612613
}
613-
CompactSketch cs1 = sk.compact();
614-
byte[] bytes = cs1.toByteArrayCompressed();
615-
CompactSketch cs2 = new WrappedCompactCompressedSketch(bytes);
614+
final CompactSketch cs1 = sk.compact();
615+
final byte[] bytes = cs1.toByteArrayCompressed();
616+
final CompactSketch cs2 = new WrappedCompactCompressedSketch(bytes);
616617
assertEquals(cs1.getRetainedEntries(), cs2.getRetainedEntries());
617-
HashIterator it1 = cs1.iterator();
618-
HashIterator it2 = cs2.iterator();
618+
final HashIterator it1 = cs1.iterator();
619+
final HashIterator it2 = cs2.iterator();
619620
while (it1.next() && it2.next()) {
620621
assertEquals(it2.get(), it2.get());
621622
}
623+
assertEquals(bytes, cs2.toByteArray());
622624
}
623625

624626
private static class State {

0 commit comments

Comments
 (0)