Skip to content

Commit a860e42

Browse files
author
lrhodes
committed
Properly disabled optional KllValidationTest
1 parent 838f809 commit a860e42

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/main/java/com/yahoo/sketches/kll/KllHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ static void randomlyHalveUp(final float[] buf, final int start, final int length
280280
}
281281
}
282282

283-
// for validation in KllValidationTest
283+
// Enable the following to use KllValidationTest
284284

285-
static int nextOffset = 0;
285+
// static int nextOffset = 0;
286286

287287
// private static int deterministicOffset() {
288288
// final int result = nextOffset;

src/test/java/com/yahoo/sketches/kll/KllValidationTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.yahoo.sketches.kll;
22

33
import org.testng.Assert;
4-
import org.testng.annotations.Test;
54

65
/* A test record contains:
76
0. testIndex
@@ -13,8 +12,9 @@
1312
6. hash of the retained samples
1413
*/
1514

16-
/* These results are for the version that delays the rollup until the next value comes in. */
17-
15+
// These results are for the version that delays the rollup until the next value comes in.
16+
// The @Test annotations have to be enabled to use this class and a section in KllHelper also
17+
// needs to be enabled.
1818
public class KllValidationTest {
1919

2020
private static final long[] correctResultsWithReset = {
@@ -151,7 +151,7 @@ private static long simpleHashOfSubArray(final float[] arr, final int start, fin
151151
final long multiplier = 738219921; // an arbitrary odd 30-bit number
152152
final long mask60 = (1L << 60) - 1;
153153
long accum = 0;
154-
for (int i = start; i < start + subLength; i++) {
154+
for (int i = start; i < (start + subLength); i++) {
155155
accum += (long) arr[i];
156156
accum *= multiplier;
157157
accum &= mask60;
@@ -160,13 +160,13 @@ private static long simpleHashOfSubArray(final float[] arr, final int start, fin
160160
return accum;
161161
}
162162

163-
@Test
163+
//@Test //need to enable
164164
public void testHash() {
165165
float[] array = { 907500, 944104, 807020, 219921, 678370, 955217, 426885 };
166166
Assert.assertEquals(simpleHashOfSubArray(array, 1, 5), 1141543353991880193L);
167167
}
168168

169-
@Test
169+
//@Test //need to enable
170170
public void testMakeInputArray() {
171171
final int[] array = { 3654721, 7309442, 2575555, 6230276, 1496389, 5151110 };
172172
Assert.assertEquals(makeInputArray(6, 3654721), array);
@@ -181,11 +181,11 @@ public void testMakeInputArray() {
181181
public void checkTestResults() {
182182
int numTests = correctResultsWithReset.length / 7;
183183
for (int testI = 0; testI < numTests; testI++) {
184-
KllHelper.nextOffset = 0;
184+
//KllHelper.nextOffset = 0; //need to enable
185185
assert (int) correctResultsWithReset[7 * testI] == testI;
186-
int k = (int) correctResultsWithReset[7 * testI + 1];
187-
int n = (int) correctResultsWithReset[7 * testI + 2];
188-
int stride = (int) correctResultsWithReset[7 * testI + 3];
186+
int k = (int) correctResultsWithReset[(7 * testI) + 1];
187+
int n = (int) correctResultsWithReset[(7 * testI) + 2];
188+
int stride = (int) correctResultsWithReset[(7 * testI) + 3];
189189
int[] inputArray = makeInputArray(n, stride);
190190
KllFloatsSketch sketch = new KllFloatsSketch(k);
191191
for (int i = 0; i < n; i++) {
@@ -196,13 +196,13 @@ public void checkTestResults() {
196196
int[] levels = sketch.getLevels();
197197
long hashedSamples = simpleHashOfSubArray(sketch.getItems(), levels[0], numSamples);
198198
System.out.print(testI);
199-
assert correctResultsWithReset[7 * testI + 4] == numLevels;
200-
assert correctResultsWithReset[7 * testI + 5] == numSamples;
199+
assert correctResultsWithReset[(7 * testI) + 4] == numLevels;
200+
assert correctResultsWithReset[(7 * testI) + 5] == numSamples;
201201
//assert correctResults[7 * testI + 6] == hashedSamples;
202-
if (correctResultsWithReset[7 * testI + 6] == hashedSamples) {
202+
if (correctResultsWithReset[(7 * testI) + 6] == hashedSamples) {
203203
System.out.println(" pass");
204204
} else {
205-
System.out.print(" " + correctResultsWithReset[7 * testI + 6] + " != " + hashedSamples);
205+
System.out.print(" " + correctResultsWithReset[(7 * testI) + 6] + " != " + hashedSamples);
206206
System.out.println(" fail");
207207
System.out.println(sketch.toString(true, true));
208208
break;

0 commit comments

Comments
 (0)