leerho commented on code in PR #798:
URL: https://github.com/apache/datasketches-java/pull/798#discussion_r4545006631
##########
src/main/java/org/apache/datasketches/count/CountMinSketch.java:
##########
@@ -64,14 +77,49 @@ int mask() {
}
/**
- * Creates a CountMin sketch with given number of hash functions and buckets,
- * and a user-specified seed.
+ * Creates an empty CountMin sketch with the given number of hash functions
and buckets,
+ * and the default seed, {@link Util#DEFAULT_UPDATE_SEED}.
+ * The sketch uses serialization version 2.
+ *
+ * <p>{@link #suggestNumHashes(double)} and {@link
#suggestNumBuckets(double)} give suitable values
+ * for a desired confidence and relative error.</p>
+ *
+ * @param numHashes The number of hash functions (rows), from 1 to 127
+ * @param numBuckets The number of buckets per hash function, at least 3.
+ * The product of numHashes and numBuckets must be less than 2<sup>30</sup>.
+ * @throws SketchesArgumentException if a parameter is out of range
+ */
+ public CountMinSketch(final byte numHashes, final int numBuckets) {
Review Comment:
Good point, thanks. Both public constructors now take `int numHashes`,
checked to be from 1 to 127. It is cast to a byte only where it is stored,
since the image keeps it in one byte. So `new CountMinSketch(3, 1000)` works
without a cast, and a `byte` from `suggestNumHashes()` still passes directly.
`getNumHashes_()` and the serialization format are unchanged. A new test covers
the range (0, -1, 128 and 259 are rejected; 127 round-trips).
##########
src/main/java/org/apache/datasketches/count/CountMinSketch.java:
##########
@@ -64,14 +77,49 @@ int mask() {
}
/**
- * Creates a CountMin sketch with given number of hash functions and buckets,
- * and a user-specified seed.
+ * Creates an empty CountMin sketch with the given number of hash functions
and buckets,
+ * and the default seed, {@link Util#DEFAULT_UPDATE_SEED}.
+ * The sketch uses serialization version 2.
+ *
+ * <p>{@link #suggestNumHashes(double)} and {@link
#suggestNumBuckets(double)} give suitable values
+ * for a desired confidence and relative error.</p>
+ *
+ * @param numHashes The number of hash functions (rows), from 1 to 127
+ * @param numBuckets The number of buckets per hash function, at least 3.
+ * The product of numHashes and numBuckets must be less than 2<sup>30</sup>.
+ * @throws SketchesArgumentException if a parameter is out of range
+ */
+ public CountMinSketch(final byte numHashes, final int numBuckets) {
+ this(numHashes, numBuckets, Util.DEFAULT_UPDATE_SEED);
+ }
+
+ /**
+ * Creates an empty CountMin sketch with the given number of hash functions
and buckets,
+ * and the given seed. The sketch uses serialization version 2.
+ *
+ * <p>{@link #suggestNumHashes(double)} and {@link
#suggestNumBuckets(double)} give suitable values
+ * for a desired confidence and relative error. Sketches can be merged only
if they use the same
+ * seed, and an image must be read back with the seed it was created
with.</p>
+ *
+ * @param numHashes The number of hash functions (rows), from 1 to 127
+ * @param numBuckets The number of buckets per hash function, at least 3.
+ * The product of numHashes and numBuckets must be less than 2<sup>30</sup>.
+ * @param seed The base hash seed
+ * @throws SketchesArgumentException if a parameter is out of range
+ */
+ public CountMinSketch(final byte numHashes, final int numBuckets, final long
seed) {
Review Comment:
Changed here too. See the reply on the first constructor above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]