Skip to content

Commit e1f286d

Browse files
author
jmalkin
committed
bump VersionEye version, add missing copyrights, improve sampling union reset tests
1 parent 6254e77 commit e1f286d

9 files changed

Lines changed: 93 additions & 18 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/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;

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

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,29 @@ public void checkDownsampledUpdate() {
208208
assertEquals(rlu.getResult().getNumSamples(), smallK);
209209
}
210210

211+
@Test
212+
public void checkUnionResetWithInitialSmallK() {
213+
final int maxK = 25;
214+
final int sketchK = 10;
215+
final ReservoirLongsUnion rlu = ReservoirLongsUnion.getInstance(maxK);
216+
217+
ReservoirLongsSketch rls = getBasicSketch(2 * sketchK, sketchK); // in sampling mode
218+
rlu.update(rls);
219+
assertEquals(rlu.getMaxK(), maxK);
220+
assertNotNull(rlu.getResult());
221+
assertEquals(rlu.getResult().getK(), sketchK);
222+
223+
rlu.reset();
224+
assertNotNull(rlu.getResult());
225+
226+
// feed in sketch in sampling mode, with larger k than old gadget
227+
rls = getBasicSketch(2 * maxK, maxK + 1);
228+
rlu.update(rls);
229+
assertEquals(rlu.getMaxK(), maxK);
230+
assertNotNull(rlu.getResult());
231+
assertEquals(rlu.getResult().getK(), maxK);
232+
}
233+
211234
@Test
212235
public void checkNewGadget() {
213236
final int maxK = 1024;
@@ -219,34 +242,34 @@ public void checkNewGadget() {
219242
final byte[] bigKBytes = bigKSketch.toByteArray();
220243
final Memory bigKMem = new NativeMemory(bigKBytes);
221244

222-
ReservoirLongsUnion riu = ReservoirLongsUnion.getInstance(maxK);
223-
riu.update(bigKMem);
224-
assertNotNull(riu.getResult());
225-
assertEquals(riu.getResult().getK(), maxK);
226-
assertEquals(riu.getResult().getN(), maxK / 2);
245+
ReservoirLongsUnion rlu = ReservoirLongsUnion.getInstance(maxK);
246+
rlu.update(bigKMem);
247+
assertNotNull(rlu.getResult());
248+
assertEquals(rlu.getResult().getK(), maxK);
249+
assertEquals(rlu.getResult().getN(), maxK / 2);
227250

228251
// sketch k < maxK but in sampling mode
229252
final ReservoirLongsSketch smallKSketch = getBasicSketch(maxK, smallK);
230253
final byte[] smallKBytes = smallKSketch.toByteArray();
231254
final Memory smallKMem = new NativeMemory(smallKBytes);
232255

233-
riu = ReservoirLongsUnion.getInstance(maxK);
234-
riu.update(smallKMem);
235-
assertNotNull(riu.getResult());
236-
assertTrue(riu.getResult().getK() < maxK);
237-
assertEquals(riu.getResult().getK(), smallK);
238-
assertEquals(riu.getResult().getN(), maxK);
256+
rlu = ReservoirLongsUnion.getInstance(maxK);
257+
rlu.update(smallKMem);
258+
assertNotNull(rlu.getResult());
259+
assertTrue(rlu.getResult().getK() < maxK);
260+
assertEquals(rlu.getResult().getK(), smallK);
261+
assertEquals(rlu.getResult().getN(), maxK);
239262

240263
// sketch k < maxK and in exact mode
241264
final ReservoirLongsSketch smallKExactSketch = getBasicSketch(smallK, smallK);
242265
final byte[] smallKExactBytes = smallKExactSketch.toByteArray();
243266
final Memory smallKExactMem = new NativeMemory(smallKExactBytes);
244267

245-
riu = ReservoirLongsUnion.getInstance(maxK);
246-
riu.update(smallKExactMem);
247-
assertNotNull(riu.getResult());
248-
assertEquals(riu.getResult().getK(), maxK);
249-
assertEquals(riu.getResult().getN(), smallK);
268+
rlu = ReservoirLongsUnion.getInstance(maxK);
269+
rlu.update(smallKExactMem);
270+
assertNotNull(rlu.getResult());
271+
assertEquals(rlu.getResult().getK(), maxK);
272+
assertEquals(rlu.getResult().getN(), smallK);
250273
}
251274

252275
@Test

0 commit comments

Comments
 (0)