Skip to content

Commit b5639e8

Browse files
committed
Slight correction in test loop.
1 parent 2139854 commit b5639e8

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/test/java/org/apache/datasketches/sampling/ReservoirItemsSketchTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,6 @@ public void checkForceIncrement() {
530530
@Test
531531
public void checkEstimateSubsetSum() {
532532
final int k = 10;
533-
SampleSubsetSummary ss = null;
534-
double itemCount = 0.0;
535533

536534
//trial loop for probabilistic testing
537535
int passLB = 0;
@@ -540,12 +538,12 @@ public void checkEstimateSubsetSum() {
540538
final ReservoirItemsSketch<Long> sketch = ReservoirItemsSketch.newInstance(k);
541539

542540
// empty sketch -- all zeros
543-
ss = sketch.estimateSubsetSum(item -> true);
541+
SampleSubsetSummary ss = sketch.estimateSubsetSum(item -> true);
544542
assertEquals(ss.getEstimate(), 0.0);
545543
assertEquals(ss.getTotalSketchWeight(), 0.0);
546544

547545
// add items, keeping in exact mode
548-
itemCount = 0.0;
546+
double itemCount = 0.0;
549547
for (long i = 1; i <= (k - 1); ++i) {
550548
sketch.update(i);
551549
itemCount += 1.0;
@@ -591,10 +589,9 @@ public void checkEstimateSubsetSum() {
591589
// allow pretty generous bounds when testing
592590
if(ss.getLowerBound() < (itemCount / 1.4)) { passLB++; }
593591
if(ss.getUpperBound() > (itemCount / 2.6)) { passUB++; }
592+
assertEquals(ss.getTotalSketchWeight(), itemCount);
594593
} //End trial loop
595594
assertTrue(passLB >= 2 && passUB >= 2); //2 out of 3 must pass for LB and UB
596-
597-
assertEquals(ss.getTotalSketchWeight(), itemCount);
598595
}
599596

600597
private static MemorySegment getBasicSerializedLongsRIS() {

0 commit comments

Comments
 (0)