Skip to content

Commit f3e4631

Browse files
committed
Minor fixes.
added testng.xml to tools to manage -Xmx config when running all tests.
1 parent d3c4927 commit f3e4631

6 files changed

Lines changed: 68 additions & 35 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ under the License.
9999
<jvm-arguments></jvm-arguments>
100100
<maven.compiler.source>${java.version}</maven.compiler.source>
101101
<maven.compiler.target>${java.version}</maven.compiler.target>
102-
<argLine>-Xmx4g -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8 ${jvm-arguments}</argLine>
102+
<argLine>-Xmx10g -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8 ${jvm-arguments}</argLine>
103103
<charset.encoding>UTF-8</charset.encoding>
104104
<project.build.sourceEncoding>${charset.encoding}</project.build.sourceEncoding>
105105
<project.build.resourceEncoding>${charset.encoding}</project.build.resourceEncoding>

src/main/java/org/apache/datasketches/kll/KllDoublesSketch.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ public static KllDoublesSketch newDirectInstance(final MemorySegment dstSeg) {
109109
public static KllDoublesSketch newDirectInstance(
110110
final int k,
111111
final MemorySegment dstSeg,
112-
final MemorySegmentRequest memSegReq) {
112+
final MemorySegmentRequest mSegReq) {
113113
Objects.requireNonNull(dstSeg, "Parameter 'dstSeg' must not be null");
114-
return KllDirectDoublesSketch.newDirectUpdatableInstance(k, DEFAULT_M, dstSeg, memSegReq);
114+
return KllDirectDoublesSketch.newDirectUpdatableInstance(k, DEFAULT_M, dstSeg, mSegReq);
115115
}
116116

117117
//Factory to create an heap instance from a MemorySegment image
@@ -172,10 +172,10 @@ public static KllDoublesSketch wrap(final MemorySegment srcSeg) {
172172
* @param mSegReq the callback for the sketch to request a larger MemorySegment. It may be null.
173173
* @return an instance of this sketch that wraps the given MemorySegment.
174174
*/
175-
public static KllDoublesSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest memSegReq) {
175+
public static KllDoublesSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
176176
Objects.requireNonNull(srcSeg, "Parameter 'srcSeg' must not be null");
177177
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, DOUBLES_SKETCH);
178-
return new KllDirectDoublesSketch(srcSeg, segVal, memSegReq);
178+
return new KllDirectDoublesSketch(srcSeg, segVal, mSegReq);
179179
}
180180

181181
//END of Constructors

