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:30 UTC

[incubator-datasketches-java] branch AddCtrs created (now e9b3ec3)

This is an automated email from the ASF dual-hosted git repository.

leerho pushed a change to branch AddCtrs
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-java.git.


      at e9b3ec3  update DoubleSketch and IntegerSketch constructors to chain.

This branch includes the following new commits:

     new 8b43f12  Add additional ctr to IntegerSketch and DoubleSketch
     new e9b3ec3  update DoubleSketch and IntegerSketch constructors to chain.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[incubator-datasketches-java] 01/02: Add additional ctr to IntegerSketch and DoubleSketch

Posted by le...@apache.org.
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


[incubator-datasketches-java] 02/02: update DoubleSketch and IntegerSketch constructors to chain.

Posted by le...@apache.org.
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 e9b3ec3eae527ac94edfab16457a3121d5ac666f
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Thu Jan 16 16:51:11 2020 -0800

    update DoubleSketch and IntegerSketch constructors to chain.
---
 src/main/java/org/apache/datasketches/tuple/adouble/DoubleSketch.java   | 2 +-
 .../java/org/apache/datasketches/tuple/aninteger/IntegerSketch.java     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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 c453835..8159886 100644
--- a/src/main/java/org/apache/datasketches/tuple/adouble/DoubleSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/adouble/DoubleSketch.java
@@ -35,7 +35,7 @@ public class DoubleSketch extends UpdatableSketch<Double, DoubleSummary> {
    * @param mode The DoubleSummary mode to be used
    */
   public DoubleSketch(final int lgK, final DoubleSummary.Mode mode) {
-    super(1 << lgK, ResizeFactor.X8.ordinal(), 1.0F, new DoubleSummaryFactory(mode));
+    this(1 << lgK, ResizeFactor.X8.ordinal(), 1.0F, mode);
   }
 
   /**
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 7e0a8f3..394cc34 100644
--- a/src/main/java/org/apache/datasketches/tuple/aninteger/IntegerSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/aninteger/IntegerSketch.java
@@ -35,7 +35,7 @@ public class IntegerSketch extends UpdatableSketch<Integer, IntegerSummary> {
    * @param mode The IntegerSummary mode to be used
    */
   public IntegerSketch(final int lgK, final IntegerSummary.Mode mode) {
-    super(1 << lgK, ResizeFactor.X8.ordinal(), 1.0F, new IntegerSummaryFactory(mode));
+    this(1 << lgK, ResizeFactor.X8.ordinal(), 1.0F, mode);
   }
 
   /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org