Skip to content

Commit c6ed8d5

Browse files
authored
Merge pull request #145 from DataSketches/reservoir_reset_test
Reservoir reset test
2 parents 6254e77 + e2414e4 commit c6ed8d5

11 files changed

Lines changed: 95 additions & 20 deletions

File tree

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ jarsIn/
2626
*.jar
2727
build.xml
2828
.idea
29-
*.iml
3029
*.properties
3130
*.releaseBackup
3231
*.next
3332
*.tag
3433

34+
# IntelliJ project files
35+
*.iml
36+
*.ipr
37+
*.iws
38+
3539
# Jekyll
3640
Gemfile
3741
Gemfile.lock

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@
450450
<plugin>
451451
<groupId>com.versioneye</groupId>
452452
<artifactId>versioneye-maven-plugin</artifactId>
453-
<version>3.11.1</version>
453+
<version>3.11.2</version>
454454
</plugin>
455455

456456
</plugins>

sketches/src/main/java/com/yahoo/sketches/quantiles/CompactDoublesSketch.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright 2017, Yahoo! Inc.
3+
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
4+
*/
5+
16
package com.yahoo.sketches.quantiles;
27

38
import com.yahoo.memory.Memory;

sketches/src/main/java/com/yahoo/sketches/quantiles/DoublesArrayAccessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright 2017, Yahoo! Inc.
3+
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
4+
*/
5+
16
package com.yahoo.sketches.quantiles;
27

38
import java.util.Arrays;

sketches/src/main/java/com/yahoo/sketches/quantiles/DoublesBufferAccessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright 2017, Yahoo! Inc.
3+
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
4+
*/
5+
16
package com.yahoo.sketches.quantiles;
27

38
/**

sketches/src/main/java/com/yahoo/sketches/quantiles/DoublesSketchAccessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright 2017, Yahoo! Inc.
3+
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
4+
*/
5+
16
package com.yahoo.sketches.quantiles;
27

38
import static com.yahoo.sketches.quantiles.PreambleUtil.COMBINED_BUFFER;

sketches/src/main/java/com/yahoo/sketches/quantiles/UpdateDoublesSketch.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright 2017, Yahoo! Inc.
3+
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
4+
*/
5+
16
package com.yahoo.sketches.quantiles;
27

38
import com.yahoo.memory.Memory;

sketches/src/main/java/com/yahoo/sketches/sampling/VarOptItemsSamples.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*
3030
* @author Jon Malkin
3131
*/
32-
public class VarOptItemsSamples<T> implements Iterable<VarOptItemsSamples<T>.WeightedSample> {
32+
class VarOptItemsSamples<T> implements Iterable<VarOptItemsSamples<T>.WeightedSample> {
3333

3434
private final VarOptItemsSketch<T> sketch_;
3535
private VarOptItemsSketch<T>.Result sampleLists;

sketches/src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* @author Jon Malkin
4848
* @author Kevin Lang
4949
*/
50-
public final class VarOptItemsSketch<T> {
50+
final class VarOptItemsSketch<T> {
5151
/**
5252
* The smallest sampling array allocated: 16
5353
*/

sketches/src/test/java/com/yahoo/sketches/sampling/ReservoirItemsUnionTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,29 @@ public void checkDownsampledUpdate() {
225225
assertEquals(riu.getResult().getNumSamples(), smallK);
226226
}
227227

228+
@Test
229+
public void checkUnionResetWithInitialSmallK() {
230+
final int maxK = 25;
231+
final int sketchK = 10;
232+
final ReservoirItemsUnion<Long> riu = ReservoirItemsUnion.getInstance(maxK);
233+
234+
ReservoirItemsSketch<Long> ris = getBasicSketch(2 * sketchK, sketchK); // in sampling mode
235+
riu.update(ris);
236+
assertEquals(riu.getMaxK(), maxK);
237+
assertNotNull(riu.getResult());
238+
assertEquals(riu.getResult().getK(), sketchK);
239+
240+
riu.reset();
241+
assertNotNull(riu.getResult());
242+
243+
// feed in sketch in sampling mode, with larger k than old gadget
244+
ris = getBasicSketch(2 * maxK, maxK + 1);
245+
riu.update(ris);
246+
assertEquals(riu.getMaxK(), maxK);
247+
assertNotNull(riu.getResult());
248+
assertEquals(riu.getResult().getK(), maxK);
249+
}
250+
228251
@Test
229252
public void checkNewGadget() {
230253
final int maxK = 1024;

0 commit comments

Comments
 (0)