src/main/java/org/apache/datasketches/kll/KllFloatsSketch.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ public static KllFloatsSketch newDirectInstance(final MemorySegment dstSeg) {
109109
public static KllFloatsSketch newDirectInstance(
110110
final int k,
111111
final MemorySegment dstSeg,
112-
final MemorySegmentRequest memSegReq) {
112+
final MemorySegmentRequest mSegReq) {
113113
Objects.requireNonNull(dstSeg, "Parameter 'dstSeg' must not be null");
114-
return KllDirectFloatsSketch.newDirectUpdatableInstance(k, DEFAULT_M, dstSeg, memSegReq);
114+
return KllDirectFloatsSketch.newDirectUpdatableInstance(k, DEFAULT_M, dstSeg, mSegReq);
115115
}
116116

117117
//Factory to create an heap instance from a MemorySegment image
@@ -172,10 +172,10 @@ public static KllFloatsSketch wrap(final MemorySegment srcSeg) {
172172
* @param mSegReq the callback for the sketch to request a larger MemorySegment. It may be null.
173173
* @return an instance of this sketch that wraps the given MemorySegment.
174174
*/
175-
public static KllFloatsSketch writableWrap(final MemorySegment srcSeg, final MemorySegmentRequest memSegReq) {
175+
public static KllFloatsSketch writableWrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
176176
Objects.requireNonNull(srcSeg, "Parameter 'srcSeg' must not be null");
177177
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, FLOATS_SKETCH);
178-
return new KllDirectFloatsSketch(srcSeg, segVal, memSegReq);
178+
return new KllDirectFloatsSketch(srcSeg, segVal, mSegReq);
179179
}
180180

181181
//END of Constructors

src/main/java/org/apache/datasketches/kll/KllLongsSketch.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ public static KllLongsSketch newDirectInstance(final MemorySegment dstSeg) {
109109
public static KllLongsSketch newDirectInstance(
110110
final int k,
111111
final MemorySegment dstSeg,
112-
final MemorySegmentRequest memSegReq) {
112+
final MemorySegmentRequest mSegReq) {
113113
Objects.requireNonNull(dstSeg, "Parameter 'dstSeg' must not be null");
114-
return KllDirectLongsSketch.newDirectUpdatableInstance(k, DEFAULT_M, dstSeg, memSegReq);
114+
return KllDirectLongsSketch.newDirectUpdatableInstance(k, DEFAULT_M, dstSeg, mSegReq);
115115
}
116116

117117
//Factory to create an heap instance from a MemorySegment image
@@ -172,10 +172,10 @@ public static KllLongsSketch wrap(final MemorySegment srcSeg) {
172172
* @param mSegReq the callback for the sketch to request a larger MemorySegment. It may be null.
173173
* @return an instance of this sketch that wraps the given MemorySegment.
174174
*/
175-
public static KllLongsSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest memSegReq) {
175+
public static KllLongsSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
176176
Objects.requireNonNull(srcSeg, "Parameter 'srcSeg' must not be null");
177177
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, LONGS_SKETCH);
178-
return new KllDirectLongsSketch(srcSeg, segVal, memSegReq);
178+
return new KllDirectLongsSketch(srcSeg, segVal, mSegReq);
179179
}
180180

181181
//END of Constructors

src/test/java/org/apache/datasketches/count/CountMinSketchTest.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@
3030
import static org.testng.Assert.*;
3131

3232
public class CountMinSketchTest {
33+
3334
@Test
3435
public void createNewCountMinSketchTest() throws Exception {
3536
assertThrows(SketchesArgumentException.class, () -> new CountMinSketch((byte) 5, 1, 123));
36-
assertThrows(SketchesArgumentException.class, () -> new CountMinSketch((byte) 4, 268435456, 123));
37-
37+
//2^28 buckets and 4 hashes -> a long[] of 8GB! Set JVM -Xmx > 8g
38+
assertThrows(SketchesArgumentException.class, () -> new CountMinSketch((byte) 4, (1 << 28), 123));
3839
final byte numHashes = 3;
3940
final int numBuckets = 5;
4041
final long seed = 1234567;
41-
CountMinSketch c = new CountMinSketch(numHashes, numBuckets, seed);
42+
final CountMinSketch c = new CountMinSketch(numHashes, numBuckets, seed);
4243

4344
assertEquals(c.getNumHashes_(), numHashes);
4445
assertEquals(c.getNumBuckets_(), numBuckets);
@@ -77,7 +78,7 @@ public void countMinSketchOneUpdateTest() {
7778
final int numBuckets = 5;
7879
final long seed = 1234567;
7980
long insertedWeights = 0;
80-
CountMinSketch c = new CountMinSketch(numHashes, numBuckets, seed);
81+
final CountMinSketch c = new CountMinSketch(numHashes, numBuckets, seed);
8182
final String x = "x";
8283

8384
assertTrue(c.isEmpty());
@@ -103,7 +104,7 @@ public void countMinSketchOneUpdateTest() {
103104

104105
@Test
105106
public void frequencyCancellationTest() {
106-
CountMinSketch c = new CountMinSketch((byte) 1, 5, 123456);
107+
final CountMinSketch c = new CountMinSketch((byte) 1, 5, 123456);
107108
c.update("x", 1);
108109
c.update("y", -1);
109110
assertEquals(c.getTotalWeight_(), 2);
@@ -114,8 +115,8 @@ public void frequencyCancellationTest() {
114115
@Test
115116
public void frequencyEstimates() {
116117
final int numItems = 10;
117-
long[] data = new long[numItems];
118-
long[] frequencies = new long[numItems];
118+
final long[] data = new long[numItems];
119+
final long[] frequencies = new long[numItems];
119120

120121
for (int i = 0; i < numItems; i++) {
121122
data[i] = i;
@@ -127,7 +128,7 @@ public void frequencyEstimates() {
127128
final int numBuckets = CountMinSketch.suggestNumBuckets(relativeError);
128129
final byte numHashes = CountMinSketch.suggestNumHashes(confidence);
129130

130-
CountMinSketch c = new CountMinSketch(numHashes, numBuckets, 1234567);
131+
final CountMinSketch c = new CountMinSketch(numHashes, numBuckets, 1234567);
131132
for (int i = 0; i < numItems; i++) {
132133
final long value = data[i];
133134
final long freq = frequencies[i];
@@ -150,15 +151,15 @@ public void mergeFailTest() {
150151
final long seed = 1234567;
151152
final int numBuckets = CountMinSketch.suggestNumBuckets(relativeError);
152153
final byte numHashes = CountMinSketch.suggestNumHashes(confidence);
153-
CountMinSketch s = new CountMinSketch(numHashes, numBuckets, seed);
154+
final CountMinSketch s = new CountMinSketch(numHashes, numBuckets, seed);
154155

155156
assertThrows("Cannot merge a sketch with itself.", SketchesException.class, () -> s.merge(s));
156157

157-
CountMinSketch s1 = new CountMinSketch((byte) (numHashes + 1), numBuckets, seed);
158-
CountMinSketch s2 = new CountMinSketch(numHashes, numBuckets + 1, seed);
159-
CountMinSketch s3 = new CountMinSketch(numHashes, numBuckets, seed + 1);
158+
final CountMinSketch s1 = new CountMinSketch((byte) (numHashes + 1), numBuckets, seed);
159+
final CountMinSketch s2 = new CountMinSketch(numHashes, numBuckets + 1, seed);
160+
final CountMinSketch s3 = new CountMinSketch(numHashes, numBuckets, seed + 1);
160161

161-
CountMinSketch[] sketches = {s1, s2, s3};
162+
final CountMinSketch[] sketches = {s1, s2, s3};
162163
for (final CountMinSketch sk : sketches) {
163164
assertThrows("Incompatible sketch configuration.", SketchesException.class, () -> s.merge(sk));
164165
}
@@ -171,12 +172,12 @@ public void mergeTest() {
171172
final long seed = 123456;
172173
final int numBuckets = CountMinSketch.suggestNumBuckets(relativeError);
173174
final byte numHashes = CountMinSketch.suggestNumHashes(confidence);
174-
CountMinSketch c = new CountMinSketch(numHashes, numBuckets, seed);
175+
final CountMinSketch c = new CountMinSketch(numHashes, numBuckets, seed);
175176

176177
final byte sHashes = c.getNumHashes_();
177178
final int sBuckets = c.getNumBuckets_();
178179
final long sSeed = c.getSeed_();
179-
CountMinSketch s = new CountMinSketch(sHashes, sBuckets, sSeed);
180+
final CountMinSketch s = new CountMinSketch(sHashes, sBuckets, sSeed);
180181

181182
c.merge(s);
182183
assertEquals(c.getTotalWeight_(), 0);
@@ -201,15 +202,15 @@ public void serializeDeserializeEmptyTest() {
201202
final byte numHashes = 3;
202203
final int numBuckets = 32;
203204
final long seed = 123456;
204-
CountMinSketch c = new CountMinSketch(numHashes, numBuckets, seed);
205+
final CountMinSketch c = new CountMinSketch(numHashes, numBuckets, seed);
205206

206-
ByteArrayOutputStream buf = new ByteArrayOutputStream();
207+
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
207208
c.serialize(buf);
208209

209-
byte[] b = buf.toByteArray();
210+
final byte[] b = buf.toByteArray();
210211
assertThrows(SketchesArgumentException.class, () -> CountMinSketch.deserialize(b, seed - 1));
211212

212-
CountMinSketch d = CountMinSketch.deserialize(b, seed);
213+
final CountMinSketch d = CountMinSketch.deserialize(b, seed);
213214
assertEquals(d.getNumHashes_(), c.getNumHashes_());
214215
assertEquals(d.getNumBuckets_(), c.getNumBuckets_());
215216
assertEquals(d.getSeed_(), c.getSeed_());
@@ -223,16 +224,16 @@ public void serializeDeserializeTest() {
223224
final byte numHashes = 5;
224225
final int numBuckets = 64;
225226
final long seed = 1234456;
226-
CountMinSketch c = new CountMinSketch(numHashes, numBuckets, seed);
227+
final CountMinSketch c = new CountMinSketch(numHashes, numBuckets, seed);
227228
for (long i = 0; i < 10; i++) {
228229
c.update(i, 10*i*i);
229230
}
230231

231-
ByteArrayOutputStream buf = new ByteArrayOutputStream();
232+
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
232233
c.serialize(buf);
233234

234235
assertThrows(SketchesArgumentException.class, () -> CountMinSketch.deserialize(buf.toByteArray(), seed - 1));
235-
CountMinSketch d = CountMinSketch.deserialize(buf.toByteArray(), seed);
236+
final CountMinSketch d = CountMinSketch.deserialize(buf.toByteArray(), seed);
236237

237238
assertEquals(d.getNumHashes_(), c.getNumHashes_());
238239
assertEquals(d.getNumBuckets_(), c.getNumBuckets_());

tools/testng.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >
2+
<suite name="AllTestsSuite">
3+
<test name="AllTests">
4+
<packages>
5+
<package name="org.apache.datasketches.common.positional" />
6+
<package name="org.apache.datasketches.common" />
7+
<package name="org.apache.datasketches.count" />
8+
<package name="org.apache.datasketches.cpc" />
9+
<package name="org.apache.datasketches.fdt" />
10+
<package name="org.apache.datasketches.filters.bloomfilter" />
11+
<package name="org.apache.datasketches.frequencies" />
12+
<package name="org.apache.datasketches.hash" />
13+
<package name="org.apache.datasketches.hll" />
14+
<package name="org.apache.datasketches.hllmap" />
15+
<package name="org.apache.datasketches.kll" />
16+
<package name="org.apache.datasketches.partitions" />
17+
<package name="org.apache.datasketches.quantiles" />
18+
<package name="org.apache.datasketches.quantiles2" />
19+
<package name="org.apache.datasketches.quantilescommon" />
20+
<package name="org.apache.datasketches.req" />
21+
<package name="org.apache.datasketches.sampling" />
22+
<package name="org.apache.datasketches.tdigest" />
23+
<package name="org.apache.datasketches.theta" />
24+
<package name="org.apache.datasketches.thetacommon" />
25+
<package name="org.apache.datasketches.tuple.adouble" />
26+
<package name="org.apache.datasketches.tuple.aninteger" />
27+
<package name="org.apache.datasketches.arrayofdoubles" />
28+
<package name="org.apache.datasketches.strings" />
29+
<package name="org.apache.datasketches.tuple" />
30+
</packages>
31+
</test>
32+
</suite>

0 commit comments

Comments
 (0)