You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2020/01/17 00:51:31 UTC
[incubator-datasketches-java] 01/02: Add additional ctr to
IntegerSketch and DoubleSketch
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch AddCtrs
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-java.git
commit 8b43f12eaa3f849fab9f544c55378bf7bdc45903
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Thu Jan 16 16:41:43 2020 -0800
Add additional ctr to IntegerSketch and DoubleSketch
---
.../java/org/apache/datasketches/tuple/Union.java | 6 +++---
.../apache/datasketches/tuple/UpdatableSketch.java | 4 ++--
.../datasketches/tuple/adouble/DoubleSketch.java | 19 +++++++++++++++++++
.../datasketches/tuple/aninteger/IntegerSketch.java | 19 +++++++++++++++++++
4 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/datasketches/tuple/Union.java b/src/main/java/org/apache/datasketches/tuple/Union.java
index 6b024c1..b71ad3b 100644
--- a/src/main/java/org/apache/datasketches/tuple/Union.java
+++ b/src/main/java/org/apache/datasketches/tuple/Union.java
@@ -51,7 +51,7 @@ public class Union<S extends Summary> {
public Union(final int nomEntries, final SummarySetOperations<S> summarySetOps) {
nomEntries_ = nomEntries;
summarySetOps_ = summarySetOps;
- sketch_ = new QuickSelectSketch<S>(nomEntries, null);
+ sketch_ = new QuickSelectSketch<>(nomEntries, null);
theta_ = sketch_.getThetaLong();
}
@@ -60,7 +60,7 @@ public class Union<S extends Summary> {
* @param sketchIn input sketch to add to the internal set
*/
public void update(final Sketch<S> sketchIn) {
- if (sketchIn == null || sketchIn.isEmpty()) { return; }
+ if ((sketchIn == null) || sketchIn.isEmpty()) { return; }
if (sketchIn.theta_ < theta_) { theta_ = sketchIn.theta_; }
final SketchIterator<S> it = sketchIn.iterator();
while (it.next()) {
@@ -85,6 +85,6 @@ public class Union<S extends Summary> {
* Resets the internal set to the initial state, which represents an empty set
*/
public void reset() {
- sketch_ = new QuickSelectSketch<S>(nomEntries_, null);
+ sketch_ = new QuickSelectSketch<>(nomEntries_, null);
}
}
diff --git a/src/main/java/org/apache/datasketches/tuple/UpdatableSketch.java b/src/main/java/org/apache/datasketches/tuple/UpdatableSketch.java
index dd07d42..174e282 100644
--- a/src/main/java/org/apache/datasketches/tuple/UpdatableSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/UpdatableSketch.java
@@ -55,8 +55,8 @@ public class UpdatableSketch<U, S extends UpdatableSummary<U>> extends QuickSele
* <a href="{@docRoot}/resources/dictionary.html#p">See Sampling Probability</a>
* @param summaryFactory An instance of a SummaryFactory.
*/
- public UpdatableSketch(final int nomEntries, final int lgResizeFactor, final float samplingProbability,
- final SummaryFactory<S> summaryFactory) {
+ public UpdatableSketch(final int nomEntries, final int lgResizeFactor,
+ final float samplingProbability, final SummaryFactory<S> summaryFactory) {
super(nomEntries, lgResizeFactor, samplingProbability, summaryFactory);
}
diff --git a/src/main/java/org/apache/datasketches/tuple/adouble/DoubleSketch.java b/src/main/java/org/apache/datasketches/tuple/adouble/DoubleSketch.java
index 57cc8e6..c453835 100644
--- a/src/main/java/org/apache/datasketches/tuple/adouble/DoubleSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/adouble/DoubleSketch.java
@@ -39,6 +39,25 @@ public class DoubleSketch extends UpdatableSketch<Double, DoubleSummary> {
}
/**
+ * Creates this sketch with the following parameters:
+ * @param lgK Log_base2 of <i>Nominal Entries</i>.
+ * @param lgResizeFactor log2(resizeFactor) - value from 0 to 3:
+ * <pre>
+ * 0 - no resizing (max size allocated),
+ * 1 - double internal hash table each time it reaches a threshold
+ * 2 - grow four times
+ * 3 - grow eight times (default)
+ * </pre>
+ * @param samplingProbability
+ * <a href="{@docRoot}/resources/dictionary.html#p">See Sampling Probability</a>
+ * @param mode The DoubleSummary mode to be used
+ */
+ public DoubleSketch(final int lgK, final int lgResizeFactor, final float samplingProbability,
+ final DoubleSummary.Mode mode) {
+ super(1 << lgK, lgResizeFactor, samplingProbability, new DoubleSummaryFactory(mode));
+ }
+
+ /**
* Constructs this sketch from a Memory image, which must be from an DoubleSketch, and
* usually with data.
* @param mem the given Memory
diff --git a/src/main/java/org/apache/datasketches/tuple/aninteger/IntegerSketch.java b/src/main/java/org/apache/datasketches/tuple/aninteger/IntegerSketch.java
index 9d75912..7e0a8f3 100644
--- a/src/main/java/org/apache/datasketches/tuple/aninteger/IntegerSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/aninteger/IntegerSketch.java
@@ -39,6 +39,25 @@ public class IntegerSketch extends UpdatableSketch<Integer, IntegerSummary> {
}
/**
+ * Creates this sketch with the following parameters:
+ * @param lgK Log_base2 of <i>Nominal Entries</i>.
+ * @param lgResizeFactor log2(resizeFactor) - value from 0 to 3:
+ * <pre>
+ * 0 - no resizing (max size allocated),
+ * 1 - double internal hash table each time it reaches a threshold
+ * 2 - grow four times
+ * 3 - grow eight times (default)
+ * </pre>
+ * @param samplingProbability
+ * <a href="{@docRoot}/resources/dictionary.html#p">See Sampling Probability</a>
+ * @param mode The IntegerSummary mode to be used
+ */
+ public IntegerSketch(final int lgK, final int lgResizeFactor, final float samplingProbability,
+ final IntegerSummary.Mode mode) {
+ super(1 << lgK, lgResizeFactor, samplingProbability, new IntegerSummaryFactory(mode));
+ }
+
+ /**
* Constructs this sketch from a Memory image, which must be from an IntegerSketch, and
* usually with data.
* @param mem the given Memory
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org