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 2019/09/21 01:48:03 UTC
[incubator-datasketches-hive] 02/04: Performed License swap,
package refactoring,
corrected import statements referring to the tuple/adouble/ implementation.
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch LicenseSwap
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-hive.git
commit 86c4a2398d0b88689250a69e95048b4099e9b70c
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Thu Sep 19 14:41:01 2019 -0700
Performed License swap, package refactoring, corrected import statements
referring to the tuple/adouble/ implementation.
---
.../java/com/yahoo/sketches/hive/cpc/State.java | 36 -------------
.../com/yahoo/sketches/hive/cpc/UnionState.java | 41 --------------
.../com/yahoo/sketches/hive/cpc/package-info.java | 11 ----
.../hive/frequencies/UnionStringsSketchUDAF.java | 32 -----------
.../sketches/hive/frequencies/package-info.java | 15 ------
.../sketches/hive/hll/SketchToEstimateUDF.java | 34 ------------
.../yahoo/sketches/hive/hll/SketchToStringUDF.java | 33 ------------
.../java/com/yahoo/sketches/hive/hll/State.java | 40 --------------
.../com/yahoo/sketches/hive/hll/package-info.java | 10 ----
.../java/com/yahoo/sketches/hive/kll/GetNUDF.java | 31 -----------
.../com/yahoo/sketches/hive/kll/SketchState.java | 49 -----------------
.../yahoo/sketches/hive/kll/SketchToStringUDF.java | 31 -----------
.../com/yahoo/sketches/hive/kll/package-info.java | 11 ----
.../hive/quantiles/DoublesSketchToStringUDF.java | 31 -----------
.../hive/quantiles/GetKFromDoublesSketchUDF.java | 31 -----------
.../hive/quantiles/GetKFromStringsSketchUDF.java | 38 -------------
.../hive/quantiles/GetNFromDoublesSketchUDF.java | 31 -----------
.../hive/quantiles/GetNFromStringsSketchUDF.java | 39 --------------
.../hive/quantiles/StringsSketchToStringUDF.java | 38 -------------
.../hive/quantiles/UnionStringsSketchUDAF.java | 34 ------------
.../com/yahoo/sketches/hive/quantiles/Util.java | 27 ----------
.../sketches/hive/quantiles/package-info.java | 21 --------
.../yahoo/sketches/hive/theta/package-info.java | 12 -----
.../hive/tuple/ArrayOfDoublesSketchStats.java | 36 -------------
...fDoublesSketchToNumberOfRetainedEntriesUDF.java | 36 -------------
.../sketches/hive/tuple/ArrayOfDoublesState.java | 34 ------------
.../hive/tuple/ArrayOfDoublesUnionState.java | 42 ---------------
.../java/com/yahoo/sketches/hive/tuple/State.java | 29 ----------
.../com/yahoo/sketches/hive/tuple/UnionState.java | 41 --------------
.../datasketches}/hive/cpc/DataToSketchUDAF.java | 22 ++++++--
.../hive/cpc/GetEstimateAndErrorBoundsUDF.java | 27 +++++++---
.../datasketches}/hive/cpc/GetEstimateUDF.java | 27 +++++++---
.../hive/cpc}/ObjectInspectorValidator.java | 20 +++++--
.../datasketches}/hive/cpc/SketchEvaluator.java | 25 ++++++---
.../apache/datasketches}/hive/cpc/SketchState.java | 23 ++++++--
.../datasketches}/hive/cpc/SketchToStringUDF.java | 27 +++++++---
.../org/apache/datasketches/hive/cpc/State.java | 49 +++++++++++++++++
.../datasketches}/hive/cpc/UnionSketchUDAF.java | 27 +++++++---
.../datasketches}/hive/cpc/UnionSketchUDF.java | 29 +++++++---
.../apache/datasketches/hive/cpc/UnionState.java | 55 +++++++++++++++++++
.../apache/datasketches/hive/cpc/package-info.java | 25 +++++++++
.../hive/frequencies/DataToItemsSketchUDAF.java | 23 ++++++--
.../hive/frequencies/DataToStringsSketchUDAF.java | 23 ++++++--
.../GetFrequentItemsFromStringsSketchUDTF.java | 29 +++++++---
.../hive/frequencies/ItemsEvaluator.java | 27 +++++++---
.../datasketches}/hive/frequencies/ItemsState.java | 29 +++++++---
.../hive/frequencies/UnionItemsSketchUDAF.java | 23 ++++++--
.../hive/frequencies/UnionStringsSketchUDAF.java | 45 ++++++++++++++++
.../hive/frequencies/package-info.java | 29 ++++++++++
.../datasketches}/hive/hll/DataToSketchUDAF.java | 23 ++++++--
.../hive/hll/ObjectInspectorValidator.java | 20 +++++--
.../datasketches}/hive/hll/SketchEvaluator.java | 27 +++++++---
.../apache/datasketches}/hive/hll/SketchState.java | 25 ++++++---
.../hll/SketchToEstimateAndErrorBoundsUDF.java | 25 ++++++---
.../datasketches/hive/hll/SketchToEstimateUDF.java | 47 ++++++++++++++++
.../datasketches/hive/hll/SketchToStringUDF.java | 46 ++++++++++++++++
.../org/apache/datasketches/hive/hll/State.java | 53 ++++++++++++++++++
.../datasketches}/hive/hll/UnionSketchUDAF.java | 27 +++++++---
.../datasketches}/hive/hll/UnionSketchUDF.java | 29 +++++++---
.../apache/datasketches}/hive/hll/UnionState.java | 27 +++++++---
.../apache/datasketches/hive/hll/package-info.java | 25 +++++++++
.../datasketches}/hive/kll/DataToSketchUDAF.java | 20 +++++--
.../apache/datasketches}/hive/kll/GetCdfUDF.java | 25 ++++++---
.../org/apache/datasketches/hive/kll/GetNUDF.java | 44 +++++++++++++++
.../apache/datasketches}/hive/kll/GetPmfUDF.java | 25 ++++++---
.../datasketches}/hive/kll/GetQuantileUDF.java | 25 ++++++---
.../datasketches}/hive/kll/GetQuantilesUDF.java | 25 ++++++---
.../apache/datasketches}/hive/kll/GetRankUDF.java | 25 ++++++---
.../hive/kll/ObjectInspectorValidator.java | 20 +++++--
.../datasketches}/hive/kll/SketchEvaluator.java | 27 +++++++---
.../apache/datasketches/hive/kll/SketchState.java | 62 ++++++++++++++++++++++
.../datasketches/hive/kll/SketchToStringUDF.java | 44 +++++++++++++++
.../datasketches}/hive/kll/UnionSketchUDAF.java | 20 +++++--
.../apache/datasketches}/hive/kll/Util.java | 20 +++++--
.../apache/datasketches/hive/kll/package-info.java | 25 +++++++++
.../hive/quantiles/DataToDoublesSketchUDAF.java | 20 +++++--
.../hive/quantiles/DataToItemsSketchUDAF.java | 23 ++++++--
.../hive/quantiles/DataToStringsSketchUDAF.java | 23 ++++++--
.../hive/quantiles/DoublesEvaluator.java | 23 ++++++--
.../hive/quantiles/DoublesSketchToStringUDF.java | 44 +++++++++++++++
.../hive/quantiles/DoublesUnionState.java | 29 +++++++---
.../hive/quantiles/GetCdfFromDoublesSketchUDF.java | 25 ++++++---
.../hive/quantiles/GetCdfFromStringsSketchUDF.java | 27 +++++++---
.../hive/quantiles/GetKFromDoublesSketchUDF.java | 44 +++++++++++++++
.../hive/quantiles/GetKFromStringsSketchUDF.java | 51 ++++++++++++++++++
.../hive/quantiles/GetNFromDoublesSketchUDF.java | 44 +++++++++++++++
.../hive/quantiles/GetNFromStringsSketchUDF.java | 52 ++++++++++++++++++
.../hive/quantiles/GetPmfFromDoublesSketchUDF.java | 25 ++++++---
.../hive/quantiles/GetPmfFromStringsSketchUDF.java | 27 +++++++---
.../quantiles/GetQuantileFromDoublesSketchUDF.java | 25 ++++++---
.../quantiles/GetQuantileFromStringsSketchUDF.java | 27 +++++++---
.../GetQuantilesFromDoublesSketchUDF.java | 25 ++++++---
.../GetQuantilesFromStringsSketchUDF.java | 27 +++++++---
.../hive/quantiles/ItemsEvaluator.java | 25 ++++++---
.../hive/quantiles/ItemsUnionState.java | 29 +++++++---
.../hive/quantiles/ObjectInspectorValidator.java | 21 +++++++-
.../hive/quantiles/StringsSketchToStringUDF.java | 51 ++++++++++++++++++
.../hive/quantiles/UnionDoublesSketchUDAF.java | 20 +++++--
.../hive/quantiles/UnionItemsSketchUDAF.java | 23 ++++++--
.../hive/quantiles/UnionStringsSketchUDAF.java | 47 ++++++++++++++++
.../apache/datasketches/hive/quantiles/Util.java | 41 ++++++++++++++
.../datasketches/hive/quantiles/package-info.java | 35 ++++++++++++
.../datasketches}/hive/theta/DataToSketchUDAF.java | 24 +++++++--
.../hive/theta/EstimateSketchUDF.java | 27 +++++++---
.../datasketches}/hive/theta/ExcludeSketchUDF.java | 31 +++++++----
.../hive/theta/IntersectSketchUDAF.java | 33 ++++++++----
.../hive/theta/IntersectSketchUDF.java | 31 +++++++----
.../hive/theta/ObjectInspectorValidator.java | 20 +++++--
.../datasketches}/hive/theta/UnionEvaluator.java | 25 ++++++---
.../datasketches}/hive/theta/UnionSketchUDAF.java | 27 +++++++---
.../datasketches}/hive/theta/UnionSketchUDF.java | 31 +++++++----
.../datasketches}/hive/theta/UnionState.java | 29 +++++++---
.../datasketches/hive/theta/package-info.java | 26 +++++++++
.../hive/tuple/ArrayOfDoublesSketchEvaluator.java | 27 +++++++---
.../hive/tuple/ArrayOfDoublesSketchState.java | 27 +++++++---
.../hive/tuple/ArrayOfDoublesSketchStats.java | 49 +++++++++++++++++
...OfDoublesSketchToEstimateAndErrorBoundsUDF.java | 27 +++++++---
.../tuple/ArrayOfDoublesSketchToEstimatesUDF.java | 29 +++++++---
.../hive/tuple/ArrayOfDoublesSketchToMeansUDF.java | 27 +++++++---
...fDoublesSketchToNumberOfRetainedEntriesUDF.java | 49 +++++++++++++++++
.../ArrayOfDoublesSketchToQuantilesSketchUDF.java | 35 ++++++++----
.../tuple/ArrayOfDoublesSketchToValuesUDTF.java | 29 +++++++---
.../tuple/ArrayOfDoublesSketchToVariancesUDF.java | 27 +++++++---
.../hive/tuple/ArrayOfDoublesSketchesTTestUDF.java | 27 +++++++---
.../hive/tuple/ArrayOfDoublesState.java | 47 ++++++++++++++++
.../hive/tuple/ArrayOfDoublesUnionState.java | 56 +++++++++++++++++++
.../hive/tuple/DataToArrayOfDoublesSketchUDAF.java | 22 ++++++--
.../hive/tuple/DataToDoubleSummarySketchUDAF.java | 35 ++++++++----
.../DataToDoubleSummaryWithModeSketchUDAF.java | 41 +++++++++-----
.../datasketches}/hive/tuple/DataToSketchUDAF.java | 25 ++++++---
.../tuple/DoubleSummarySketchToEstimatesUDF.java | 35 ++++++++----
.../tuple/DoubleSummarySketchToPercentileUDF.java | 39 +++++++++-----
.../hive/tuple}/ObjectInspectorValidator.java | 20 +++++--
.../datasketches}/hive/tuple/SketchEvaluator.java | 35 ++++++++----
.../datasketches}/hive/tuple/SketchState.java | 31 +++++++----
.../org/apache/datasketches/hive/tuple/State.java | 42 +++++++++++++++
.../hive/tuple/UnionArrayOfDoublesSketchUDAF.java | 27 +++++++---
.../hive/tuple/UnionDoubleSummarySketchUDAF.java | 33 ++++++++----
.../UnionDoubleSummaryWithModeSketchUDAF.java | 35 ++++++++----
.../datasketches}/hive/tuple/UnionSketchUDAF.java | 29 +++++++---
.../apache/datasketches/hive/tuple/UnionState.java | 55 +++++++++++++++++++
.../datasketches}/hive/tuple/package-info.java | 21 ++++++--
.../com/yahoo/sketches/hive/kll/GetNUDFTest.java | 35 ------------
.../sketches/hive/kll/GetQuantileUDFTest.java | 34 ------------
.../yahoo/sketches/hive/kll/GetRankUDFTest.java | 35 ------------
.../sketches/hive/kll/SektchToStringUDFTest.java | 34 ------------
.../quantiles/DoublesSektchToStringUDFTest.java | 31 -----------
.../quantiles/GetKFromDoublesSektchUDFTest.java | 30 -----------
.../quantiles/GetKFromStringsSketchUDFTest.java | 38 -------------
.../quantiles/GetNFromDoublesSektchUDFTest.java | 35 ------------
.../quantiles/GetNFromStringsSketchUDFTest.java | 42 ---------------
.../GetQuantileFromDoublesSektchUDFTest.java | 34 ------------
.../quantiles/StringsSketchToStringUDFTest.java | 39 --------------
.../hive/cpc/DataToSketchUDAFTest.java | 26 ++++++---
.../hive/cpc/GetEstimateAndErrorBoundsUDFTest.java | 22 ++++++--
.../datasketches}/hive/cpc/GetEstimateUDFTest.java | 22 ++++++--
.../hive/cpc/SketchToStringUDFTest.java | 22 ++++++--
.../hive/cpc/UnionSketchUDAFTest.java | 26 ++++++---
.../datasketches}/hive/cpc/UnionSketchUDFTest.java | 24 +++++++--
.../frequencies/DataToStringsSketchUDAFTest.java | 29 +++++++---
.../GetFrequentItemsFromStringsSketchUDTFTest.java | 27 +++++++---
.../frequencies/UnionStringsSketchUDAFTest.java | 29 +++++++---
.../hive/hll/DataToSketchUDAFTest.java | 26 ++++++---
.../hll/SketchToEstimateAndErrorBoundsUDFTest.java | 22 ++++++--
.../hive/hll/SketchToEstimateUDFTest.java | 22 ++++++--
.../hive/hll/SketchToStringUDFTest.java | 22 ++++++--
.../hive/hll/UnionSketchUDAFTest.java | 26 ++++++---
.../datasketches}/hive/hll/UnionSketchUDFTest.java | 27 +++++++---
.../hive/kll/DataToSketchUDAFTest.java | 24 +++++++--
.../datasketches}/hive/kll/GetCdfUDFTest.java | 22 ++++++--
.../apache/datasketches/hive/kll/GetNUDFTest.java | 49 +++++++++++++++++
.../datasketches}/hive/kll/GetPmfUDFTest.java | 22 ++++++--
.../datasketches/hive/kll/GetQuantileUDFTest.java | 48 +++++++++++++++++
.../hive/kll/GetQuantilesUDFTest.java | 22 ++++++--
.../datasketches/hive/kll/GetRankUDFTest.java | 49 +++++++++++++++++
.../hive/kll/SektchToStringUDFTest.java | 48 +++++++++++++++++
.../hive/kll/UnionSketchUDAFTest.java | 24 +++++++--
.../quantiles/DataToDoublesSketchUDAFTest.java | 27 ++++++++--
.../quantiles/DataToStringsSketchUDAFTest.java | 29 ++++++++--
.../quantiles/DoublesSektchToStringUDFTest.java | 45 ++++++++++++++++
.../quantiles/GetCdfFromDoublesSketchUDFTest.java | 24 +++++++--
.../quantiles/GetCdfFromStringsSketchUDFTest.java | 26 ++++++---
.../quantiles/GetKFromDoublesSektchUDFTest.java | 45 ++++++++++++++++
.../quantiles/GetKFromStringsSketchUDFTest.java | 53 ++++++++++++++++++
.../quantiles/GetNFromDoublesSektchUDFTest.java | 49 +++++++++++++++++
.../quantiles/GetNFromStringsSketchUDFTest.java | 56 +++++++++++++++++++
.../quantiles/GetPmfFromDoublesSketchUDFTest.java | 25 +++++++--
.../quantiles/GetPmfFromStringsSketchUDFTest.java | 27 +++++++---
.../GetQuantileFromDoublesSektchUDFTest.java | 49 +++++++++++++++++
.../GetQuantileFromStringsSketchUDFTest.java | 28 +++++++---
.../GetQuantilesFromDoublesSketchUDFTest.java | 27 +++++++---
.../GetQuantilesFromStringsSketchUDFTest.java | 31 ++++++++---
.../quantiles/StringsSketchToStringUDFTest.java | 53 ++++++++++++++++++
.../hive/quantiles/UnionDoublesSketchUDAFTest.java | 27 +++++++---
.../hive/quantiles/UnionStringsSketchUDAFTest.java | 29 +++++++---
.../hive/theta/DataToSketchUDAFTest.java | 37 +++++++++----
.../hive/theta/EstimateSketchUDFTest.java | 29 ++++++++--
.../hive/theta/ExcludeSketchUDFTest.java | 31 ++++++++---
.../hive/theta/IntersectSketchUDAFTest.java | 31 ++++++++---
.../hive/theta/IntersectSketchUDFTest.java | 29 ++++++++--
.../datasketches}/hive/theta/SampleSketchUDF.java | 29 ++++++++--
.../hive/theta/UnionSketchUDAFTest.java | 33 +++++++++---
.../hive/theta/UnionSketchUDFTest.java | 29 ++++++++--
...ublesSketchToEstimateAndErrorBoundsUDFTest.java | 24 +++++++--
.../ArrayOfDoublesSketchToEstimatesUDFTest.java | 24 +++++++--
.../tuple/ArrayOfDoublesSketchToMeansUDFTest.java | 24 +++++++--
...blesSketchToNumberOfRetainedEntriesUDFTest.java | 24 +++++++--
...rayOfDoublesSketchToQuantilesSketchUDFTest.java | 28 +++++++---
.../ArrayOfDoublesSketchToValuesUDTFTest.java | 25 +++++++--
.../ArrayOfDoublesSketchToVariancesUDFTest.java | 24 +++++++--
.../tuple/ArrayOfDoublesSketchesTTestUDFTest.java | 24 +++++++--
.../tuple/DataToArrayOfDoublesSketchUDAFTest.java | 32 +++++++----
.../tuple/DataToDoubleSummarySketchUDAFTest.java | 38 ++++++++-----
.../DataToDoubleSummaryWithModeSketchUDAFTest.java | 40 +++++++++-----
.../DoubleSummarySketchToEstimatesUDFTest.java | 28 +++++++---
.../DoubleSummarySketchToPercentileUDFTest.java | 28 +++++++---
.../tuple/UnionArrayOfDoublesSketchUDAFTest.java | 32 +++++++----
.../tuple/UnionDoubleSummarySketchUDAFTest.java | 38 ++++++++-----
.../UnionDoubleSummaryWithModeSketchUDAFTest.java | 40 +++++++++-----
219 files changed, 4662 insertions(+), 2173 deletions(-)
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/State.java b/src/main/java/com/yahoo/sketches/hive/cpc/State.java
deleted file mode 100644
index 836f3a5..0000000
--- a/src/main/java/com/yahoo/sketches/hive/cpc/State.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.cpc;
-
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
-
-import com.yahoo.sketches.cpc.CpcSketch;
-
-abstract class State extends AbstractAggregationBuffer {
-
- private int lgK_;
- private long seed_;
-
- void init(final int lgK, final long seed) {
- lgK_ = lgK;
- seed_ = seed;
- }
-
- int getLgK() {
- return lgK_;
- }
-
- long getSeed() {
- return seed_;
- }
-
- abstract boolean isInitialized();
-
- abstract CpcSketch getResult();
-
- abstract void reset();
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/UnionState.java b/src/main/java/com/yahoo/sketches/hive/cpc/UnionState.java
deleted file mode 100644
index 9912e32..0000000
--- a/src/main/java/com/yahoo/sketches/hive/cpc/UnionState.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.cpc;
-
-import com.yahoo.sketches.cpc.CpcSketch;
-import com.yahoo.sketches.cpc.CpcUnion;
-
-class UnionState extends State {
-
- private CpcUnion union_;
-
- @Override
- boolean isInitialized() {
- return union_ != null;
- }
-
- @Override
- void init(final int lgK, final long seed) {
- super.init(lgK, seed);
- union_ = new CpcUnion(lgK, seed);
- }
-
- void update(final CpcSketch sketch) {
- union_.update(sketch);
- }
-
- @Override
- CpcSketch getResult() {
- if (union_ == null) { return null; }
- return union_.getResult();
- }
-
- @Override
- void reset() {
- union_ = null;
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/package-info.java b/src/main/java/com/yahoo/sketches/hive/cpc/package-info.java
deleted file mode 100644
index eb646c8..0000000
--- a/src/main/java/com/yahoo/sketches/hive/cpc/package-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-/**
- * Hive UDFs for CPC sketches.
- *
- * @author Alexander Saydakov
- */
-package com.yahoo.sketches.hive.cpc;
diff --git a/src/main/java/com/yahoo/sketches/hive/frequencies/UnionStringsSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/frequencies/UnionStringsSketchUDAF.java
deleted file mode 100644
index e04b32e..0000000
--- a/src/main/java/com/yahoo/sketches/hive/frequencies/UnionStringsSketchUDAF.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.frequencies;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
-
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-
-@Description(name = "Union", value = "_FUNC_(sketch) - "
- + "Returns an ItemsSketch<String> in a serialized form as a binary blob."
- + " Input values must also be serialized sketches.")
-@SuppressWarnings("javadoc")
-public class UnionStringsSketchUDAF extends UnionItemsSketchUDAF<String> {
-
- @Override
- GenericUDAFEvaluator createEvaluator() {
- return new UnionStringsSketchEvaluator();
- }
-
- static class UnionStringsSketchEvaluator extends UnionItemsSketchEvaluator<String> {
-
- UnionStringsSketchEvaluator() {
- super(new ArrayOfStringsSerDe());
- }
-
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/frequencies/package-info.java b/src/main/java/com/yahoo/sketches/hive/frequencies/package-info.java
deleted file mode 100644
index deba6b0..0000000
--- a/src/main/java/com/yahoo/sketches/hive/frequencies/package-info.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc. Licensed under the terms of the Apache License 2.0. See LICENSE file
- * at the project root for terms.
- */
-
-/**
- * Hive UDFs for Frequent Items sketch.
- * This includes generic implementation in the form of abstract classes DataToItemsSketchUDAF
- * and UnionItemsSketchUDAF to be specialized for particular types of items.
- * An implementation for strings is provided: DataToStringsSketchUDAF and UnionStringsSketchUDAF.
- * GetFrequentItemsFromStringsSketchUDTF is to obtain results from sketches.
- *
- * @author Alexander Saydakov
- */
-package com.yahoo.sketches.hive.frequencies;
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/SketchToEstimateUDF.java b/src/main/java/com/yahoo/sketches/hive/hll/SketchToEstimateUDF.java
deleted file mode 100644
index 48502e4..0000000
--- a/src/main/java/com/yahoo/sketches/hive/hll/SketchToEstimateUDF.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.hll;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.hll.HllSketch;
-
-@Description(
- name = "SketchToEstimate",
- value = "_FUNC_(sketch)",
- extended = "Returns an estimate of unique count from a given HllSketch."
- + " The result is a double value.")
-@SuppressWarnings("javadoc")
-public class SketchToEstimateUDF extends UDF {
-
- /**
- * Get an estimate from a given HllSketch
- * @param serializedSketch HllSketch in a serialized binary form
- * @return estimate of unique count
- */
- public Double evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final HllSketch sketch = HllSketch.wrap(Memory.wrap(serializedSketch.getBytes()));
- return sketch.getEstimate();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/SketchToStringUDF.java b/src/main/java/com/yahoo/sketches/hive/hll/SketchToStringUDF.java
deleted file mode 100644
index 8bf5951..0000000
--- a/src/main/java/com/yahoo/sketches/hive/hll/SketchToStringUDF.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.hll;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.hll.HllSketch;
-
-@Description(
- name = "SketchToString",
- value = "_FUNC_(sketch)",
- extended = "Returns an human-readable summary of a given HllSketch.")
-@SuppressWarnings("javadoc")
-public class SketchToStringUDF extends UDF {
-
- /**
- * Get a human-readable summary of a given HllSketch
- * @param serializedSketch HllSketch in a serialized binary form
- * @return text summary
- */
- public String evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final HllSketch sketch = HllSketch.wrap(Memory.wrap(serializedSketch.getBytes()));
- return sketch.toString();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/State.java b/src/main/java/com/yahoo/sketches/hive/hll/State.java
deleted file mode 100644
index a3e279e..0000000
--- a/src/main/java/com/yahoo/sketches/hive/hll/State.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.hll;
-
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
-import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
-
-import com.yahoo.sketches.hll.HllSketch;
-import com.yahoo.sketches.hll.TgtHllType;
-
-abstract class State extends AbstractAggregationBuffer {
-
- private int lgK_;
- private TgtHllType type_;
-
- void init(final int lgK, final TgtHllType type) {
- lgK_ = lgK;
- type_ = type;
- }
-
- int getLgK() {
- return lgK_;
- }
-
- TgtHllType getType() {
- return type_;
- }
-
- abstract boolean isInitialized();
-
- abstract void update(final Object data, final PrimitiveObjectInspector keyObjectInspector);
-
- abstract HllSketch getResult();
-
- abstract void reset();
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/package-info.java b/src/main/java/com/yahoo/sketches/hive/hll/package-info.java
deleted file mode 100644
index 605aebe..0000000
--- a/src/main/java/com/yahoo/sketches/hive/hll/package-info.java
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * Copyright 2017, Yahoo! Inc. Licensed under the terms of the Apache License 2.0. See LICENSE file
- * at the project root for terms.
- */
-/**
- * Hive UDFs for HLL sketches.
- *
- * @author Alexander Saydakov
- */
-package com.yahoo.sketches.hive.hll;
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/GetNUDF.java b/src/main/java/com/yahoo/sketches/hive/kll/GetNUDF.java
deleted file mode 100644
index 7dddcb0..0000000
--- a/src/main/java/com/yahoo/sketches/hive/kll/GetNUDF.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.kll;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
-@Description(name = "GetN", value = "_FUNC_(sketch)",
-extended = " Returns the total number of observed input values (stream length) from a given KllFloatsSketch.")
-@SuppressWarnings("javadoc")
-public class GetNUDF extends UDF {
-
- /**
- * Returns N from a given sketch
- * @param serializedSketch serialized sketch
- * @return stream length
- */
- public Long evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final KllFloatsSketch sketch = KllFloatsSketch.heapify(Memory.wrap(serializedSketch.getBytes()));
- return sketch.getN();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/SketchState.java b/src/main/java/com/yahoo/sketches/hive/kll/SketchState.java
deleted file mode 100644
index c5feb2d..0000000
--- a/src/main/java/com/yahoo/sketches/hive/kll/SketchState.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.kll;
-
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
-
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
-class SketchState extends AbstractAggregationBuffer {
-
- private KllFloatsSketch state_;
-
- // initialization is needed in the first phase (iterate) only
- void init() {
- state_ = new KllFloatsSketch();
- }
-
- void init(final int k) {
- state_ = new KllFloatsSketch(k);
- }
-
- boolean isInitialized() {
- return state_ != null;
- }
-
- void update(final float value) {
- state_.update(value);
- }
-
- void update(final KllFloatsSketch sketch) {
- if (state_ == null) {
- state_ = sketch;
- } else {
- state_.merge(sketch);
- }
- }
-
- public KllFloatsSketch getResult() {
- return state_;
- }
-
- void reset() {
- state_ = null;
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/SketchToStringUDF.java b/src/main/java/com/yahoo/sketches/hive/kll/SketchToStringUDF.java
deleted file mode 100644
index 2c8ef6e..0000000
--- a/src/main/java/com/yahoo/sketches/hive/kll/SketchToStringUDF.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.kll;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
-@Description(name = "SketchToString", value = "_FUNC_(sketch)",
-extended = " Returns a human-readable summary of a given KllFloatsSketch.")
-@SuppressWarnings("javadoc")
-public class SketchToStringUDF extends UDF {
-
- /**
- * Returns a summary of a given sketch
- * @param serializedSketch serialized sketch
- * @return text summary
- */
- public String evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final KllFloatsSketch sketch = KllFloatsSketch.heapify(Memory.wrap(serializedSketch.getBytes()));
- return sketch.toString();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/package-info.java b/src/main/java/com/yahoo/sketches/hive/kll/package-info.java
deleted file mode 100644
index b74f994..0000000
--- a/src/main/java/com/yahoo/sketches/hive/kll/package-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-/**
- * Hive UDFs for KllFloatsSketch sketch.
- *
- * @author Alexander Saydakov
- */
-package com.yahoo.sketches.hive.kll;
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/DoublesSketchToStringUDF.java b/src/main/java/com/yahoo/sketches/hive/quantiles/DoublesSketchToStringUDF.java
deleted file mode 100644
index 67fdf77..0000000
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/DoublesSketchToStringUDF.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-
-@Description(name = "ToString", value = "_FUNC_(sketch)",
-extended = " Returns a human-readable summary of a given DoublesSketch.")
-@SuppressWarnings("javadoc")
-public class DoublesSketchToStringUDF extends UDF {
-
- /**
- * Returns a human-readable summary of a given sketch
- * @param serializedSketch serialized sketch
- * @return text summary
- */
- public String evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final DoublesSketch sketch = DoublesSketch.wrap(Memory.wrap(serializedSketch.getBytes()));
- return sketch.toString();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetKFromDoublesSketchUDF.java b/src/main/java/com/yahoo/sketches/hive/quantiles/GetKFromDoublesSketchUDF.java
deleted file mode 100644
index a4374ee..0000000
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetKFromDoublesSketchUDF.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-
-@Description(name = "GetK", value = "_FUNC_(sketch)",
-extended = " Returns parameter K from a given DoublesSketch sketch.")
-@SuppressWarnings("javadoc")
-public class GetKFromDoublesSketchUDF extends UDF {
-
- /**
- * Returns parameter K from a given sketch
- * @param serializedSketch serialized sketch
- * @return parameter K
- */
- public Integer evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final DoublesSketch sketch = DoublesSketch.wrap(Memory.wrap(serializedSketch.getBytes()));
- return sketch.getK();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetKFromStringsSketchUDF.java b/src/main/java/com/yahoo/sketches/hive/quantiles/GetKFromStringsSketchUDF.java
deleted file mode 100644
index 9b0523c..0000000
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetKFromStringsSketchUDF.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import java.util.Comparator;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
-@Description(name = "GetK", value = "_FUNC_(sketch)",
-extended = " Returns parameter K from a given ItemsSketch<String> sketch.")
-@SuppressWarnings("javadoc")
-public class GetKFromStringsSketchUDF extends UDF {
-
- /**
- * Returns parameter K from a given sketch
- * @param serializedSketch serialized sketch
- * @return parameter K
- */
- public Integer evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final ItemsSketch<String> sketch = ItemsSketch.getInstance(
- Memory.wrap(serializedSketch.getBytes()),
- Comparator.naturalOrder(),
- new ArrayOfStringsSerDe()
- );
- return sketch.getK();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetNFromDoublesSketchUDF.java b/src/main/java/com/yahoo/sketches/hive/quantiles/GetNFromDoublesSketchUDF.java
deleted file mode 100644
index b8b619d..0000000
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetNFromDoublesSketchUDF.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-
-@Description(name = "GetN", value = "_FUNC_(sketch)",
-extended = " Returns the total number of observed input values (stream length) from a given DoublesSketch.")
-@SuppressWarnings("javadoc")
-public class GetNFromDoublesSketchUDF extends UDF {
-
- /**
- * Returns N from a given sketch
- * @param serializedSketch serialized sketch
- * @return stream length
- */
- public Long evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final DoublesSketch sketch = DoublesSketch.wrap(Memory.wrap(serializedSketch.getBytes()));
- return sketch.getN();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetNFromStringsSketchUDF.java b/src/main/java/com/yahoo/sketches/hive/quantiles/GetNFromStringsSketchUDF.java
deleted file mode 100644
index f625216..0000000
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetNFromStringsSketchUDF.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import java.util.Comparator;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
-@Description(name = "GetN", value = "_FUNC_(sketch)",
- extended = " Returns the total number of observed input values (stream length) "
- + "from a given ItemsSketch<String>.")
-@SuppressWarnings("javadoc")
-public class GetNFromStringsSketchUDF extends UDF {
-
- /**
- * Returns N from a given sketch
- * @param serializedSketch serialized sketch
- * @return stream length
- */
- public Long evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final ItemsSketch<String> sketch = ItemsSketch.getInstance(
- Memory.wrap(serializedSketch.getBytes()),
- Comparator.naturalOrder(),
- new ArrayOfStringsSerDe()
- );
- return sketch.getN();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/StringsSketchToStringUDF.java b/src/main/java/com/yahoo/sketches/hive/quantiles/StringsSketchToStringUDF.java
deleted file mode 100644
index 3487ae9..0000000
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/StringsSketchToStringUDF.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import java.util.Comparator;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
-@Description(name = "ToString", value = "_FUNC_(sketch)",
-extended = " Returns a human-readable summary of a given ItemsSketch<String>.")
-@SuppressWarnings("javadoc")
-public class StringsSketchToStringUDF extends UDF {
-
- /**
- * Returns a human-readable summary of a given sketch
- * @param serializedSketch serialized sketch
- * @return text summary
- */
- public String evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final ItemsSketch<String> sketch = ItemsSketch.getInstance(
- Memory.wrap(serializedSketch.getBytes()),
- Comparator.naturalOrder(),
- new ArrayOfStringsSerDe()
- );
- return sketch.toString();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/UnionStringsSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/quantiles/UnionStringsSketchUDAF.java
deleted file mode 100644
index 11f1c65..0000000
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/UnionStringsSketchUDAF.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import java.util.Comparator;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
-
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-
-@Description(name = "Union", value = "_FUNC_(sketch) - "
- + "Returns an ItemsSketch<String> in a serialized form as a binary blob."
- + " Input values must also be serialized sketches.")
-@SuppressWarnings("javadoc")
-public class UnionStringsSketchUDAF extends UnionItemsSketchUDAF<String> {
-
- @Override
- public GenericUDAFEvaluator createEvaluator() {
- return new UnionStringsSketchEvaluator();
- }
-
- static class UnionStringsSketchEvaluator extends UnionEvaluator<String> {
-
- UnionStringsSketchEvaluator() {
- super(Comparator.naturalOrder(), new ArrayOfStringsSerDe());
- }
-
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/Util.java b/src/main/java/com/yahoo/sketches/hive/quantiles/Util.java
deleted file mode 100644
index ddd2690..0000000
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/Util.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import java.util.ArrayList;
-import java.util.List;
-
-final class Util {
-
- static double[] objectsToPrimitives(final Double[] array) {
- final double[] result = new double[array.length];
- for (int i = 0; i < array.length; i++) {
- result[i] = array[i];
- }
- return result;
- }
-
- static List<Double> primitivesToList(final double[] array) {
- final List<Double> result = new ArrayList<Double>(array.length);
- for (double item: array) { result.add(item); }
- return result;
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/package-info.java b/src/main/java/com/yahoo/sketches/hive/quantiles/package-info.java
deleted file mode 100644
index 7fe33a8..0000000
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc. Licensed under the terms of the Apache License 2.0. See LICENSE file
- * at the project root for terms.
- */
-
-/**
- * Hive UDFs for Quantiles sketches.
- * This includes UDFs for generic ItemsSketch and specialized DoublesSketch.
- *
- * <p>The generic implementation is in the form of abstract classes DataToItemsSketchUDAF and
- * UnionItemsSketchUDAF to be specialized for particular types of items.
- * An implementation for strings is provided: DataToStringsSketchUDAF, UnionStringsSketchUDAF,
- * plus UDFs to obtain the results from sketches:
- * GetQuantileFromStringsSketchUDF, GetQuantilesFromStringsSketchUDF and GetPmfFromStringsSketchUDF.
- *
- * <p>Support for DoublesSketch: DataToDoublesSketchUDAF, UnionDoublesSketchUDAF,
- * GetQuantileFromDoublesSketchUDF, GetQuantilesFromDoublesSketchUDF, GetPmfFromDoublesSketchUDF
- *
- * @author Alexander Saydakov
- */
-package com.yahoo.sketches.hive.quantiles;
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/package-info.java b/src/main/java/com/yahoo/sketches/hive/theta/package-info.java
deleted file mode 100644
index d66c7fd..0000000
--- a/src/main/java/com/yahoo/sketches/hive/theta/package-info.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-/**
- * Hive UDFs and UDAFs for Theta sketch.
- *
- * @author Will Lauer
- * @author Alexander Saydakov
- */
-package com.yahoo.sketches.hive.theta;
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchStats.java b/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchStats.java
deleted file mode 100644
index a2d3c24..0000000
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchStats.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.tuple;
-
-import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
-
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketchIterator;
-
-class ArrayOfDoublesSketchStats {
-
- /**
- * Convert sketch to summary statistics.
- *
- * @param sketch ArrayOfDoublesSketch to convert to summary statistics.
- * @return An array of SummaryStatistics.
- */
- static SummaryStatistics[] sketchToSummaryStatistics(final ArrayOfDoublesSketch sketch) {
- final SummaryStatistics[] summaryStatistics = new SummaryStatistics[sketch.getNumValues()];
- for (int i = 0; i < sketch.getNumValues(); i++) {
- summaryStatistics[i] = new SummaryStatistics();
- }
- final ArrayOfDoublesSketchIterator it = sketch.iterator();
- while (it.next()) {
- final double[] values = it.getValues();
- for (int i = 0; i < it.getValues().length; i++) {
- summaryStatistics[i].addValue(values[i]);
- }
- }
- return summaryStatistics;
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDF.java b/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDF.java
deleted file mode 100644
index 5db42e3..0000000
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDF.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.tuple;
-
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDF;
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;
-
-@Description(
- name = "ArrayOfDoublesSketchToNumberOfRetainedEntries",
- value = "_FUNC_(sketch)",
- extended = "Returns the number of retained entries from a given ArrayOfDoublesSketch."
- + " The result is an integer value.")
-@SuppressWarnings("javadoc")
-public class ArrayOfDoublesSketchToNumberOfRetainedEntriesUDF extends UDF {
-
- /**
- * Get number of retained entries from a given ArrayOfDoublesSketch
- * @param serializedSketch ArrayOfDoublesSketch in as serialized binary
- * @return number of retained entries
- */
- public Integer evaluate(final BytesWritable serializedSketch) {
- if (serializedSketch == null) { return null; }
- final ArrayOfDoublesSketch sketch = ArrayOfDoublesSketches.wrapSketch(
- Memory.wrap(serializedSketch.getBytes()));
- return sketch.getRetainedEntries();
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesState.java b/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesState.java
deleted file mode 100644
index de22fb9..0000000
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesState.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.tuple;
-
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
-
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-
-abstract class ArrayOfDoublesState extends AbstractAggregationBuffer {
-
- private int nominalNumEntries_;
- private int numValues_;
-
- void init(final int numNominalEntries, final int numValues) {
- nominalNumEntries_ = numNominalEntries;
- numValues_ = numValues;
- }
-
- int getNominalNumEntries() {
- return nominalNumEntries_;
- }
-
- int getNumValues() {
- return numValues_;
- }
-
- abstract ArrayOfDoublesSketch getResult();
-
- abstract void reset();
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesUnionState.java b/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesUnionState.java
deleted file mode 100644
index fb369c7..0000000
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesUnionState.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.tuple;
-
-import com.yahoo.sketches.tuple.ArrayOfDoublesSetOperationBuilder;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUnion;
-
-class ArrayOfDoublesUnionState extends ArrayOfDoublesState {
-
- private ArrayOfDoublesUnion union_;
-
- boolean isInitialized() {
- return union_ != null;
- }
-
- @Override
- void init(final int nominalNumEntries, final int numValues) {
- super.init(nominalNumEntries, numValues);
- union_ = new ArrayOfDoublesSetOperationBuilder()
- .setNominalEntries(nominalNumEntries).setNumberOfValues(numValues).buildUnion();
- }
-
- void update(final ArrayOfDoublesSketch sketch) {
- union_.update(sketch);
- }
-
- @Override
- ArrayOfDoublesSketch getResult() {
- if (union_ == null) { return null; }
- return union_.getResult();
- }
-
- @Override
- void reset() {
- union_ = null;
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/State.java b/src/main/java/com/yahoo/sketches/hive/tuple/State.java
deleted file mode 100644
index 62f07fa..0000000
--- a/src/main/java/com/yahoo/sketches/hive/tuple/State.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.tuple;
-
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
-
-import com.yahoo.sketches.tuple.Sketch;
-import com.yahoo.sketches.tuple.Summary;
-
-abstract class State<S extends Summary> extends AbstractAggregationBuffer {
-
- private int nominalNumEntries_;
-
- void init(final int nominalNumEntries) {
- nominalNumEntries_ = nominalNumEntries;
- }
-
- int getNominalNumEntries() {
- return nominalNumEntries_;
- }
-
- abstract Sketch<S> getResult();
-
- abstract void reset();
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/UnionState.java b/src/main/java/com/yahoo/sketches/hive/tuple/UnionState.java
deleted file mode 100644
index 0ca1624..0000000
--- a/src/main/java/com/yahoo/sketches/hive/tuple/UnionState.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.tuple;
-
-import com.yahoo.sketches.tuple.Sketch;
-import com.yahoo.sketches.tuple.Summary;
-import com.yahoo.sketches.tuple.SummarySetOperations;
-import com.yahoo.sketches.tuple.Union;
-
-class UnionState<S extends Summary> extends State<S> {
-
- private Union<S> union_;
-
- boolean isInitialized() {
- return union_ != null;
- }
-
- void init(final int nominalNumEntries, final SummarySetOperations<S> summarySetOps) {
- super.init(nominalNumEntries);
- union_ = new Union<S>(nominalNumEntries, summarySetOps);
- }
-
- void update(final Sketch<S> sketch) {
- union_.update(sketch);
- }
-
- @Override
- Sketch<S> getResult() {
- if (union_ == null) { return null; }
- return union_.getResult();
- }
-
- @Override
- void reset() {
- union_ = null;
- }
-
-}
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/DataToSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/cpc/DataToSketchUDAF.java
similarity index 89%
rename from src/main/java/com/yahoo/sketches/hive/cpc/DataToSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/cpc/DataToSketchUDAF.java
index d326941..732a5b8 100644
--- a/src/main/java/com/yahoo/sketches/hive/cpc/DataToSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/cpc/DataToSketchUDAF.java
@@ -1,11 +1,25 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/GetEstimateAndErrorBoundsUDF.java b/src/main/java/org/apache/datasketches/hive/cpc/GetEstimateAndErrorBoundsUDF.java
similarity index 69%
rename from src/main/java/com/yahoo/sketches/hive/cpc/GetEstimateAndErrorBoundsUDF.java
rename to src/main/java/org/apache/datasketches/hive/cpc/GetEstimateAndErrorBoundsUDF.java
index 4c5922c..68113ad 100644
--- a/src/main/java/com/yahoo/sketches/hive/cpc/GetEstimateAndErrorBoundsUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/cpc/GetEstimateAndErrorBoundsUDF.java
@@ -1,22 +1,35 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
import java.util.List;
+import org.apache.datasketches.cpc.CpcSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.cpc.CpcSketch;
-
@Description(
name = "GetEstimateAndBounds",
value = "_FUNC_(sketch, kappa, seed)",
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/GetEstimateUDF.java b/src/main/java/org/apache/datasketches/hive/cpc/GetEstimateUDF.java
similarity index 54%
rename from src/main/java/com/yahoo/sketches/hive/cpc/GetEstimateUDF.java
rename to src/main/java/org/apache/datasketches/hive/cpc/GetEstimateUDF.java
index dcfb0e0..6b53711 100644
--- a/src/main/java/com/yahoo/sketches/hive/cpc/GetEstimateUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/cpc/GetEstimateUDF.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
+import org.apache.datasketches.cpc.CpcSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.cpc.CpcSketch;
-
@Description(
name = "GetEstimate",
value = "_FUNC_(sketch)",
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ObjectInspectorValidator.java b/src/main/java/org/apache/datasketches/hive/cpc/ObjectInspectorValidator.java
similarity index 69%
rename from src/main/java/com/yahoo/sketches/hive/tuple/ObjectInspectorValidator.java
rename to src/main/java/org/apache/datasketches/hive/cpc/ObjectInspectorValidator.java
index 3518e2a..22ff57d 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ObjectInspectorValidator.java
+++ b/src/main/java/org/apache/datasketches/hive/cpc/ObjectInspectorValidator.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc. Licensed under the terms of the Apache License 2.0. See LICENSE file
- * at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.cpc;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/SketchEvaluator.java b/src/main/java/org/apache/datasketches/hive/cpc/SketchEvaluator.java
similarity index 76%
rename from src/main/java/com/yahoo/sketches/hive/cpc/SketchEvaluator.java
rename to src/main/java/org/apache/datasketches/hive/cpc/SketchEvaluator.java
index 10058a5..f7ce24f 100644
--- a/src/main/java/com/yahoo/sketches/hive/cpc/SketchEvaluator.java
+++ b/src/main/java/org/apache/datasketches/hive/cpc/SketchEvaluator.java
@@ -1,12 +1,28 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
import java.util.Arrays;
+import org.apache.datasketches.cpc.CpcSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
@@ -15,9 +31,6 @@ import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.cpc.CpcSketch;
-
// This class implements functionality common to DataToSketch and UnionSketch
abstract class SketchEvaluator extends GenericUDAFEvaluator {
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/SketchState.java b/src/main/java/org/apache/datasketches/hive/cpc/SketchState.java
similarity index 72%
rename from src/main/java/com/yahoo/sketches/hive/cpc/SketchState.java
rename to src/main/java/org/apache/datasketches/hive/cpc/SketchState.java
index 8d73db1..932880c 100644
--- a/src/main/java/com/yahoo/sketches/hive/cpc/SketchState.java
+++ b/src/main/java/org/apache/datasketches/hive/cpc/SketchState.java
@@ -1,15 +1,28 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
+import org.apache.datasketches.cpc.CpcSketch;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.sketches.cpc.CpcSketch;
-
class SketchState extends State {
private CpcSketch sketch_;
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/SketchToStringUDF.java b/src/main/java/org/apache/datasketches/hive/cpc/SketchToStringUDF.java
similarity index 53%
rename from src/main/java/com/yahoo/sketches/hive/cpc/SketchToStringUDF.java
rename to src/main/java/org/apache/datasketches/hive/cpc/SketchToStringUDF.java
index 66bd6a7..e058c65 100644
--- a/src/main/java/com/yahoo/sketches/hive/cpc/SketchToStringUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/cpc/SketchToStringUDF.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
+import org.apache.datasketches.cpc.CpcSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.cpc.CpcSketch;
-
@Description(
name = "SketchToString",
value = "_FUNC_(sketch, seed)",
diff --git a/src/main/java/org/apache/datasketches/hive/cpc/State.java b/src/main/java/org/apache/datasketches/hive/cpc/State.java
new file mode 100644
index 0000000..f3b9e1e
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/cpc/State.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.cpc;
+
+import org.apache.datasketches.cpc.CpcSketch;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
+
+abstract class State extends AbstractAggregationBuffer {
+
+ private int lgK_;
+ private long seed_;
+
+ void init(final int lgK, final long seed) {
+ lgK_ = lgK;
+ seed_ = seed;
+ }
+
+ int getLgK() {
+ return lgK_;
+ }
+
+ long getSeed() {
+ return seed_;
+ }
+
+ abstract boolean isInitialized();
+
+ abstract CpcSketch getResult();
+
+ abstract void reset();
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/UnionSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/cpc/UnionSketchUDAF.java
similarity index 88%
rename from src/main/java/com/yahoo/sketches/hive/cpc/UnionSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/cpc/UnionSketchUDAF.java
index 058435d..7e22c3d 100644
--- a/src/main/java/com/yahoo/sketches/hive/cpc/UnionSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/cpc/UnionSketchUDAF.java
@@ -1,14 +1,30 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
+import org.apache.datasketches.cpc.CpcSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
@@ -26,9 +42,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StandardStructObjectInspect
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.cpc.CpcSketch;
-
/**
* Hive UDAF to compute union of HllSketch objects
*/
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/UnionSketchUDF.java b/src/main/java/org/apache/datasketches/hive/cpc/UnionSketchUDF.java
similarity index 65%
rename from src/main/java/com/yahoo/sketches/hive/cpc/UnionSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/cpc/UnionSketchUDF.java
index 7d82ac8..2fb990c 100644
--- a/src/main/java/com/yahoo/sketches/hive/cpc/UnionSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/cpc/UnionSketchUDF.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
+import org.apache.datasketches.cpc.CpcSketch;
+import org.apache.datasketches.cpc.CpcUnion;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.cpc.CpcSketch;
-import com.yahoo.sketches.cpc.CpcUnion;
-
/**
* Hive union sketch UDF.
*/
diff --git a/src/main/java/org/apache/datasketches/hive/cpc/UnionState.java b/src/main/java/org/apache/datasketches/hive/cpc/UnionState.java
new file mode 100644
index 0000000..4ca1006
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/cpc/UnionState.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.cpc;
+
+import org.apache.datasketches.cpc.CpcSketch;
+import org.apache.datasketches.cpc.CpcUnion;
+
+class UnionState extends State {
+
+ private CpcUnion union_;
+
+ @Override
+ boolean isInitialized() {
+ return union_ != null;
+ }
+
+ @Override
+ void init(final int lgK, final long seed) {
+ super.init(lgK, seed);
+ union_ = new CpcUnion(lgK, seed);
+ }
+
+ void update(final CpcSketch sketch) {
+ union_.update(sketch);
+ }
+
+ @Override
+ CpcSketch getResult() {
+ if (union_ == null) { return null; }
+ return union_.getResult();
+ }
+
+ @Override
+ void reset() {
+ union_ = null;
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/cpc/package-info.java b/src/main/java/org/apache/datasketches/hive/cpc/package-info.java
new file mode 100644
index 0000000..8f19cf1
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/cpc/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hive UDFs for CPC sketches.
+ *
+ * @author Alexander Saydakov
+ */
+package org.apache.datasketches.hive.cpc;
diff --git a/src/main/java/com/yahoo/sketches/hive/frequencies/DataToItemsSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/frequencies/DataToItemsSketchUDAF.java
similarity index 80%
rename from src/main/java/com/yahoo/sketches/hive/frequencies/DataToItemsSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/frequencies/DataToItemsSketchUDAF.java
index 3b9edcc..93da5d6 100644
--- a/src/main/java/com/yahoo/sketches/hive/frequencies/DataToItemsSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/frequencies/DataToItemsSketchUDAF.java
@@ -1,10 +1,25 @@
/*
- * Copyright 2016, Yahoo! Inc. Licensed under the terms of the Apache License 2.0. See LICENSE file
- * at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.frequencies;
+package org.apache.datasketches.hive.frequencies;
+import org.apache.datasketches.ArrayOfItemsSerDe;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -16,8 +31,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-
/**
* This is a generic implementation to be specialized in subclasses
* @param <T> type of item
diff --git a/src/main/java/com/yahoo/sketches/hive/frequencies/DataToStringsSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/frequencies/DataToStringsSketchUDAF.java
similarity index 65%
rename from src/main/java/com/yahoo/sketches/hive/frequencies/DataToStringsSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/frequencies/DataToStringsSketchUDAF.java
index b863138..39d8303 100644
--- a/src/main/java/com/yahoo/sketches/hive/frequencies/DataToStringsSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/frequencies/DataToStringsSketchUDAF.java
@@ -1,10 +1,25 @@
/*
- * Copyright 2016, Yahoo! Inc. Licensed under the terms of the Apache License 2.0. See LICENSE file
- * at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.frequencies;
+package org.apache.datasketches.hive.frequencies;
+import org.apache.datasketches.ArrayOfStringsSerDe;
import org.apache.hadoop.hive.common.type.HiveChar;
import org.apache.hadoop.hive.common.type.HiveVarchar;
import org.apache.hadoop.hive.ql.exec.Description;
@@ -13,8 +28,6 @@ import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-
@Description(name = "DataToSketch", value = "_FUNC_(value, maxMapSize) - "
+ "Returns an ItemsSketch<String> in a serialized form as a binary blob."
+ " Values must be of string type."
diff --git a/src/main/java/com/yahoo/sketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTF.java b/src/main/java/org/apache/datasketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTF.java
similarity index 79%
rename from src/main/java/com/yahoo/sketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTF.java
rename to src/main/java/org/apache/datasketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTF.java
index 601f755..45cf09a 100644
--- a/src/main/java/com/yahoo/sketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTF.java
+++ b/src/main/java/org/apache/datasketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTF.java
@@ -1,12 +1,30 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.frequencies;
+package org.apache.datasketches.hive.frequencies;
import java.util.Arrays;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.frequencies.ErrorType;
+import org.apache.datasketches.frequencies.ItemsSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
@@ -19,11 +37,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.frequencies.ErrorType;
-import com.yahoo.sketches.frequencies.ItemsSketch;
-
@Description(name = "GetFrequentItems", value = "_FUNC_(sketch, errorType) - "
+ "Returns a list of frequent items in descending order by estimated frequency."
+ " Error type is optional and must be one of the following: "
diff --git a/src/main/java/com/yahoo/sketches/hive/frequencies/ItemsEvaluator.java b/src/main/java/org/apache/datasketches/hive/frequencies/ItemsEvaluator.java
similarity index 71%
rename from src/main/java/com/yahoo/sketches/hive/frequencies/ItemsEvaluator.java
rename to src/main/java/org/apache/datasketches/hive/frequencies/ItemsEvaluator.java
index 0ddf894..0ca7ee9 100644
--- a/src/main/java/com/yahoo/sketches/hive/frequencies/ItemsEvaluator.java
+++ b/src/main/java/org/apache/datasketches/hive/frequencies/ItemsEvaluator.java
@@ -1,10 +1,26 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.frequencies;
+package org.apache.datasketches.hive.frequencies;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.frequencies.ItemsSketch;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -13,9 +29,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.Pr
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.frequencies.ItemsSketch;
-
abstract class ItemsEvaluator<T> extends GenericUDAFEvaluator {
private final ArrayOfItemsSerDe<T> serDe_;
@@ -70,7 +83,7 @@ abstract class ItemsEvaluator<T> extends GenericUDAFEvaluator {
@SuppressWarnings("deprecation")
@Override
public AggregationBuffer getNewAggregationBuffer() throws HiveException {
- return new ItemsState<T>(serDe_);
+ return new ItemsState<>(serDe_);
}
}
diff --git a/src/main/java/com/yahoo/sketches/hive/frequencies/ItemsState.java b/src/main/java/org/apache/datasketches/hive/frequencies/ItemsState.java
similarity index 50%
rename from src/main/java/com/yahoo/sketches/hive/frequencies/ItemsState.java
rename to src/main/java/org/apache/datasketches/hive/frequencies/ItemsState.java
index 4f4c920..965e928 100644
--- a/src/main/java/com/yahoo/sketches/hive/frequencies/ItemsState.java
+++ b/src/main/java/org/apache/datasketches/hive/frequencies/ItemsState.java
@@ -1,16 +1,29 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.frequencies;
+package org.apache.datasketches.hive.frequencies;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.frequencies.ItemsSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.frequencies.ItemsSketch;
-
class ItemsState<T> extends AbstractAggregationBuffer {
private int maxMapSize_;
@@ -25,7 +38,7 @@ class ItemsState<T> extends AbstractAggregationBuffer {
// not needed for merging sketches using update(sketch)
void init(final int maxMapSize) {
maxMapSize_ = maxMapSize;
- sketch = new ItemsSketch<T>(maxMapSize_);
+ sketch = new ItemsSketch<>(maxMapSize_);
}
boolean isInitialized() {
diff --git a/src/main/java/com/yahoo/sketches/hive/frequencies/UnionItemsSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/frequencies/UnionItemsSketchUDAF.java
similarity index 70%
rename from src/main/java/com/yahoo/sketches/hive/frequencies/UnionItemsSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/frequencies/UnionItemsSketchUDAF.java
index 3866863..285350b 100644
--- a/src/main/java/com/yahoo/sketches/hive/frequencies/UnionItemsSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/frequencies/UnionItemsSketchUDAF.java
@@ -1,10 +1,25 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.frequencies;
+package org.apache.datasketches.hive.frequencies;
+import org.apache.datasketches.ArrayOfItemsSerDe;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -15,8 +30,6 @@ import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFParameterInfo;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-
/**
* This is a generic implementation to be specialized in subclasses
* @param <T> type of item
diff --git a/src/main/java/org/apache/datasketches/hive/frequencies/UnionStringsSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/frequencies/UnionStringsSketchUDAF.java
new file mode 100644
index 0000000..02f4cc8
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/frequencies/UnionStringsSketchUDAF.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.frequencies;
+
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
+
+@Description(name = "Union", value = "_FUNC_(sketch) - "
+ + "Returns an ItemsSketch<String> in a serialized form as a binary blob."
+ + " Input values must also be serialized sketches.")
+@SuppressWarnings("javadoc")
+public class UnionStringsSketchUDAF extends UnionItemsSketchUDAF<String> {
+
+ @Override
+ GenericUDAFEvaluator createEvaluator() {
+ return new UnionStringsSketchEvaluator();
+ }
+
+ static class UnionStringsSketchEvaluator extends UnionItemsSketchEvaluator<String> {
+
+ UnionStringsSketchEvaluator() {
+ super(new ArrayOfStringsSerDe());
+ }
+
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/frequencies/package-info.java b/src/main/java/org/apache/datasketches/hive/frequencies/package-info.java
new file mode 100644
index 0000000..9d2de28
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/frequencies/package-info.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hive UDFs for Frequent Items sketch.
+ * This includes generic implementation in the form of abstract classes DataToItemsSketchUDAF
+ * and UnionItemsSketchUDAF to be specialized for particular types of items.
+ * An implementation for strings is provided: DataToStringsSketchUDAF and UnionStringsSketchUDAF.
+ * GetFrequentItemsFromStringsSketchUDTF is to obtain results from sketches.
+ *
+ * @author Alexander Saydakov
+ */
+package org.apache.datasketches.hive.frequencies;
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/DataToSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/hll/DataToSketchUDAF.java
similarity index 90%
rename from src/main/java/com/yahoo/sketches/hive/hll/DataToSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/hll/DataToSketchUDAF.java
index ac6c563..e86aec9 100644
--- a/src/main/java/com/yahoo/sketches/hive/hll/DataToSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/hll/DataToSketchUDAF.java
@@ -1,12 +1,27 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
import java.util.Arrays;
+import org.apache.datasketches.hll.TgtHllType;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
@@ -24,8 +39,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.sketches.hll.TgtHllType;
-
/**
* Hive UDAF to create an HllSketch from raw data.
*/
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/ObjectInspectorValidator.java b/src/main/java/org/apache/datasketches/hive/hll/ObjectInspectorValidator.java
similarity index 69%
rename from src/main/java/com/yahoo/sketches/hive/hll/ObjectInspectorValidator.java
rename to src/main/java/org/apache/datasketches/hive/hll/ObjectInspectorValidator.java
index 0d04b2e..e885eee 100644
--- a/src/main/java/com/yahoo/sketches/hive/hll/ObjectInspectorValidator.java
+++ b/src/main/java/org/apache/datasketches/hive/hll/ObjectInspectorValidator.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/SketchEvaluator.java b/src/main/java/org/apache/datasketches/hive/hll/SketchEvaluator.java
similarity index 75%
rename from src/main/java/com/yahoo/sketches/hive/hll/SketchEvaluator.java
rename to src/main/java/org/apache/datasketches/hive/hll/SketchEvaluator.java
index a73e922..c41265a 100644
--- a/src/main/java/com/yahoo/sketches/hive/hll/SketchEvaluator.java
+++ b/src/main/java/org/apache/datasketches/hive/hll/SketchEvaluator.java
@@ -1,12 +1,29 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
import java.util.Arrays;
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.hll.TgtHllType;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
@@ -15,10 +32,6 @@ import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.hll.HllSketch;
-import com.yahoo.sketches.hll.TgtHllType;
-
// This class implements functionality common to DataToSketch and UnionSketch
abstract class SketchEvaluator extends GenericUDAFEvaluator {
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/SketchState.java b/src/main/java/org/apache/datasketches/hive/hll/SketchState.java
similarity index 71%
rename from src/main/java/com/yahoo/sketches/hive/hll/SketchState.java
rename to src/main/java/org/apache/datasketches/hive/hll/SketchState.java
index ca4aec1..5da2f49 100644
--- a/src/main/java/com/yahoo/sketches/hive/hll/SketchState.java
+++ b/src/main/java/org/apache/datasketches/hive/hll/SketchState.java
@@ -1,16 +1,29 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.hll.TgtHllType;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.sketches.hll.HllSketch;
-import com.yahoo.sketches.hll.TgtHllType;
-
class SketchState extends State {
private HllSketch sketch_;
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/SketchToEstimateAndErrorBoundsUDF.java b/src/main/java/org/apache/datasketches/hive/hll/SketchToEstimateAndErrorBoundsUDF.java
similarity index 63%
rename from src/main/java/com/yahoo/sketches/hive/hll/SketchToEstimateAndErrorBoundsUDF.java
rename to src/main/java/org/apache/datasketches/hive/hll/SketchToEstimateAndErrorBoundsUDF.java
index 4ef2b72..905aaa9 100644
--- a/src/main/java/com/yahoo/sketches/hive/hll/SketchToEstimateAndErrorBoundsUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/hll/SketchToEstimateAndErrorBoundsUDF.java
@@ -1,20 +1,33 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
import java.util.Arrays;
import java.util.List;
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.hll.HllSketch;
-
@Description(
name = "SketchToEstimateAndErrorBounds",
value = "_FUNC_(sketch, kappa)",
diff --git a/src/main/java/org/apache/datasketches/hive/hll/SketchToEstimateUDF.java b/src/main/java/org/apache/datasketches/hive/hll/SketchToEstimateUDF.java
new file mode 100644
index 0000000..03a5d6d
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/hll/SketchToEstimateUDF.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.hll;
+
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(
+ name = "SketchToEstimate",
+ value = "_FUNC_(sketch)",
+ extended = "Returns an estimate of unique count from a given HllSketch."
+ + " The result is a double value.")
+@SuppressWarnings("javadoc")
+public class SketchToEstimateUDF extends UDF {
+
+ /**
+ * Get an estimate from a given HllSketch
+ * @param serializedSketch HllSketch in a serialized binary form
+ * @return estimate of unique count
+ */
+ public Double evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final HllSketch sketch = HllSketch.wrap(Memory.wrap(serializedSketch.getBytes()));
+ return sketch.getEstimate();
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/hll/SketchToStringUDF.java b/src/main/java/org/apache/datasketches/hive/hll/SketchToStringUDF.java
new file mode 100644
index 0000000..33b3ad2
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/hll/SketchToStringUDF.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.hll;
+
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(
+ name = "SketchToString",
+ value = "_FUNC_(sketch)",
+ extended = "Returns an human-readable summary of a given HllSketch.")
+@SuppressWarnings("javadoc")
+public class SketchToStringUDF extends UDF {
+
+ /**
+ * Get a human-readable summary of a given HllSketch
+ * @param serializedSketch HllSketch in a serialized binary form
+ * @return text summary
+ */
+ public String evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final HllSketch sketch = HllSketch.wrap(Memory.wrap(serializedSketch.getBytes()));
+ return sketch.toString();
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/hll/State.java b/src/main/java/org/apache/datasketches/hive/hll/State.java
new file mode 100644
index 0000000..fa9e5df
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/hll/State.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.hll;
+
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.hll.TgtHllType;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+
+abstract class State extends AbstractAggregationBuffer {
+
+ private int lgK_;
+ private TgtHllType type_;
+
+ void init(final int lgK, final TgtHllType type) {
+ lgK_ = lgK;
+ type_ = type;
+ }
+
+ int getLgK() {
+ return lgK_;
+ }
+
+ TgtHllType getType() {
+ return type_;
+ }
+
+ abstract boolean isInitialized();
+
+ abstract void update(final Object data, final PrimitiveObjectInspector keyObjectInspector);
+
+ abstract HllSketch getResult();
+
+ abstract void reset();
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/UnionSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/hll/UnionSketchUDAF.java
similarity index 88%
rename from src/main/java/com/yahoo/sketches/hive/hll/UnionSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/hll/UnionSketchUDAF.java
index ed81890..6277a83 100644
--- a/src/main/java/com/yahoo/sketches/hive/hll/UnionSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/hll/UnionSketchUDAF.java
@@ -1,12 +1,29 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
import java.util.Arrays;
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.hll.TgtHllType;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
@@ -24,10 +41,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StandardStructObjectInspect
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.hll.HllSketch;
-import com.yahoo.sketches.hll.TgtHllType;
-
/**
* Hive UDAF to compute union of HllSketch objects
*/
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/UnionSketchUDF.java b/src/main/java/org/apache/datasketches/hive/hll/UnionSketchUDF.java
similarity index 67%
rename from src/main/java/com/yahoo/sketches/hive/hll/UnionSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/hll/UnionSketchUDF.java
index ad46763..25cf218 100644
--- a/src/main/java/com/yahoo/sketches/hive/hll/UnionSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/hll/UnionSketchUDF.java
@@ -1,18 +1,31 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.hll.TgtHllType;
+import org.apache.datasketches.hll.Union;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.hll.HllSketch;
-import com.yahoo.sketches.hll.TgtHllType;
-import com.yahoo.sketches.hll.Union;
-
/**
* Hive union sketch UDF.
*/
diff --git a/src/main/java/com/yahoo/sketches/hive/hll/UnionState.java b/src/main/java/org/apache/datasketches/hive/hll/UnionState.java
similarity index 71%
rename from src/main/java/com/yahoo/sketches/hive/hll/UnionState.java
rename to src/main/java/org/apache/datasketches/hive/hll/UnionState.java
index eb74828..8cd82e4 100644
--- a/src/main/java/com/yahoo/sketches/hive/hll/UnionState.java
+++ b/src/main/java/org/apache/datasketches/hive/hll/UnionState.java
@@ -1,17 +1,30 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.hll.TgtHllType;
+import org.apache.datasketches.hll.Union;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.sketches.hll.HllSketch;
-import com.yahoo.sketches.hll.TgtHllType;
-import com.yahoo.sketches.hll.Union;
-
class UnionState extends State {
private Union union_;
diff --git a/src/main/java/org/apache/datasketches/hive/hll/package-info.java b/src/main/java/org/apache/datasketches/hive/hll/package-info.java
new file mode 100644
index 0000000..1dc31ad
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/hll/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hive UDFs for HLL sketches.
+ *
+ * @author Alexander Saydakov
+ */
+package org.apache.datasketches.hive.hll;
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/DataToSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/kll/DataToSketchUDAF.java
similarity index 73%
rename from src/main/java/com/yahoo/sketches/hive/kll/DataToSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/kll/DataToSketchUDAF.java
index f177fb3..f77db2a 100644
--- a/src/main/java/com/yahoo/sketches/hive/kll/DataToSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/kll/DataToSketchUDAF.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/GetCdfUDF.java b/src/main/java/org/apache/datasketches/hive/kll/GetCdfUDF.java
similarity index 62%
rename from src/main/java/com/yahoo/sketches/hive/kll/GetCdfUDF.java
rename to src/main/java/org/apache/datasketches/hive/kll/GetCdfUDF.java
index fa9b78c..b6131ff 100644
--- a/src/main/java/com/yahoo/sketches/hive/kll/GetCdfUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/kll/GetCdfUDF.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import java.util.List;
+import org.apache.datasketches.kll.KllFloatsSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
@Description(
name = "GetCDF",
value = "_FUNC_(sketch, split points...)",
diff --git a/src/main/java/org/apache/datasketches/hive/kll/GetNUDF.java b/src/main/java/org/apache/datasketches/hive/kll/GetNUDF.java
new file mode 100644
index 0000000..800d055
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/kll/GetNUDF.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.kll;
+
+import org.apache.datasketches.kll.KllFloatsSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(name = "GetN", value = "_FUNC_(sketch)",
+extended = " Returns the total number of observed input values (stream length) from a given KllFloatsSketch.")
+@SuppressWarnings("javadoc")
+public class GetNUDF extends UDF {
+
+ /**
+ * Returns N from a given sketch
+ * @param serializedSketch serialized sketch
+ * @return stream length
+ */
+ public Long evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final KllFloatsSketch sketch = KllFloatsSketch.heapify(Memory.wrap(serializedSketch.getBytes()));
+ return sketch.getN();
+ }
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/GetPmfUDF.java b/src/main/java/org/apache/datasketches/hive/kll/GetPmfUDF.java
similarity index 62%
rename from src/main/java/com/yahoo/sketches/hive/kll/GetPmfUDF.java
rename to src/main/java/org/apache/datasketches/hive/kll/GetPmfUDF.java
index e14f1ff..490e2b6 100644
--- a/src/main/java/com/yahoo/sketches/hive/kll/GetPmfUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/kll/GetPmfUDF.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import java.util.List;
+import org.apache.datasketches.kll.KllFloatsSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
@Description(
name = "GetPMF",
value = "_FUNC_(sketch, split points...)",
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/GetQuantileUDF.java b/src/main/java/org/apache/datasketches/hive/kll/GetQuantileUDF.java
similarity index 55%
rename from src/main/java/com/yahoo/sketches/hive/kll/GetQuantileUDF.java
rename to src/main/java/org/apache/datasketches/hive/kll/GetQuantileUDF.java
index c5720d6..ee20976 100644
--- a/src/main/java/com/yahoo/sketches/hive/kll/GetQuantileUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/kll/GetQuantileUDF.java
@@ -1,17 +1,30 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
+import org.apache.datasketches.kll.KllFloatsSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
@Description(name = "GetQuantile", value = "_FUNC_(sketch, fraction)",
extended = " Returns a quantile value from a given KllFloatsSketch."
+ " A single value for a given fraction is returned."
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/GetQuantilesUDF.java b/src/main/java/org/apache/datasketches/hive/kll/GetQuantilesUDF.java
similarity index 58%
rename from src/main/java/com/yahoo/sketches/hive/kll/GetQuantilesUDF.java
rename to src/main/java/org/apache/datasketches/hive/kll/GetQuantilesUDF.java
index 0c29a2a..951e777 100644
--- a/src/main/java/com/yahoo/sketches/hive/kll/GetQuantilesUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/kll/GetQuantilesUDF.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import java.util.List;
+import org.apache.datasketches.kll.KllFloatsSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
@Description(
name = "GetQuantiles",
value = "_FUNC_(sketch, fractions...)",
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/GetRankUDF.java b/src/main/java/org/apache/datasketches/hive/kll/GetRankUDF.java
similarity index 51%
rename from src/main/java/com/yahoo/sketches/hive/kll/GetRankUDF.java
rename to src/main/java/org/apache/datasketches/hive/kll/GetRankUDF.java
index ee4bd9f..2181ac6 100644
--- a/src/main/java/com/yahoo/sketches/hive/kll/GetRankUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/kll/GetRankUDF.java
@@ -1,17 +1,30 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
+import org.apache.datasketches.kll.KllFloatsSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
@Description(name = "GetRank", value = "_FUNC_(sketch, value)",
extended = " Returns a normalized rank of a given value from a given KllFloatsSketch."
+ " The returned rank is an approximation to the fraction of values of the distribution"
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/ObjectInspectorValidator.java b/src/main/java/org/apache/datasketches/hive/kll/ObjectInspectorValidator.java
similarity index 60%
rename from src/main/java/com/yahoo/sketches/hive/kll/ObjectInspectorValidator.java
rename to src/main/java/org/apache/datasketches/hive/kll/ObjectInspectorValidator.java
index b82e39a..d51d79a 100644
--- a/src/main/java/com/yahoo/sketches/hive/kll/ObjectInspectorValidator.java
+++ b/src/main/java/org/apache/datasketches/hive/kll/ObjectInspectorValidator.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.parse.SemanticException;
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/SketchEvaluator.java b/src/main/java/org/apache/datasketches/hive/kll/SketchEvaluator.java
similarity index 72%
rename from src/main/java/com/yahoo/sketches/hive/kll/SketchEvaluator.java
rename to src/main/java/org/apache/datasketches/hive/kll/SketchEvaluator.java
index ba1af04..bef19fc 100644
--- a/src/main/java/com/yahoo/sketches/hive/kll/SketchEvaluator.java
+++ b/src/main/java/org/apache/datasketches/hive/kll/SketchEvaluator.java
@@ -1,10 +1,26 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
+import org.apache.datasketches.kll.KllFloatsSketch;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -13,9 +29,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.Pr
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
abstract class SketchEvaluator extends GenericUDAFEvaluator {
protected PrimitiveObjectInspector inputInspector_;
@@ -29,7 +42,7 @@ abstract class SketchEvaluator extends GenericUDAFEvaluator {
// Parameters:
// In PARTIAL1 and COMPLETE mode, the parameters are original data.
// In PARTIAL2 and FINAL mode, the parameters are partial aggregations.
- if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
+ if ((mode == Mode.PARTIAL1) || (mode == Mode.COMPLETE)) {
if (parameters.length > 1) {
kInspector_ = (PrimitiveObjectInspector) parameters[1];
}
diff --git a/src/main/java/org/apache/datasketches/hive/kll/SketchState.java b/src/main/java/org/apache/datasketches/hive/kll/SketchState.java
new file mode 100644
index 0000000..d8e2003
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/kll/SketchState.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.kll;
+
+import org.apache.datasketches.kll.KllFloatsSketch;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
+
+class SketchState extends AbstractAggregationBuffer {
+
+ private KllFloatsSketch state_;
+
+ // initialization is needed in the first phase (iterate) only
+ void init() {
+ state_ = new KllFloatsSketch();
+ }
+
+ void init(final int k) {
+ state_ = new KllFloatsSketch(k);
+ }
+
+ boolean isInitialized() {
+ return state_ != null;
+ }
+
+ void update(final float value) {
+ state_.update(value);
+ }
+
+ void update(final KllFloatsSketch sketch) {
+ if (state_ == null) {
+ state_ = sketch;
+ } else {
+ state_.merge(sketch);
+ }
+ }
+
+ public KllFloatsSketch getResult() {
+ return state_;
+ }
+
+ void reset() {
+ state_ = null;
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/kll/SketchToStringUDF.java b/src/main/java/org/apache/datasketches/hive/kll/SketchToStringUDF.java
new file mode 100644
index 0000000..e66882e
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/kll/SketchToStringUDF.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.kll;
+
+import org.apache.datasketches.kll.KllFloatsSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(name = "SketchToString", value = "_FUNC_(sketch)",
+extended = " Returns a human-readable summary of a given KllFloatsSketch.")
+@SuppressWarnings("javadoc")
+public class SketchToStringUDF extends UDF {
+
+ /**
+ * Returns a summary of a given sketch
+ * @param serializedSketch serialized sketch
+ * @return text summary
+ */
+ public String evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final KllFloatsSketch sketch = KllFloatsSketch.heapify(Memory.wrap(serializedSketch.getBytes()));
+ return sketch.toString();
+ }
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/UnionSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/kll/UnionSketchUDAF.java
similarity index 72%
rename from src/main/java/com/yahoo/sketches/hive/kll/UnionSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/kll/UnionSketchUDAF.java
index 80b39a1..0fa69bd 100644
--- a/src/main/java/com/yahoo/sketches/hive/kll/UnionSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/kll/UnionSketchUDAF.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
diff --git a/src/main/java/com/yahoo/sketches/hive/kll/Util.java b/src/main/java/org/apache/datasketches/hive/kll/Util.java
similarity index 52%
rename from src/main/java/com/yahoo/sketches/hive/kll/Util.java
rename to src/main/java/org/apache/datasketches/hive/kll/Util.java
index a7acb14..1886ef7 100644
--- a/src/main/java/com/yahoo/sketches/hive/kll/Util.java
+++ b/src/main/java/org/apache/datasketches/hive/kll/Util.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/org/apache/datasketches/hive/kll/package-info.java b/src/main/java/org/apache/datasketches/hive/kll/package-info.java
new file mode 100644
index 0000000..c46fc65
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/kll/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hive UDFs for KllFloatsSketch sketch.
+ *
+ * @author Alexander Saydakov
+ */
+package org.apache.datasketches.hive.kll;
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/DataToDoublesSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/quantiles/DataToDoublesSketchUDAF.java
similarity index 73%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/DataToDoublesSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/DataToDoublesSketchUDAF.java
index d6a0098..8860da6 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/DataToDoublesSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/DataToDoublesSketchUDAF.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/DataToItemsSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/quantiles/DataToItemsSketchUDAF.java
similarity index 73%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/DataToItemsSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/DataToItemsSketchUDAF.java
index 3c173af..b7424a5 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/DataToItemsSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/DataToItemsSketchUDAF.java
@@ -1,12 +1,27 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
+import org.apache.datasketches.ArrayOfItemsSerDe;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.parse.SemanticException;
@@ -17,8 +32,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-
/**
* This is a generic implementation to be specialized in subclasses
* @param <T> type of item
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/DataToStringsSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/quantiles/DataToStringsSketchUDAF.java
similarity index 66%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/DataToStringsSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/DataToStringsSketchUDAF.java
index 09bef98..4b21eda 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/DataToStringsSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/DataToStringsSketchUDAF.java
@@ -1,12 +1,27 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
+import org.apache.datasketches.ArrayOfStringsSerDe;
import org.apache.hadoop.hive.common.type.HiveChar;
import org.apache.hadoop.hive.common.type.HiveVarchar;
import org.apache.hadoop.hive.ql.exec.Description;
@@ -15,8 +30,6 @@ import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-
@Description(name = "DataToSketch", value = "_FUNC_(value, k) - "
+ "Returns an ItemsSketch<String> in a serialized form as a binary blob."
+ " Values must be of string type."
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/DoublesEvaluator.java b/src/main/java/org/apache/datasketches/hive/quantiles/DoublesEvaluator.java
similarity index 74%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/DoublesEvaluator.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/DoublesEvaluator.java
index f6593d8..afdea0a 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/DoublesEvaluator.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/DoublesEvaluator.java
@@ -1,10 +1,25 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
+import org.apache.datasketches.quantiles.DoublesSketch;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -13,8 +28,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.Pr
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-
abstract class DoublesEvaluator extends GenericUDAFEvaluator {
protected PrimitiveObjectInspector inputObjectInspector;
diff --git a/src/main/java/org/apache/datasketches/hive/quantiles/DoublesSketchToStringUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/DoublesSketchToStringUDF.java
new file mode 100644
index 0000000..11c497a
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/DoublesSketchToStringUDF.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(name = "ToString", value = "_FUNC_(sketch)",
+extended = " Returns a human-readable summary of a given DoublesSketch.")
+@SuppressWarnings("javadoc")
+public class DoublesSketchToStringUDF extends UDF {
+
+ /**
+ * Returns a human-readable summary of a given sketch
+ * @param serializedSketch serialized sketch
+ * @return text summary
+ */
+ public String evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final DoublesSketch sketch = DoublesSketch.wrap(Memory.wrap(serializedSketch.getBytes()));
+ return sketch.toString();
+ }
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/DoublesUnionState.java b/src/main/java/org/apache/datasketches/hive/quantiles/DoublesUnionState.java
similarity index 50%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/DoublesUnionState.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/DoublesUnionState.java
index b1c6e93..2b2fe8b 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/DoublesUnionState.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/DoublesUnionState.java
@@ -1,17 +1,30 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.quantiles.DoublesUnion;
+import org.apache.datasketches.quantiles.DoublesUnionBuilder;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.quantiles.DoublesUnion;
-import com.yahoo.sketches.quantiles.DoublesUnionBuilder;
-
class DoublesUnionState extends AbstractAggregationBuffer {
private DoublesUnion union;
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetCdfFromDoublesSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetCdfFromDoublesSketchUDF.java
similarity index 62%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/GetCdfFromDoublesSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/GetCdfFromDoublesSketchUDF.java
index e6829aa..e747a8d 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetCdfFromDoublesSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetCdfFromDoublesSketchUDF.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.List;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-
@Description(
name = "GetCDF",
value = "_FUNC_(sketch, split points...)",
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetCdfFromStringsSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetCdfFromStringsSketchUDF.java
similarity index 62%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/GetCdfFromStringsSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/GetCdfFromStringsSketchUDF.java
index 06f5024..3722cd0 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetCdfFromStringsSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetCdfFromStringsSketchUDF.java
@@ -1,21 +1,34 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
import java.util.List;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.ItemsSketch;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
@Description(
name = "GetCDF",
value = "_FUNC_(sketch, split points...)",
diff --git a/src/main/java/org/apache/datasketches/hive/quantiles/GetKFromDoublesSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetKFromDoublesSketchUDF.java
new file mode 100644
index 0000000..9ba75e9
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetKFromDoublesSketchUDF.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(name = "GetK", value = "_FUNC_(sketch)",
+extended = " Returns parameter K from a given DoublesSketch sketch.")
+@SuppressWarnings("javadoc")
+public class GetKFromDoublesSketchUDF extends UDF {
+
+ /**
+ * Returns parameter K from a given sketch
+ * @param serializedSketch serialized sketch
+ * @return parameter K
+ */
+ public Integer evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final DoublesSketch sketch = DoublesSketch.wrap(Memory.wrap(serializedSketch.getBytes()));
+ return sketch.getK();
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/quantiles/GetKFromStringsSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetKFromStringsSketchUDF.java
new file mode 100644
index 0000000..e0366bf
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetKFromStringsSketchUDF.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import java.util.Comparator;
+
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.ItemsSketch;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(name = "GetK", value = "_FUNC_(sketch)",
+extended = " Returns parameter K from a given ItemsSketch<String> sketch.")
+@SuppressWarnings("javadoc")
+public class GetKFromStringsSketchUDF extends UDF {
+
+ /**
+ * Returns parameter K from a given sketch
+ * @param serializedSketch serialized sketch
+ * @return parameter K
+ */
+ public Integer evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final ItemsSketch<String> sketch = ItemsSketch.getInstance(
+ Memory.wrap(serializedSketch.getBytes()),
+ Comparator.naturalOrder(),
+ new ArrayOfStringsSerDe()
+ );
+ return sketch.getK();
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/quantiles/GetNFromDoublesSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetNFromDoublesSketchUDF.java
new file mode 100644
index 0000000..fce02b5
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetNFromDoublesSketchUDF.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(name = "GetN", value = "_FUNC_(sketch)",
+extended = " Returns the total number of observed input values (stream length) from a given DoublesSketch.")
+@SuppressWarnings("javadoc")
+public class GetNFromDoublesSketchUDF extends UDF {
+
+ /**
+ * Returns N from a given sketch
+ * @param serializedSketch serialized sketch
+ * @return stream length
+ */
+ public Long evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final DoublesSketch sketch = DoublesSketch.wrap(Memory.wrap(serializedSketch.getBytes()));
+ return sketch.getN();
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/quantiles/GetNFromStringsSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetNFromStringsSketchUDF.java
new file mode 100644
index 0000000..860e3b7
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetNFromStringsSketchUDF.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import java.util.Comparator;
+
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.ItemsSketch;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(name = "GetN", value = "_FUNC_(sketch)",
+ extended = " Returns the total number of observed input values (stream length) "
+ + "from a given ItemsSketch<String>.")
+@SuppressWarnings("javadoc")
+public class GetNFromStringsSketchUDF extends UDF {
+
+ /**
+ * Returns N from a given sketch
+ * @param serializedSketch serialized sketch
+ * @return stream length
+ */
+ public Long evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final ItemsSketch<String> sketch = ItemsSketch.getInstance(
+ Memory.wrap(serializedSketch.getBytes()),
+ Comparator.naturalOrder(),
+ new ArrayOfStringsSerDe()
+ );
+ return sketch.getN();
+ }
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetPmfFromDoublesSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetPmfFromDoublesSketchUDF.java
similarity index 62%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/GetPmfFromDoublesSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/GetPmfFromDoublesSketchUDF.java
index 6225b30..c54a572 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetPmfFromDoublesSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetPmfFromDoublesSketchUDF.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.List;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-
@Description(
name = "GetPMF",
value = "_FUNC_(sketch, split points...)",
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetPmfFromStringsSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetPmfFromStringsSketchUDF.java
similarity index 62%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/GetPmfFromStringsSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/GetPmfFromStringsSketchUDF.java
index e12edbd..1fb1305 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetPmfFromStringsSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetPmfFromStringsSketchUDF.java
@@ -1,21 +1,34 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
import java.util.List;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.ItemsSketch;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
@Description(
name = "GetPMF",
value = "_FUNC_(sketch, split points...)",
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromDoublesSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetQuantileFromDoublesSketchUDF.java
similarity index 55%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromDoublesSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/GetQuantileFromDoublesSketchUDF.java
index 8485b34..5339309 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromDoublesSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetQuantileFromDoublesSketchUDF.java
@@ -1,17 +1,30 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-
@Description(name = "GetQuantile", value = "_FUNC_(sketch, fraction)",
extended = " Returns a quantile value from a given DoublesSketch sketch."
+ " A single value for a given fraction is returned."
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromStringsSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetQuantileFromStringsSketchUDF.java
similarity index 57%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromStringsSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/GetQuantileFromStringsSketchUDF.java
index fc592ab..768bdaf 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromStringsSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetQuantileFromStringsSketchUDF.java
@@ -1,20 +1,33 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.ItemsSketch;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
@Description(name = "GetQuantile", value = "_FUNC_(sketch, fraction)",
extended = " Returns a quantile value from a given ItemsSketch<String> sketch."
+ " A single value for a given fraction is returned."
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromDoublesSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromDoublesSketchUDF.java
similarity index 70%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromDoublesSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromDoublesSketchUDF.java
index 9da74f4..5c10be2 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromDoublesSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromDoublesSketchUDF.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.List;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-
@Description(
name = "GetQuantiles",
value = "_FUNC_(sketch, fractions...) or _FUNC_(sketch, number)",
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromStringsSketchUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromStringsSketchUDF.java
similarity index 71%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromStringsSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromStringsSketchUDF.java
index 744d6a5..c079126 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromStringsSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromStringsSketchUDF.java
@@ -1,22 +1,35 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.ItemsSketch;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
@Description(
name = "GetQuantiles",
value = "_FUNC_(sketch, fractions...) or _FUNC_(sketch, number)",
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/ItemsEvaluator.java b/src/main/java/org/apache/datasketches/hive/quantiles/ItemsEvaluator.java
similarity index 76%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/ItemsEvaluator.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/ItemsEvaluator.java
index bbb19f5..954a3e7 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/ItemsEvaluator.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/ItemsEvaluator.java
@@ -1,12 +1,28 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.quantiles.ItemsSketch;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -15,9 +31,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.Pr
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
abstract class ItemsEvaluator<T> extends GenericUDAFEvaluator {
private final Comparator<? super T> comparator_;
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/ItemsUnionState.java b/src/main/java/org/apache/datasketches/hive/quantiles/ItemsUnionState.java
similarity index 56%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/ItemsUnionState.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/ItemsUnionState.java
index 6bf0a60..e98e48b 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/ItemsUnionState.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/ItemsUnionState.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.ItemsSketch;
+import org.apache.datasketches.quantiles.ItemsUnion;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-import com.yahoo.sketches.quantiles.ItemsUnion;
-
class ItemsUnionState<T> extends AbstractAggregationBuffer {
private final Comparator<? super T> comparator_;
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/ObjectInspectorValidator.java b/src/main/java/org/apache/datasketches/hive/quantiles/ObjectInspectorValidator.java
similarity index 60%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/ObjectInspectorValidator.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/ObjectInspectorValidator.java
index c56ed70..ad19264 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/ObjectInspectorValidator.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/ObjectInspectorValidator.java
@@ -1,4 +1,23 @@
-package com.yahoo.sketches.hive.quantiles;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.parse.SemanticException;
diff --git a/src/main/java/org/apache/datasketches/hive/quantiles/StringsSketchToStringUDF.java b/src/main/java/org/apache/datasketches/hive/quantiles/StringsSketchToStringUDF.java
new file mode 100644
index 0000000..551e06d
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/StringsSketchToStringUDF.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import java.util.Comparator;
+
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.ItemsSketch;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(name = "ToString", value = "_FUNC_(sketch)",
+extended = " Returns a human-readable summary of a given ItemsSketch<String>.")
+@SuppressWarnings("javadoc")
+public class StringsSketchToStringUDF extends UDF {
+
+ /**
+ * Returns a human-readable summary of a given sketch
+ * @param serializedSketch serialized sketch
+ * @return text summary
+ */
+ public String evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final ItemsSketch<String> sketch = ItemsSketch.getInstance(
+ Memory.wrap(serializedSketch.getBytes()),
+ Comparator.naturalOrder(),
+ new ArrayOfStringsSerDe()
+ );
+ return sketch.toString();
+ }
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/UnionDoublesSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/quantiles/UnionDoublesSketchUDAF.java
similarity index 72%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/UnionDoublesSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/UnionDoublesSketchUDAF.java
index 441f6fc..d746a54 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/UnionDoublesSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/UnionDoublesSketchUDAF.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/UnionItemsSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/quantiles/UnionItemsSketchUDAF.java
similarity index 72%
rename from src/main/java/com/yahoo/sketches/hive/quantiles/UnionItemsSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/quantiles/UnionItemsSketchUDAF.java
index 3ad08e9..3c93a5c 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/UnionItemsSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/UnionItemsSketchUDAF.java
@@ -1,12 +1,27 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
+import org.apache.datasketches.ArrayOfItemsSerDe;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.parse.SemanticException;
@@ -17,8 +32,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-
/**
* This is a generic implementation to be specialized in subclasses
* @param <T> type of item
diff --git a/src/main/java/org/apache/datasketches/hive/quantiles/UnionStringsSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/quantiles/UnionStringsSketchUDAF.java
new file mode 100644
index 0000000..da97534
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/UnionStringsSketchUDAF.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import java.util.Comparator;
+
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
+
+@Description(name = "Union", value = "_FUNC_(sketch) - "
+ + "Returns an ItemsSketch<String> in a serialized form as a binary blob."
+ + " Input values must also be serialized sketches.")
+@SuppressWarnings("javadoc")
+public class UnionStringsSketchUDAF extends UnionItemsSketchUDAF<String> {
+
+ @Override
+ public GenericUDAFEvaluator createEvaluator() {
+ return new UnionStringsSketchEvaluator();
+ }
+
+ static class UnionStringsSketchEvaluator extends UnionEvaluator<String> {
+
+ UnionStringsSketchEvaluator() {
+ super(Comparator.naturalOrder(), new ArrayOfStringsSerDe());
+ }
+
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/quantiles/Util.java b/src/main/java/org/apache/datasketches/hive/quantiles/Util.java
new file mode 100644
index 0000000..2aea43c
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/Util.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import java.util.ArrayList;
+import java.util.List;
+
+final class Util {
+
+ static double[] objectsToPrimitives(final Double[] array) {
+ final double[] result = new double[array.length];
+ for (int i = 0; i < array.length; i++) {
+ result[i] = array[i];
+ }
+ return result;
+ }
+
+ static List<Double> primitivesToList(final double[] array) {
+ final List<Double> result = new ArrayList<Double>(array.length);
+ for (double item: array) { result.add(item); }
+ return result;
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/quantiles/package-info.java b/src/main/java/org/apache/datasketches/hive/quantiles/package-info.java
new file mode 100644
index 0000000..24f631b
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/quantiles/package-info.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hive UDFs for Quantiles sketches.
+ * This includes UDFs for generic ItemsSketch and specialized DoublesSketch.
+ *
+ * <p>The generic implementation is in the form of abstract classes DataToItemsSketchUDAF and
+ * UnionItemsSketchUDAF to be specialized for particular types of items.
+ * An implementation for strings is provided: DataToStringsSketchUDAF, UnionStringsSketchUDAF,
+ * plus UDFs to obtain the results from sketches:
+ * GetQuantileFromStringsSketchUDF, GetQuantilesFromStringsSketchUDF and GetPmfFromStringsSketchUDF.
+ *
+ * <p>Support for DoublesSketch: DataToDoublesSketchUDAF, UnionDoublesSketchUDAF,
+ * GetQuantileFromDoublesSketchUDF, GetQuantilesFromDoublesSketchUDF, GetPmfFromDoublesSketchUDF
+ *
+ * @author Alexander Saydakov
+ */
+package org.apache.datasketches.hive.quantiles;
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/DataToSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/theta/DataToSketchUDAF.java
similarity index 89%
rename from src/main/java/com/yahoo/sketches/hive/theta/DataToSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/theta/DataToSketchUDAF.java
index ccfc97a..581f5a6 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/DataToSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/theta/DataToSketchUDAF.java
@@ -1,12 +1,26 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_NOMINAL_ENTRIES;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/EstimateSketchUDF.java b/src/main/java/org/apache/datasketches/hive/theta/EstimateSketchUDF.java
similarity index 54%
rename from src/main/java/com/yahoo/sketches/hive/theta/EstimateSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/theta/EstimateSketchUDF.java
index deb0de4..dd4c1a7 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/EstimateSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/theta/EstimateSketchUDF.java
@@ -1,18 +1,31 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.Sketch;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.Sketch;
-
/**
* Hive estimate sketch udf. V4
*
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/ExcludeSketchUDF.java b/src/main/java/org/apache/datasketches/hive/theta/ExcludeSketchUDF.java
similarity index 66%
rename from src/main/java/com/yahoo/sketches/hive/theta/ExcludeSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/theta/ExcludeSketchUDF.java
index 9d11da3..778e5fe 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/ExcludeSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/theta/ExcludeSketchUDF.java
@@ -1,20 +1,33 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.AnotB;
+import org.apache.datasketches.theta.SetOperation;
+import org.apache.datasketches.theta.Sketch;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.AnotB;
-import com.yahoo.sketches.theta.SetOperation;
-import com.yahoo.sketches.theta.Sketch;
-
/**
* Hive exclude sketch UDF. (i.e. in sketch a but not in sketch b)
*
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/theta/IntersectSketchUDAF.java
similarity index 87%
rename from src/main/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/theta/IntersectSketchUDAF.java
index d32c880..8a1f626 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/theta/IntersectSketchUDAF.java
@@ -1,14 +1,33 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.Intersection;
+import org.apache.datasketches.theta.SetOperation;
+import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.Sketches;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
@@ -28,12 +47,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectIn
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.LongWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.Intersection;
-import com.yahoo.sketches.theta.SetOperation;
-import com.yahoo.sketches.theta.Sketch;
-import com.yahoo.sketches.theta.Sketches;
-
@Description(
name = "intersectSketch",
value = "_FUNC_(sketch, seed) - Compute the intersection of sketches",
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/IntersectSketchUDF.java b/src/main/java/org/apache/datasketches/hive/theta/IntersectSketchUDF.java
similarity index 64%
rename from src/main/java/com/yahoo/sketches/hive/theta/IntersectSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/theta/IntersectSketchUDF.java
index 1840903..07be37c 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/IntersectSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/theta/IntersectSketchUDF.java
@@ -1,20 +1,33 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.Intersection;
+import org.apache.datasketches.theta.SetOperation;
+import org.apache.datasketches.theta.Sketch;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.Intersection;
-import com.yahoo.sketches.theta.SetOperation;
-import com.yahoo.sketches.theta.Sketch;
-
/**
* Hive intersection sketch UDF.
*
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/ObjectInspectorValidator.java b/src/main/java/org/apache/datasketches/hive/theta/ObjectInspectorValidator.java
similarity index 75%
rename from src/main/java/com/yahoo/sketches/hive/theta/ObjectInspectorValidator.java
rename to src/main/java/org/apache/datasketches/hive/theta/ObjectInspectorValidator.java
index 360333a..bf21796 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/ObjectInspectorValidator.java
+++ b/src/main/java/org/apache/datasketches/hive/theta/ObjectInspectorValidator.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/UnionEvaluator.java b/src/main/java/org/apache/datasketches/hive/theta/UnionEvaluator.java
similarity index 82%
rename from src/main/java/com/yahoo/sketches/hive/theta/UnionEvaluator.java
rename to src/main/java/org/apache/datasketches/hive/theta/UnionEvaluator.java
index 6b4d324..14b821c 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/UnionEvaluator.java
+++ b/src/main/java/org/apache/datasketches/hive/theta/UnionEvaluator.java
@@ -1,12 +1,28 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
import java.util.Arrays;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.Sketch;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
@@ -15,9 +31,6 @@ import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.Sketch;
-
/**
* Common code for DataToSketchUDAF and UnionSketchUDAF
*/
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/UnionSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/theta/UnionSketchUDAF.java
similarity index 87%
rename from src/main/java/com/yahoo/sketches/hive/theta/UnionSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/theta/UnionSketchUDAF.java
index 55f943e..74b7ec0 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/UnionSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/theta/UnionSketchUDAF.java
@@ -1,15 +1,30 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_NOMINAL_ENTRIES;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
+import org.apache.datasketches.memory.Memory;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
@@ -26,8 +41,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StandardStructObjectInspect
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.memory.Memory;
-
/**
* Hive UDAF to compute union of theta Sketch objects
*/
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/UnionSketchUDF.java b/src/main/java/org/apache/datasketches/hive/theta/UnionSketchUDF.java
similarity index 69%
rename from src/main/java/com/yahoo/sketches/hive/theta/UnionSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/theta/UnionSketchUDF.java
index b671fc0..5cb0358 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/UnionSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/theta/UnionSketchUDF.java
@@ -1,20 +1,33 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_NOMINAL_ENTRIES;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.SetOperation;
+import org.apache.datasketches.theta.Union;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.SetOperation;
-import com.yahoo.sketches.theta.Union;
-
/**
* Hive union sketch UDF.
*/
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/UnionState.java b/src/main/java/org/apache/datasketches/hive/theta/UnionState.java
similarity index 73%
rename from src/main/java/com/yahoo/sketches/hive/theta/UnionState.java
rename to src/main/java/org/apache/datasketches/hive/theta/UnionState.java
index 370af5c..a7e3b20 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/UnionState.java
+++ b/src/main/java/org/apache/datasketches/hive/theta/UnionState.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.SetOperation;
+import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.Union;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.SetOperation;
-import com.yahoo.sketches.theta.Sketch;
-import com.yahoo.sketches.theta.Union;
-
class UnionState extends AbstractAggregationBuffer {
static final float DEFAULT_SAMPLING_PROBABILITY = 1;
diff --git a/src/main/java/org/apache/datasketches/hive/theta/package-info.java b/src/main/java/org/apache/datasketches/hive/theta/package-info.java
new file mode 100644
index 0000000..1d28a7c
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/theta/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hive UDFs and UDAFs for Theta sketch.
+ *
+ * @author Will Lauer
+ * @author Alexander Saydakov
+ */
+package org.apache.datasketches.hive.theta;
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchEvaluator.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchEvaluator.java
similarity index 75%
rename from src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchEvaluator.java
rename to src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchEvaluator.java
index c9a806b..7a50cd4 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchEvaluator.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchEvaluator.java
@@ -1,12 +1,29 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.Arrays;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketches;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
@@ -14,10 +31,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.IntWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;
-
abstract class ArrayOfDoublesSketchEvaluator extends GenericUDAFEvaluator {
protected static final String NOMINAL_NUM_ENTRIES_FIELD = "nominalEntries";
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchState.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchState.java
similarity index 70%
rename from src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchState.java
rename to src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchState.java
index ad3de59..e0c38aa 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchState.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchState.java
@@ -1,17 +1,30 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
-
class ArrayOfDoublesSketchState extends ArrayOfDoublesState {
private ArrayOfDoublesUpdatableSketch sketch_;
diff --git a/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchStats.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchStats.java
new file mode 100644
index 0000000..06890fd
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchStats.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.tuple;
+
+import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketchIterator;
+
+class ArrayOfDoublesSketchStats {
+
+ /**
+ * Convert sketch to summary statistics.
+ *
+ * @param sketch ArrayOfDoublesSketch to convert to summary statistics.
+ * @return An array of SummaryStatistics.
+ */
+ static SummaryStatistics[] sketchToSummaryStatistics(final ArrayOfDoublesSketch sketch) {
+ final SummaryStatistics[] summaryStatistics = new SummaryStatistics[sketch.getNumValues()];
+ for (int i = 0; i < sketch.getNumValues(); i++) {
+ summaryStatistics[i] = new SummaryStatistics();
+ }
+ final ArrayOfDoublesSketchIterator it = sketch.iterator();
+ while (it.next()) {
+ final double[] values = it.getValues();
+ for (int i = 0; i < it.getValues().length; i++) {
+ summaryStatistics[i].addValue(values[i]);
+ }
+ }
+ return summaryStatistics;
+ }
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDF.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDF.java
similarity index 55%
rename from src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDF.java
index fb826b5..158b3b0 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDF.java
@@ -1,21 +1,34 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.Arrays;
import java.util.List;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketches;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;
-
@Description(
name = "ArrayOfDoublesSketchToEstimateAndErrorBounds",
value = "_FUNC_(sketch)",
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDF.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDF.java
similarity index 62%
rename from src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDF.java
index 22dac90..8813bcc 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDF.java
@@ -1,22 +1,35 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.ArrayList;
import java.util.List;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketchIterator;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketches;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketchIterator;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;
-
@Description(
name = "ArrayOfDoublesSketchToEstimates",
value = "_FUNC_(sketch)",
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToMeansUDF.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToMeansUDF.java
similarity index 58%
rename from src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToMeansUDF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToMeansUDF.java
index a10a143..c4e499d 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToMeansUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToMeansUDF.java
@@ -1,22 +1,35 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketches;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;
-
@Description(
name = "ArrayOfDoublesSketchToMeans",
value = "_FUNC_(sketch)",
diff --git a/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDF.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDF.java
new file mode 100644
index 0000000..ff17a8c
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDF.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.tuple;
+
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketches;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.BytesWritable;
+
+@Description(
+ name = "ArrayOfDoublesSketchToNumberOfRetainedEntries",
+ value = "_FUNC_(sketch)",
+ extended = "Returns the number of retained entries from a given ArrayOfDoublesSketch."
+ + " The result is an integer value.")
+@SuppressWarnings("javadoc")
+public class ArrayOfDoublesSketchToNumberOfRetainedEntriesUDF extends UDF {
+
+ /**
+ * Get number of retained entries from a given ArrayOfDoublesSketch
+ * @param serializedSketch ArrayOfDoublesSketch in as serialized binary
+ * @return number of retained entries
+ */
+ public Integer evaluate(final BytesWritable serializedSketch) {
+ if (serializedSketch == null) { return null; }
+ final ArrayOfDoublesSketch sketch = ArrayOfDoublesSketches.wrapSketch(
+ Memory.wrap(serializedSketch.getBytes()));
+ return sketch.getRetainedEntries();
+ }
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDF.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDF.java
similarity index 70%
rename from src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDF.java
index 2cab6ba..398db48 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDF.java
@@ -1,22 +1,35 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.quantiles.DoublesSketchBuilder;
+import org.apache.datasketches.quantiles.UpdateDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketchIterator;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketches;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.quantiles.DoublesSketchBuilder;
-import com.yahoo.sketches.quantiles.UpdateDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketchIterator;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;
-
@Description(
name = "ArrayOfDoublesSketchToQuantilesSketch",
value = "_FUNC_(sketch, column, k)",
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTF.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTF.java
similarity index 72%
rename from src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTF.java
index e814e32..ebd905c 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTF.java
@@ -1,14 +1,32 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketchIterator;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketches;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -20,11 +38,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketchIterator;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;
-
@SuppressWarnings("javadoc")
public class ArrayOfDoublesSketchToValuesUDTF extends GenericUDTF {
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDF.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDF.java
similarity index 59%
rename from src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDF.java
index 9b0bc45..d632a88 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDF.java
@@ -1,22 +1,35 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketches;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;
-
@Description(
name = "ArrayOfDoublesSketchToVariances",
value = "_FUNC_(sketch)",
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchesTTestUDF.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchesTTestUDF.java
similarity index 69%
rename from src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchesTTestUDF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchesTTestUDF.java
index cd7048e..73f75ed 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchesTTestUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchesTTestUDF.java
@@ -1,23 +1,36 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
import org.apache.commons.math3.stat.inference.TTest;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketches;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;
-
@Description(
name = "ArrayOfDoublesSketchesTTest",
value = "_FUNC_(sketchA, sketchB)",
diff --git a/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesState.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesState.java
new file mode 100644
index 0000000..59743a0
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesState.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.tuple;
+
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
+
+abstract class ArrayOfDoublesState extends AbstractAggregationBuffer {
+
+ private int nominalNumEntries_;
+ private int numValues_;
+
+ void init(final int numNominalEntries, final int numValues) {
+ nominalNumEntries_ = numNominalEntries;
+ numValues_ = numValues;
+ }
+
+ int getNominalNumEntries() {
+ return nominalNumEntries_;
+ }
+
+ int getNumValues() {
+ return numValues_;
+ }
+
+ abstract ArrayOfDoublesSketch getResult();
+
+ abstract void reset();
+
+}
diff --git a/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesUnionState.java b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesUnionState.java
new file mode 100644
index 0000000..2610f7f
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesUnionState.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.tuple;
+
+import org.apache.datasketches.tuple.ArrayOfDoublesSetOperationBuilder;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUnion;
+
+class ArrayOfDoublesUnionState extends ArrayOfDoublesState {
+
+ private ArrayOfDoublesUnion union_;
+
+ boolean isInitialized() {
+ return union_ != null;
+ }
+
+ @Override
+ void init(final int nominalNumEntries, final int numValues) {
+ super.init(nominalNumEntries, numValues);
+ union_ = new ArrayOfDoublesSetOperationBuilder()
+ .setNominalEntries(nominalNumEntries).setNumberOfValues(numValues).buildUnion();
+ }
+
+ void update(final ArrayOfDoublesSketch sketch) {
+ union_.update(sketch);
+ }
+
+ @Override
+ ArrayOfDoublesSketch getResult() {
+ if (union_ == null) { return null; }
+ return union_.getResult();
+ }
+
+ @Override
+ void reset() {
+ union_ = null;
+ }
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java
similarity index 89%
rename from src/main/java/com/yahoo/sketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java
index 4514836..dc6d3f2 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java
@@ -1,11 +1,25 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
-import static com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES;
+import static org.apache.datasketches.Util.DEFAULT_NOMINAL_ENTRIES;
import java.util.Arrays;
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/DataToDoubleSummarySketchUDAF.java b/src/main/java/org/apache/datasketches/hive/tuple/DataToDoubleSummarySketchUDAF.java
similarity index 71%
rename from src/main/java/com/yahoo/sketches/hive/tuple/DataToDoubleSummarySketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/DataToDoubleSummarySketchUDAF.java
index 0670a44..06e136f 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/DataToDoubleSummarySketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/DataToDoubleSummarySketchUDAF.java
@@ -1,10 +1,31 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
+import org.apache.datasketches.tuple.SummaryDeserializer;
+import org.apache.datasketches.tuple.SummaryFactory;
+import org.apache.datasketches.tuple.SummarySetOperations;
+import org.apache.datasketches.tuple.adouble.DoubleSummary;
+import org.apache.datasketches.tuple.adouble.DoubleSummaryDeserializer;
+import org.apache.datasketches.tuple.adouble.DoubleSummaryFactory;
+import org.apache.datasketches.tuple.adouble.DoubleSummarySetOperations;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
@@ -12,14 +33,6 @@ import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFParameterInfo;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
-import com.yahoo.sketches.tuple.DoubleSummary;
-import com.yahoo.sketches.tuple.DoubleSummaryDeserializer;
-import com.yahoo.sketches.tuple.DoubleSummaryFactory;
-import com.yahoo.sketches.tuple.DoubleSummarySetOperations;
-import com.yahoo.sketches.tuple.SummaryDeserializer;
-import com.yahoo.sketches.tuple.SummaryFactory;
-import com.yahoo.sketches.tuple.SummarySetOperations;
-
/**
* This simple implementation is to give an example of a concrete UDAF based on the abstract
* DataToSketchUDAF if no extra arguments are needed. The same functionality is included into
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/DataToDoubleSummaryWithModeSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/tuple/DataToDoubleSummaryWithModeSketchUDAF.java
similarity index 81%
rename from src/main/java/com/yahoo/sketches/hive/tuple/DataToDoubleSummaryWithModeSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/DataToDoubleSummaryWithModeSketchUDAF.java
index 53292eb..ab88b51 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/DataToDoubleSummaryWithModeSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/DataToDoubleSummaryWithModeSketchUDAF.java
@@ -1,12 +1,34 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.Arrays;
+import org.apache.datasketches.tuple.Sketch;
+import org.apache.datasketches.tuple.SummaryDeserializer;
+import org.apache.datasketches.tuple.SummaryFactory;
+import org.apache.datasketches.tuple.SummarySetOperations;
+import org.apache.datasketches.tuple.adouble.DoubleSummary;
+import org.apache.datasketches.tuple.adouble.DoubleSummaryDeserializer;
+import org.apache.datasketches.tuple.adouble.DoubleSummaryFactory;
+import org.apache.datasketches.tuple.adouble.DoubleSummarySetOperations;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -23,15 +45,6 @@ import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
-import com.yahoo.sketches.tuple.DoubleSummary;
-import com.yahoo.sketches.tuple.DoubleSummaryDeserializer;
-import com.yahoo.sketches.tuple.DoubleSummaryFactory;
-import com.yahoo.sketches.tuple.DoubleSummarySetOperations;
-import com.yahoo.sketches.tuple.Sketch;
-import com.yahoo.sketches.tuple.SummaryDeserializer;
-import com.yahoo.sketches.tuple.SummaryFactory;
-import com.yahoo.sketches.tuple.SummarySetOperations;
-
/**
* This is an example of a concrete UDAF based on the abstract DataToSketchUDAF if extra arguments
* are needed. For a simpler example with no extra arguments see DataToDoubleSummarySketchUDAF.
@@ -98,13 +111,13 @@ public class DataToDoubleSummaryWithModeSketchUDAF extends DataToSketchUDAF {
@Override
public ObjectInspector init(final Mode mode, final ObjectInspector[] inspectors) throws HiveException {
final ObjectInspector resultInspector = super.init(mode, inspectors);
- if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
+ if ((mode == Mode.PARTIAL1) || (mode == Mode.COMPLETE)) {
// input is original data
if (inspectors.length > 4) {
summaryModeInspector_ = (PrimitiveObjectInspector) inspectors[4];
}
}
- if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
+ if ((mode == Mode.PARTIAL1) || (mode == Mode.PARTIAL2)) {
// intermediate results need to include the nominal number of entries and the summary mode
return ObjectInspectorFactory.getStandardStructObjectInspector(
Arrays.asList(NOMINAL_NUM_ENTRIES_FIELD, SUMMARY_MODE_FIELD, SKETCH_FIELD),
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/DataToSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/tuple/DataToSketchUDAF.java
similarity index 87%
rename from src/main/java/com/yahoo/sketches/hive/tuple/DataToSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/DataToSketchUDAF.java
index fc886e3..b236329 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/DataToSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/DataToSketchUDAF.java
@@ -1,14 +1,29 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
-import static com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES;
+import static org.apache.datasketches.Util.DEFAULT_NOMINAL_ENTRIES;
import java.util.Arrays;
+import org.apache.datasketches.tuple.UpdatableSummary;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -24,8 +39,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.sketches.tuple.UpdatableSummary;
-
@SuppressWarnings("javadoc")
public abstract class DataToSketchUDAF extends AbstractGenericUDAFResolver {
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/DoubleSummarySketchToEstimatesUDF.java b/src/main/java/org/apache/datasketches/hive/tuple/DoubleSummarySketchToEstimatesUDF.java
similarity index 57%
rename from src/main/java/com/yahoo/sketches/hive/tuple/DoubleSummarySketchToEstimatesUDF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/DoubleSummarySketchToEstimatesUDF.java
index 1b65574..54819bf 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/DoubleSummarySketchToEstimatesUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/DoubleSummarySketchToEstimatesUDF.java
@@ -1,25 +1,38 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.Arrays;
import java.util.List;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.Sketch;
+import org.apache.datasketches.tuple.SketchIterator;
+import org.apache.datasketches.tuple.Sketches;
+import org.apache.datasketches.tuple.SummaryDeserializer;
+import org.apache.datasketches.tuple.adouble.DoubleSummary;
+import org.apache.datasketches.tuple.adouble.DoubleSummaryDeserializer;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.DoubleSummary;
-import com.yahoo.sketches.tuple.DoubleSummaryDeserializer;
-import com.yahoo.sketches.tuple.Sketch;
-import com.yahoo.sketches.tuple.SketchIterator;
-import com.yahoo.sketches.tuple.Sketches;
-import com.yahoo.sketches.tuple.SummaryDeserializer;
-
@Description(
name = "DoubleSummarySketchToEstimates",
value = "_FUNC_(sketch)",
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/DoubleSummarySketchToPercentileUDF.java b/src/main/java/org/apache/datasketches/hive/tuple/DoubleSummarySketchToPercentileUDF.java
similarity index 57%
rename from src/main/java/com/yahoo/sketches/hive/tuple/DoubleSummarySketchToPercentileUDF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/DoubleSummarySketchToPercentileUDF.java
index 0bf99c7..484d002 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/DoubleSummarySketchToPercentileUDF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/DoubleSummarySketchToPercentileUDF.java
@@ -1,24 +1,37 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.quantiles.UpdateDoublesSketch;
+import org.apache.datasketches.tuple.Sketch;
+import org.apache.datasketches.tuple.SketchIterator;
+import org.apache.datasketches.tuple.Sketches;
+import org.apache.datasketches.tuple.SummaryDeserializer;
+import org.apache.datasketches.tuple.adouble.DoubleSummary;
+import org.apache.datasketches.tuple.adouble.DoubleSummaryDeserializer;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.quantiles.UpdateDoublesSketch;
-import com.yahoo.sketches.tuple.DoubleSummary;
-import com.yahoo.sketches.tuple.DoubleSummaryDeserializer;
-import com.yahoo.sketches.tuple.Sketch;
-import com.yahoo.sketches.tuple.SketchIterator;
-import com.yahoo.sketches.tuple.Sketches;
-import com.yahoo.sketches.tuple.SummaryDeserializer;
-
@Description(
name = "DoubleSummarySketchToPercentile",
value = "_FUNC_(sketch)",
diff --git a/src/main/java/com/yahoo/sketches/hive/cpc/ObjectInspectorValidator.java b/src/main/java/org/apache/datasketches/hive/tuple/ObjectInspectorValidator.java
similarity index 69%
rename from src/main/java/com/yahoo/sketches/hive/cpc/ObjectInspectorValidator.java
rename to src/main/java/org/apache/datasketches/hive/tuple/ObjectInspectorValidator.java
index d306c2e..02367db 100644
--- a/src/main/java/com/yahoo/sketches/hive/cpc/ObjectInspectorValidator.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/ObjectInspectorValidator.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.tuple;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/SketchEvaluator.java b/src/main/java/org/apache/datasketches/hive/tuple/SketchEvaluator.java
similarity index 77%
rename from src/main/java/com/yahoo/sketches/hive/tuple/SketchEvaluator.java
rename to src/main/java/org/apache/datasketches/hive/tuple/SketchEvaluator.java
index 2ccaa28..add93de 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/SketchEvaluator.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/SketchEvaluator.java
@@ -1,12 +1,33 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.Arrays;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.Sketch;
+import org.apache.datasketches.tuple.Sketches;
+import org.apache.datasketches.tuple.Summary;
+import org.apache.datasketches.tuple.SummaryDeserializer;
+import org.apache.datasketches.tuple.SummaryFactory;
+import org.apache.datasketches.tuple.SummarySetOperations;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
@@ -14,14 +35,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.IntWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.Sketch;
-import com.yahoo.sketches.tuple.Sketches;
-import com.yahoo.sketches.tuple.Summary;
-import com.yahoo.sketches.tuple.SummaryDeserializer;
-import com.yahoo.sketches.tuple.SummaryFactory;
-import com.yahoo.sketches.tuple.SummarySetOperations;
-
abstract class SketchEvaluator<S extends Summary> extends GenericUDAFEvaluator {
protected static final String NOMINAL_NUM_ENTRIES_FIELD = "nominalEntries";
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/SketchState.java b/src/main/java/org/apache/datasketches/hive/tuple/SketchState.java
similarity index 66%
rename from src/main/java/com/yahoo/sketches/hive/tuple/SketchState.java
rename to src/main/java/org/apache/datasketches/hive/tuple/SketchState.java
index b3379f9..1556e01 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/SketchState.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/SketchState.java
@@ -1,19 +1,32 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
+import org.apache.datasketches.tuple.Sketch;
+import org.apache.datasketches.tuple.SummaryFactory;
+import org.apache.datasketches.tuple.UpdatableSketch;
+import org.apache.datasketches.tuple.UpdatableSketchBuilder;
+import org.apache.datasketches.tuple.UpdatableSummary;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.sketches.tuple.Sketch;
-import com.yahoo.sketches.tuple.SummaryFactory;
-import com.yahoo.sketches.tuple.UpdatableSketch;
-import com.yahoo.sketches.tuple.UpdatableSketchBuilder;
-import com.yahoo.sketches.tuple.UpdatableSummary;
-
class SketchState<U, S extends UpdatableSummary<U>> extends State<S> {
private UpdatableSketch<U, S> sketch_;
diff --git a/src/main/java/org/apache/datasketches/hive/tuple/State.java b/src/main/java/org/apache/datasketches/hive/tuple/State.java
new file mode 100644
index 0000000..e2d774a
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/tuple/State.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.tuple;
+
+import org.apache.datasketches.tuple.Sketch;
+import org.apache.datasketches.tuple.Summary;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
+
+abstract class State<S extends Summary> extends AbstractAggregationBuffer {
+
+ private int nominalNumEntries_;
+
+ void init(final int nominalNumEntries) {
+ nominalNumEntries_ = nominalNumEntries;
+ }
+
+ int getNominalNumEntries() {
+ return nominalNumEntries_;
+ }
+
+ abstract Sketch<S> getResult();
+
+ abstract void reset();
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/UnionArrayOfDoublesSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/tuple/UnionArrayOfDoublesSketchUDAF.java
similarity index 85%
rename from src/main/java/com/yahoo/sketches/hive/tuple/UnionArrayOfDoublesSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/UnionArrayOfDoublesSketchUDAF.java
index d169f49..324ef06 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/UnionArrayOfDoublesSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/UnionArrayOfDoublesSketchUDAF.java
@@ -1,14 +1,30 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
-import static com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES;
+import static org.apache.datasketches.Util.DEFAULT_NOMINAL_ENTRIES;
import java.util.Arrays;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.ArrayOfDoublesSketches;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
@@ -25,9 +41,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;
-
@Description(
name = "UnionArrayOfDoublesSketch",
value = "_FUNC_(sketch, nominal number of entries, number of values)",
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/UnionDoubleSummarySketchUDAF.java b/src/main/java/org/apache/datasketches/hive/tuple/UnionDoubleSummarySketchUDAF.java
similarity index 65%
rename from src/main/java/com/yahoo/sketches/hive/tuple/UnionDoubleSummarySketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/UnionDoubleSummarySketchUDAF.java
index 4275079..37a7afa 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/UnionDoubleSummarySketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/UnionDoubleSummarySketchUDAF.java
@@ -1,20 +1,33 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
+import org.apache.datasketches.tuple.SummaryDeserializer;
+import org.apache.datasketches.tuple.SummaryFactory;
+import org.apache.datasketches.tuple.SummarySetOperations;
+import org.apache.datasketches.tuple.adouble.DoubleSummary;
+import org.apache.datasketches.tuple.adouble.DoubleSummaryDeserializer;
+import org.apache.datasketches.tuple.adouble.DoubleSummarySetOperations;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
-import com.yahoo.sketches.tuple.DoubleSummary;
-import com.yahoo.sketches.tuple.DoubleSummaryDeserializer;
-import com.yahoo.sketches.tuple.DoubleSummarySetOperations;
-import com.yahoo.sketches.tuple.SummaryDeserializer;
-import com.yahoo.sketches.tuple.SummaryFactory;
-import com.yahoo.sketches.tuple.SummarySetOperations;
-
/**
* This simple implementation is to give an example of a concrete UDAF based on the abstract
* UnionSketchUDAF if no extra arguments are needed.. The same functionality is included into
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/UnionDoubleSummaryWithModeSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/tuple/UnionDoubleSummaryWithModeSketchUDAF.java
similarity index 82%
rename from src/main/java/com/yahoo/sketches/hive/tuple/UnionDoubleSummaryWithModeSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/UnionDoubleSummaryWithModeSketchUDAF.java
index 79db2f3..feb8ff2 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/UnionDoubleSummaryWithModeSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/UnionDoubleSummaryWithModeSketchUDAF.java
@@ -1,12 +1,33 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.Arrays;
+import org.apache.datasketches.tuple.Sketch;
+import org.apache.datasketches.tuple.SummaryDeserializer;
+import org.apache.datasketches.tuple.SummaryFactory;
+import org.apache.datasketches.tuple.SummarySetOperations;
+import org.apache.datasketches.tuple.adouble.DoubleSummary;
+import org.apache.datasketches.tuple.adouble.DoubleSummaryDeserializer;
+import org.apache.datasketches.tuple.adouble.DoubleSummarySetOperations;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -22,14 +43,6 @@ import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
-import com.yahoo.sketches.tuple.DoubleSummary;
-import com.yahoo.sketches.tuple.DoubleSummaryDeserializer;
-import com.yahoo.sketches.tuple.DoubleSummarySetOperations;
-import com.yahoo.sketches.tuple.Sketch;
-import com.yahoo.sketches.tuple.SummaryDeserializer;
-import com.yahoo.sketches.tuple.SummaryFactory;
-import com.yahoo.sketches.tuple.SummarySetOperations;
-
/**
* This is an example of a concrete UDAF based on the abstract UnionSketchUDAF if extra arguments
* are needed. For a simpler example with no extra arguments see UnionDoubleSummarySketchUDAF.
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/UnionSketchUDAF.java b/src/main/java/org/apache/datasketches/hive/tuple/UnionSketchUDAF.java
similarity index 82%
rename from src/main/java/com/yahoo/sketches/hive/tuple/UnionSketchUDAF.java
rename to src/main/java/org/apache/datasketches/hive/tuple/UnionSketchUDAF.java
index 05950e6..f097ff1 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/UnionSketchUDAF.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/UnionSketchUDAF.java
@@ -1,14 +1,31 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
-import static com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES;
+import static org.apache.datasketches.Util.DEFAULT_NOMINAL_ENTRIES;
import java.util.Arrays;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.tuple.Sketches;
+import org.apache.datasketches.tuple.Summary;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.parse.SemanticException;
@@ -23,10 +40,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.tuple.Sketches;
-import com.yahoo.sketches.tuple.Summary;
-
/**
* Generic implementation to be sub-classed with a particular type of Summary
*/
diff --git a/src/main/java/org/apache/datasketches/hive/tuple/UnionState.java b/src/main/java/org/apache/datasketches/hive/tuple/UnionState.java
new file mode 100644
index 0000000..90b9383
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/hive/tuple/UnionState.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.tuple;
+
+import org.apache.datasketches.tuple.Sketch;
+import org.apache.datasketches.tuple.Summary;
+import org.apache.datasketches.tuple.SummarySetOperations;
+import org.apache.datasketches.tuple.Union;
+
+class UnionState<S extends Summary> extends State<S> {
+
+ private Union<S> union_;
+
+ boolean isInitialized() {
+ return union_ != null;
+ }
+
+ void init(final int nominalNumEntries, final SummarySetOperations<S> summarySetOps) {
+ super.init(nominalNumEntries);
+ union_ = new Union<S>(nominalNumEntries, summarySetOps);
+ }
+
+ void update(final Sketch<S> sketch) {
+ union_.update(sketch);
+ }
+
+ @Override
+ Sketch<S> getResult() {
+ if (union_ == null) { return null; }
+ return union_.getResult();
+ }
+
+ @Override
+ void reset() {
+ union_ = null;
+ }
+
+}
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/package-info.java b/src/main/java/org/apache/datasketches/hive/tuple/package-info.java
similarity index 58%
rename from src/main/java/com/yahoo/sketches/hive/tuple/package-info.java
rename to src/main/java/org/apache/datasketches/hive/tuple/package-info.java
index 5eabc94..366905c 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/package-info.java
+++ b/src/main/java/org/apache/datasketches/hive/tuple/package-info.java
@@ -1,7 +1,22 @@
/*
- * Copyright 2016, Yahoo! Inc. Licensed under the terms of the Apache License 2.0. See LICENSE file
- * at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
+
/**
* Hive UDFs for Tuple sketches.
* Tuple sketches are based on the idea of Theta sketches with the addition of
@@ -24,4 +39,4 @@
*
* @author Alexander Saydakov
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
diff --git a/src/test/java/com/yahoo/sketches/hive/kll/GetNUDFTest.java b/src/test/java/com/yahoo/sketches/hive/kll/GetNUDFTest.java
deleted file mode 100644
index 11ce0ca..0000000
--- a/src/test/java/com/yahoo/sketches/hive/kll/GetNUDFTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.kll;
-
-import org.apache.hadoop.io.BytesWritable;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
-@SuppressWarnings("javadoc")
-public class GetNUDFTest {
-
- @Test
- public void nullSketch() {
- final Long result = new GetNUDF().evaluate(null);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- KllFloatsSketch sketch = new KllFloatsSketch();
- sketch.update(1);
- sketch.update(2);
- sketch.update(3);
- sketch.update(4);
- final Long result = new GetNUDF().evaluate(new BytesWritable(sketch.toByteArray()));
- Assert.assertNotNull(result);
- Assert.assertEquals(result, Long.valueOf(4));
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/kll/GetQuantileUDFTest.java b/src/test/java/com/yahoo/sketches/hive/kll/GetQuantileUDFTest.java
deleted file mode 100644
index 9993ffa..0000000
--- a/src/test/java/com/yahoo/sketches/hive/kll/GetQuantileUDFTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.kll;
-
-import org.apache.hadoop.io.BytesWritable;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
-@SuppressWarnings("javadoc")
-public class GetQuantileUDFTest {
-
- @Test
- public void nullSketch() {
- final Float result = new GetQuantileUDF().evaluate(null, 0);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- KllFloatsSketch sketch = new KllFloatsSketch();
- sketch.update(1);
- sketch.update(2);
- sketch.update(3);
- final Float result = new GetQuantileUDF().evaluate(new BytesWritable(sketch.toByteArray()), 0.5);
- Assert.assertNotNull(result);
- Assert.assertEquals(result, 2f);
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/kll/GetRankUDFTest.java b/src/test/java/com/yahoo/sketches/hive/kll/GetRankUDFTest.java
deleted file mode 100644
index a568139..0000000
--- a/src/test/java/com/yahoo/sketches/hive/kll/GetRankUDFTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.kll;
-
-import org.apache.hadoop.io.BytesWritable;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
-@SuppressWarnings("javadoc")
-public class GetRankUDFTest {
-
- @Test
- public void nullSketch() {
- final Double result = new GetRankUDF().evaluate(null, 0);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- KllFloatsSketch sketch = new KllFloatsSketch();
- sketch.update(1);
- sketch.update(2);
- sketch.update(3);
- sketch.update(4);
- final Double result = new GetRankUDF().evaluate(new BytesWritable(sketch.toByteArray()), 3f);
- Assert.assertNotNull(result);
- Assert.assertEquals(result, 0.5);
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/kll/SektchToStringUDFTest.java b/src/test/java/com/yahoo/sketches/hive/kll/SektchToStringUDFTest.java
deleted file mode 100644
index 9a3263a..0000000
--- a/src/test/java/com/yahoo/sketches/hive/kll/SektchToStringUDFTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.kll;
-
-import org.apache.hadoop.io.BytesWritable;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.yahoo.sketches.kll.KllFloatsSketch;
-
-@SuppressWarnings("javadoc")
-public class SektchToStringUDFTest {
-
- @Test
- public void nullSketch() {
- final String result = new SketchToStringUDF().evaluate(null);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- KllFloatsSketch sketch = new KllFloatsSketch();
- sketch.update(1);
- sketch.update(2);
- sketch.update(3);
- sketch.update(4);
- final String result = new SketchToStringUDF().evaluate(new BytesWritable(sketch.toByteArray()));
- Assert.assertNotNull(result);
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/DoublesSektchToStringUDFTest.java b/src/test/java/com/yahoo/sketches/hive/quantiles/DoublesSektchToStringUDFTest.java
deleted file mode 100644
index f5771c4..0000000
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/DoublesSektchToStringUDFTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import com.yahoo.sketches.quantiles.DoublesSketch;
-
-import org.testng.annotations.Test;
-import org.apache.hadoop.io.BytesWritable;
-import org.testng.Assert;
-
-@SuppressWarnings("javadoc")
-public class DoublesSektchToStringUDFTest {
-
- @Test
- public void nullSketch() {
- final String result = new DoublesSketchToStringUDF().evaluate(null);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- final DoublesSketch sketch = DoublesSketch.builder().build();
- final String result = new DoublesSketchToStringUDF().evaluate(new BytesWritable(sketch.toByteArray()));
- Assert.assertNotNull(result);
- Assert.assertTrue(result.length() > 0);
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetKFromDoublesSektchUDFTest.java b/src/test/java/com/yahoo/sketches/hive/quantiles/GetKFromDoublesSektchUDFTest.java
deleted file mode 100644
index 4ad4621..0000000
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetKFromDoublesSektchUDFTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-package com.yahoo.sketches.hive.quantiles;
-
-import com.yahoo.sketches.quantiles.DoublesSketch;
-
-import org.testng.annotations.Test;
-import org.apache.hadoop.io.BytesWritable;
-import org.testng.Assert;
-
-@SuppressWarnings("javadoc")
-public class GetKFromDoublesSektchUDFTest {
-
- @Test
- public void nullSketch() {
- Integer result = new GetKFromDoublesSketchUDF().evaluate(null);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- DoublesSketch sketch = DoublesSketch.builder().build();
- Integer result = new GetKFromDoublesSketchUDF().evaluate(new BytesWritable(sketch.toByteArray()));
- Assert.assertNotNull(result);
- Assert.assertEquals(result, Integer.valueOf(128));
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetKFromStringsSketchUDFTest.java b/src/test/java/com/yahoo/sketches/hive/quantiles/GetKFromStringsSketchUDFTest.java
deleted file mode 100644
index e8cdf4b..0000000
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetKFromStringsSketchUDFTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-package com.yahoo.sketches.hive.quantiles;
-
-import java.util.Comparator;
-
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
-import org.testng.annotations.Test;
-import org.testng.Assert;
-
-@SuppressWarnings("javadoc")
-public class GetKFromStringsSketchUDFTest {
-
- static final Comparator<String> comparator = Comparator.naturalOrder();
- static final ArrayOfItemsSerDe<String> serDe = new ArrayOfStringsSerDe();
-
- @Test
- public void nullSketch() {
- Integer result = new GetKFromStringsSketchUDF().evaluate(null);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- ItemsSketch<String> sketch = ItemsSketch.getInstance(comparator);
- Integer result = new GetKFromStringsSketchUDF().evaluate(new BytesWritable(sketch.toByteArray(serDe)));
- Assert.assertNotNull(result);
- Assert.assertEquals(result, Integer.valueOf(128));
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetNFromDoublesSektchUDFTest.java b/src/test/java/com/yahoo/sketches/hive/quantiles/GetNFromDoublesSektchUDFTest.java
deleted file mode 100644
index 6b4b084..0000000
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetNFromDoublesSektchUDFTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.quantiles.UpdateDoublesSketch;
-
-import org.testng.annotations.Test;
-import org.apache.hadoop.io.BytesWritable;
-import org.testng.Assert;
-
-@SuppressWarnings("javadoc")
-public class GetNFromDoublesSektchUDFTest {
-
- @Test
- public void nullSketch() {
- Long result = new GetNFromDoublesSketchUDF().evaluate(null);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- UpdateDoublesSketch sketch = DoublesSketch.builder().build();
- sketch.update(1);
- sketch.update(2);
- sketch.update(3);
- Long result = new GetNFromDoublesSketchUDF().evaluate(new BytesWritable(sketch.toByteArray()));
- Assert.assertNotNull(result);
- Assert.assertEquals(result, Long.valueOf(3));
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetNFromStringsSketchUDFTest.java b/src/test/java/com/yahoo/sketches/hive/quantiles/GetNFromStringsSketchUDFTest.java
deleted file mode 100644
index 6116ce4..0000000
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetNFromStringsSketchUDFTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import java.util.Comparator;
-
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
-import org.testng.annotations.Test;
-import org.testng.Assert;
-
-@SuppressWarnings("javadoc")
-public class GetNFromStringsSketchUDFTest {
-
- static final Comparator<String> comparator = Comparator.naturalOrder();
- static final ArrayOfItemsSerDe<String> serDe = new ArrayOfStringsSerDe();
-
- @Test
- public void nullSketch() {
- Long result = new GetNFromStringsSketchUDF().evaluate(null);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- ItemsSketch<String> sketch = ItemsSketch.getInstance(comparator);
- sketch.update("a");
- sketch.update("b");
- sketch.update("c");
- Long result = new GetNFromStringsSketchUDF().evaluate(new BytesWritable(sketch.toByteArray(serDe)));
- Assert.assertNotNull(result);
- Assert.assertEquals(result, Long.valueOf(3));
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromDoublesSektchUDFTest.java b/src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromDoublesSektchUDFTest.java
deleted file mode 100644
index f38390b..0000000
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromDoublesSektchUDFTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-package com.yahoo.sketches.hive.quantiles;
-
-import org.apache.hadoop.io.BytesWritable;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.quantiles.UpdateDoublesSketch;
-
-@SuppressWarnings("javadoc")
-public class GetQuantileFromDoublesSektchUDFTest {
-
- @Test
- public void nullSketch() {
- Double result = new GetQuantileFromDoublesSketchUDF().evaluate(null, 0);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- UpdateDoublesSketch sketch = DoublesSketch.builder().build();
- sketch.update(1);
- sketch.update(2);
- sketch.update(3);
- Double result = new GetQuantileFromDoublesSketchUDF().evaluate(new BytesWritable(sketch.toByteArray()), 0.5);
- Assert.assertNotNull(result);
- Assert.assertEquals(result, 2.0);
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/StringsSketchToStringUDFTest.java b/src/test/java/com/yahoo/sketches/hive/quantiles/StringsSketchToStringUDFTest.java
deleted file mode 100644
index 12e5941..0000000
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/StringsSketchToStringUDFTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
- */
-
-package com.yahoo.sketches.hive.quantiles;
-
-import java.util.Comparator;
-
-import org.apache.hadoop.io.BytesWritable;
-
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
-
-import org.testng.annotations.Test;
-import org.testng.Assert;
-
-@SuppressWarnings("javadoc")
-public class StringsSketchToStringUDFTest {
-
- static final Comparator<String> COMPARATOR = Comparator.naturalOrder();
- static final ArrayOfItemsSerDe<String> SERDE = new ArrayOfStringsSerDe();
-
- @Test
- public void nullSketch() {
- final String result = new StringsSketchToStringUDF().evaluate(null);
- Assert.assertNull(result);
- }
-
- @Test
- public void normalCase() {
- final ItemsSketch<String> sketch = ItemsSketch.getInstance(COMPARATOR);
- final String result = new StringsSketchToStringUDF().evaluate(new BytesWritable(sketch.toByteArray(SERDE)));
- Assert.assertNotNull(result);
- Assert.assertTrue(result.length() > 0);
- }
-
-}
diff --git a/src/test/java/com/yahoo/sketches/hive/cpc/DataToSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/cpc/DataToSketchUDAFTest.java
similarity index 94%
rename from src/test/java/com/yahoo/sketches/hive/cpc/DataToSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/cpc/DataToSketchUDAFTest.java
index e59f80c..9fdb113 100644
--- a/src/test/java/com/yahoo/sketches/hive/cpc/DataToSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/cpc/DataToSketchUDAFTest.java
@@ -1,11 +1,25 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
import java.util.List;
@@ -33,8 +47,8 @@ import org.apache.hadoop.io.Text;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.cpc.CpcSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.cpc.CpcSketch;
@SuppressWarnings("javadoc")
public class DataToSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/cpc/GetEstimateAndErrorBoundsUDFTest.java b/src/test/java/org/apache/datasketches/hive/cpc/GetEstimateAndErrorBoundsUDFTest.java
similarity index 70%
rename from src/test/java/com/yahoo/sketches/hive/cpc/GetEstimateAndErrorBoundsUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/cpc/GetEstimateAndErrorBoundsUDFTest.java
index c1ae592..bdfefac 100644
--- a/src/test/java/com/yahoo/sketches/hive/cpc/GetEstimateAndErrorBoundsUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/cpc/GetEstimateAndErrorBoundsUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
import java.util.List;
@@ -11,7 +25,7 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.cpc.CpcSketch;
+import org.apache.datasketches.cpc.CpcSketch;
@SuppressWarnings("javadoc")
public class GetEstimateAndErrorBoundsUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/cpc/GetEstimateUDFTest.java b/src/test/java/org/apache/datasketches/hive/cpc/GetEstimateUDFTest.java
similarity index 58%
rename from src/test/java/com/yahoo/sketches/hive/cpc/GetEstimateUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/cpc/GetEstimateUDFTest.java
index 16e1b67..6f5c3d1 100644
--- a/src/test/java/com/yahoo/sketches/hive/cpc/GetEstimateUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/cpc/GetEstimateUDFTest.java
@@ -1,15 +1,29 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.cpc.CpcSketch;
+import org.apache.datasketches.cpc.CpcSketch;
@SuppressWarnings("javadoc")
public class GetEstimateUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/cpc/SketchToStringUDFTest.java b/src/test/java/org/apache/datasketches/hive/cpc/SketchToStringUDFTest.java
similarity index 58%
rename from src/test/java/com/yahoo/sketches/hive/cpc/SketchToStringUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/cpc/SketchToStringUDFTest.java
index e9aa6e5..2c49092 100644
--- a/src/test/java/com/yahoo/sketches/hive/cpc/SketchToStringUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/cpc/SketchToStringUDFTest.java
@@ -1,15 +1,29 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.cpc.CpcSketch;
+import org.apache.datasketches.cpc.CpcSketch;
@SuppressWarnings("javadoc")
public class SketchToStringUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/cpc/UnionSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/cpc/UnionSketchUDAFTest.java
similarity index 94%
rename from src/test/java/com/yahoo/sketches/hive/cpc/UnionSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/cpc/UnionSketchUDAFTest.java
index 13e9255..4734fea 100644
--- a/src/test/java/com/yahoo/sketches/hive/cpc/UnionSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/cpc/UnionSketchUDAFTest.java
@@ -1,11 +1,25 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
import java.util.List;
@@ -28,8 +42,8 @@ import org.apache.hadoop.io.LongWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.cpc.CpcSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.cpc.CpcSketch;
@SuppressWarnings("javadoc")
public class UnionSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/cpc/UnionSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/cpc/UnionSketchUDFTest.java
similarity index 75%
rename from src/test/java/com/yahoo/sketches/hive/cpc/UnionSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/cpc/UnionSketchUDFTest.java
index 0ce994e..56bff15 100644
--- a/src/test/java/com/yahoo/sketches/hive/cpc/UnionSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/cpc/UnionSketchUDFTest.java
@@ -1,16 +1,30 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.cpc;
+package org.apache.datasketches.hive.cpc;
import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.cpc.CpcSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.cpc.CpcSketch;
@SuppressWarnings("javadoc")
public class UnionSketchUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/frequencies/DataToStringsSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/frequencies/DataToStringsSketchUDAFTest.java
similarity index 88%
rename from src/test/java/com/yahoo/sketches/hive/frequencies/DataToStringsSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/frequencies/DataToStringsSketchUDAFTest.java
index 4e9d887..b58774f 100644
--- a/src/test/java/com/yahoo/sketches/hive/frequencies/DataToStringsSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/frequencies/DataToStringsSketchUDAFTest.java
@@ -1,8 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.frequencies;
+
+package org.apache.datasketches.hive.frequencies;
import java.util.Arrays;
@@ -21,10 +36,10 @@ import org.apache.hadoop.io.IntWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.frequencies.ItemsSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.frequencies.ItemsSketch;
@SuppressWarnings("javadoc")
public class DataToStringsSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTFTest.java b/src/test/java/org/apache/datasketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTFTest.java
similarity index 86%
rename from src/test/java/com/yahoo/sketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTFTest.java
rename to src/test/java/org/apache/datasketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTFTest.java
index 055c9f9..a8fd68e 100644
--- a/src/test/java/com/yahoo/sketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/frequencies/GetFrequentItemsFromStringsSketchUDTFTest.java
@@ -1,8 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.frequencies;
+
+package org.apache.datasketches.hive.frequencies;
import java.util.ArrayList;
import java.util.Arrays;
@@ -23,9 +38,9 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.frequencies.ItemsSketch;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.frequencies.ItemsSketch;
@SuppressWarnings("javadoc")
public class GetFrequentItemsFromStringsSketchUDTFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/frequencies/UnionStringsSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/frequencies/UnionStringsSketchUDAFTest.java
similarity index 84%
rename from src/test/java/com/yahoo/sketches/hive/frequencies/UnionStringsSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/frequencies/UnionStringsSketchUDAFTest.java
index e8cbba5..71f62f6 100644
--- a/src/test/java/com/yahoo/sketches/hive/frequencies/UnionStringsSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/frequencies/UnionStringsSketchUDAFTest.java
@@ -1,8 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.frequencies;
+
+package org.apache.datasketches.hive.frequencies;
import java.util.Arrays;
@@ -21,10 +36,10 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.frequencies.ItemsSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.frequencies.ItemsSketch;
@SuppressWarnings("javadoc")
public class UnionStringsSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/hll/DataToSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/hll/DataToSketchUDAFTest.java
similarity index 94%
rename from src/test/java/com/yahoo/sketches/hive/hll/DataToSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/hll/DataToSketchUDAFTest.java
index 3385136..22f9ce7 100644
--- a/src/test/java/com/yahoo/sketches/hive/hll/DataToSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/hll/DataToSketchUDAFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
import java.util.Arrays;
import java.util.List;
@@ -30,9 +44,9 @@ import org.apache.hadoop.io.Text;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.hll.HllSketch;
-import com.yahoo.sketches.hll.TgtHllType;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.hll.TgtHllType;
@SuppressWarnings("javadoc")
public class DataToSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/hll/SketchToEstimateAndErrorBoundsUDFTest.java b/src/test/java/org/apache/datasketches/hive/hll/SketchToEstimateAndErrorBoundsUDFTest.java
similarity index 66%
rename from src/test/java/com/yahoo/sketches/hive/hll/SketchToEstimateAndErrorBoundsUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/hll/SketchToEstimateAndErrorBoundsUDFTest.java
index 81e009b..31162fc 100644
--- a/src/test/java/com/yahoo/sketches/hive/hll/SketchToEstimateAndErrorBoundsUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/hll/SketchToEstimateAndErrorBoundsUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
import java.util.List;
@@ -11,7 +25,7 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.hll.HllSketch;
+import org.apache.datasketches.hll.HllSketch;
@SuppressWarnings("javadoc")
public class SketchToEstimateAndErrorBoundsUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/hll/SketchToEstimateUDFTest.java b/src/test/java/org/apache/datasketches/hive/hll/SketchToEstimateUDFTest.java
similarity index 50%
rename from src/test/java/com/yahoo/sketches/hive/hll/SketchToEstimateUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/hll/SketchToEstimateUDFTest.java
index 64d290a..761d3bf 100644
--- a/src/test/java/com/yahoo/sketches/hive/hll/SketchToEstimateUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/hll/SketchToEstimateUDFTest.java
@@ -1,15 +1,29 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.hll.HllSketch;
+import org.apache.datasketches.hll.HllSketch;
@SuppressWarnings("javadoc")
public class SketchToEstimateUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/hll/SketchToStringUDFTest.java b/src/test/java/org/apache/datasketches/hive/hll/SketchToStringUDFTest.java
similarity index 50%
rename from src/test/java/com/yahoo/sketches/hive/hll/SketchToStringUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/hll/SketchToStringUDFTest.java
index 1e6c5ac..be0d8ad 100644
--- a/src/test/java/com/yahoo/sketches/hive/hll/SketchToStringUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/hll/SketchToStringUDFTest.java
@@ -1,15 +1,29 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.hll.HllSketch;
+import org.apache.datasketches.hll.HllSketch;
@SuppressWarnings("javadoc")
public class SketchToStringUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/hll/UnionSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/hll/UnionSketchUDAFTest.java
similarity index 94%
rename from src/test/java/com/yahoo/sketches/hive/hll/UnionSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/hll/UnionSketchUDAFTest.java
index c9b283e..b9705c1 100644
--- a/src/test/java/com/yahoo/sketches/hive/hll/UnionSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/hll/UnionSketchUDAFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+package org.apache.datasketches.hive.hll;
import java.util.Arrays;
import java.util.List;
@@ -26,9 +40,9 @@ import org.apache.hadoop.io.Text;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.hll.HllSketch;
-import com.yahoo.sketches.hll.TgtHllType;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.hll.TgtHllType;
@SuppressWarnings("javadoc")
public class UnionSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/hll/UnionSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/hll/UnionSketchUDFTest.java
similarity index 68%
rename from src/test/java/com/yahoo/sketches/hive/hll/UnionSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/hll/UnionSketchUDFTest.java
index d68cc72..ddb0b1c 100644
--- a/src/test/java/com/yahoo/sketches/hive/hll/UnionSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/hll/UnionSketchUDFTest.java
@@ -1,16 +1,31 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.hll;
+
+package org.apache.datasketches.hive.hll;
import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.hll.HllSketch;
-import com.yahoo.sketches.hll.TgtHllType;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.hll.HllSketch;
+import org.apache.datasketches.hll.TgtHllType;
@SuppressWarnings("javadoc")
public class UnionSketchUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/kll/DataToSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/kll/DataToSketchUDAFTest.java
similarity index 92%
rename from src/test/java/com/yahoo/sketches/hive/kll/DataToSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/kll/DataToSketchUDAFTest.java
index 3edfd68..4d746e7 100644
--- a/src/test/java/com/yahoo/sketches/hive/kll/DataToSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/kll/DataToSketchUDAFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import java.util.Arrays;
@@ -23,8 +37,8 @@ import org.apache.hadoop.io.IntWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.kll.KllFloatsSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.kll.KllFloatsSketch;
@SuppressWarnings("javadoc")
public class DataToSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/kll/GetCdfUDFTest.java b/src/test/java/org/apache/datasketches/hive/kll/GetCdfUDFTest.java
similarity index 62%
rename from src/test/java/com/yahoo/sketches/hive/kll/GetCdfUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/kll/GetCdfUDFTest.java
index 085cdd1..f491477 100644
--- a/src/test/java/com/yahoo/sketches/hive/kll/GetCdfUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/kll/GetCdfUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import java.util.List;
@@ -11,7 +25,7 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.kll.KllFloatsSketch;
+import org.apache.datasketches.kll.KllFloatsSketch;
@SuppressWarnings("javadoc")
public class GetCdfUDFTest {
diff --git a/src/test/java/org/apache/datasketches/hive/kll/GetNUDFTest.java b/src/test/java/org/apache/datasketches/hive/kll/GetNUDFTest.java
new file mode 100644
index 0000000..53d6458
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/kll/GetNUDFTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.kll;
+
+import org.apache.hadoop.io.BytesWritable;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.datasketches.kll.KllFloatsSketch;
+
+@SuppressWarnings("javadoc")
+public class GetNUDFTest {
+
+ @Test
+ public void nullSketch() {
+ final Long result = new GetNUDF().evaluate(null);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ KllFloatsSketch sketch = new KllFloatsSketch();
+ sketch.update(1);
+ sketch.update(2);
+ sketch.update(3);
+ sketch.update(4);
+ final Long result = new GetNUDF().evaluate(new BytesWritable(sketch.toByteArray()));
+ Assert.assertNotNull(result);
+ Assert.assertEquals(result, Long.valueOf(4));
+ }
+
+}
diff --git a/src/test/java/com/yahoo/sketches/hive/kll/GetPmfUDFTest.java b/src/test/java/org/apache/datasketches/hive/kll/GetPmfUDFTest.java
similarity index 62%
rename from src/test/java/com/yahoo/sketches/hive/kll/GetPmfUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/kll/GetPmfUDFTest.java
index 1e9f41b..3f525f6 100644
--- a/src/test/java/com/yahoo/sketches/hive/kll/GetPmfUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/kll/GetPmfUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import java.util.List;
@@ -11,7 +25,7 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.kll.KllFloatsSketch;
+import org.apache.datasketches.kll.KllFloatsSketch;
@SuppressWarnings("javadoc")
public class GetPmfUDFTest {
diff --git a/src/test/java/org/apache/datasketches/hive/kll/GetQuantileUDFTest.java b/src/test/java/org/apache/datasketches/hive/kll/GetQuantileUDFTest.java
new file mode 100644
index 0000000..c005d35
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/kll/GetQuantileUDFTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.kll;
+
+import org.apache.hadoop.io.BytesWritable;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.datasketches.kll.KllFloatsSketch;
+
+@SuppressWarnings("javadoc")
+public class GetQuantileUDFTest {
+
+ @Test
+ public void nullSketch() {
+ final Float result = new GetQuantileUDF().evaluate(null, 0);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ KllFloatsSketch sketch = new KllFloatsSketch();
+ sketch.update(1);
+ sketch.update(2);
+ sketch.update(3);
+ final Float result = new GetQuantileUDF().evaluate(new BytesWritable(sketch.toByteArray()), 0.5);
+ Assert.assertNotNull(result);
+ Assert.assertEquals(result, 2f);
+ }
+
+}
diff --git a/src/test/java/com/yahoo/sketches/hive/kll/GetQuantilesUDFTest.java b/src/test/java/org/apache/datasketches/hive/kll/GetQuantilesUDFTest.java
similarity index 57%
rename from src/test/java/com/yahoo/sketches/hive/kll/GetQuantilesUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/kll/GetQuantilesUDFTest.java
index 6fe8ba8..f95b217 100644
--- a/src/test/java/com/yahoo/sketches/hive/kll/GetQuantilesUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/kll/GetQuantilesUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import java.util.List;
@@ -11,7 +25,7 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.kll.KllFloatsSketch;
+import org.apache.datasketches.kll.KllFloatsSketch;
@SuppressWarnings("javadoc")
public class GetQuantilesUDFTest {
diff --git a/src/test/java/org/apache/datasketches/hive/kll/GetRankUDFTest.java b/src/test/java/org/apache/datasketches/hive/kll/GetRankUDFTest.java
new file mode 100644
index 0000000..fb25de8
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/kll/GetRankUDFTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.kll;
+
+import org.apache.hadoop.io.BytesWritable;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.datasketches.kll.KllFloatsSketch;
+
+@SuppressWarnings("javadoc")
+public class GetRankUDFTest {
+
+ @Test
+ public void nullSketch() {
+ final Double result = new GetRankUDF().evaluate(null, 0);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ KllFloatsSketch sketch = new KllFloatsSketch();
+ sketch.update(1);
+ sketch.update(2);
+ sketch.update(3);
+ sketch.update(4);
+ final Double result = new GetRankUDF().evaluate(new BytesWritable(sketch.toByteArray()), 3f);
+ Assert.assertNotNull(result);
+ Assert.assertEquals(result, 0.5);
+ }
+
+}
diff --git a/src/test/java/org/apache/datasketches/hive/kll/SektchToStringUDFTest.java b/src/test/java/org/apache/datasketches/hive/kll/SektchToStringUDFTest.java
new file mode 100644
index 0000000..34db524
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/kll/SektchToStringUDFTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.kll;
+
+import org.apache.hadoop.io.BytesWritable;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.datasketches.kll.KllFloatsSketch;
+
+@SuppressWarnings("javadoc")
+public class SektchToStringUDFTest {
+
+ @Test
+ public void nullSketch() {
+ final String result = new SketchToStringUDF().evaluate(null);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ KllFloatsSketch sketch = new KllFloatsSketch();
+ sketch.update(1);
+ sketch.update(2);
+ sketch.update(3);
+ sketch.update(4);
+ final String result = new SketchToStringUDF().evaluate(new BytesWritable(sketch.toByteArray()));
+ Assert.assertNotNull(result);
+ }
+
+}
diff --git a/src/test/java/com/yahoo/sketches/hive/kll/UnionSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/kll/UnionSketchUDAFTest.java
similarity index 91%
rename from src/test/java/com/yahoo/sketches/hive/kll/UnionSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/kll/UnionSketchUDAFTest.java
index da03c1f..b148a78 100644
--- a/src/test/java/com/yahoo/sketches/hive/kll/UnionSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/kll/UnionSketchUDAFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2018, Oath Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.kll;
+package org.apache.datasketches.hive.kll;
import java.util.Arrays;
@@ -22,8 +36,8 @@ import org.apache.hadoop.io.IntWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.kll.KllFloatsSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.kll.KllFloatsSketch;
@SuppressWarnings("javadoc")
public class UnionSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/DataToDoublesSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/DataToDoublesSketchUDAFTest.java
similarity index 91%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/DataToDoublesSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/DataToDoublesSketchUDAFTest.java
index 4d20880..b133de7 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/DataToDoublesSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/DataToDoublesSketchUDAFTest.java
@@ -1,4 +1,23 @@
-package com.yahoo.sketches.hive.quantiles;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
import java.util.Arrays;
@@ -18,9 +37,9 @@ import org.apache.hadoop.io.IntWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.quantiles.UpdateDoublesSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.quantiles.UpdateDoublesSketch;
@SuppressWarnings("javadoc")
public class DataToDoublesSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/DataToStringsSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/DataToStringsSketchUDAFTest.java
similarity index 91%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/DataToStringsSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/DataToStringsSketchUDAFTest.java
index 577c547..d58a8f3 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/DataToStringsSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/DataToStringsSketchUDAFTest.java
@@ -1,4 +1,23 @@
-package com.yahoo.sketches.hive.quantiles;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
import java.util.Arrays;
import java.util.Comparator;
@@ -17,10 +36,10 @@ import org.apache.hadoop.io.IntWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.quantiles.ItemsSketch;
@SuppressWarnings("javadoc")
public class DataToStringsSketchUDAFTest {
diff --git a/src/test/java/org/apache/datasketches/hive/quantiles/DoublesSektchToStringUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/DoublesSektchToStringUDFTest.java
new file mode 100644
index 0000000..75c0a8c
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/DoublesSektchToStringUDFTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import org.apache.datasketches.quantiles.DoublesSketch;
+
+import org.testng.annotations.Test;
+import org.apache.hadoop.io.BytesWritable;
+import org.testng.Assert;
+
+@SuppressWarnings("javadoc")
+public class DoublesSektchToStringUDFTest {
+
+ @Test
+ public void nullSketch() {
+ final String result = new DoublesSketchToStringUDF().evaluate(null);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ final DoublesSketch sketch = DoublesSketch.builder().build();
+ final String result = new DoublesSketchToStringUDF().evaluate(new BytesWritable(sketch.toByteArray()));
+ Assert.assertNotNull(result);
+ Assert.assertTrue(result.length() > 0);
+ }
+
+}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetCdfFromDoublesSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetCdfFromDoublesSketchUDFTest.java
similarity index 62%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/GetCdfFromDoublesSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/GetCdfFromDoublesSketchUDFTest.java
index 56f3583..06f9fd5 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetCdfFromDoublesSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetCdfFromDoublesSketchUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.List;
@@ -11,8 +25,8 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.quantiles.UpdateDoublesSketch;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.quantiles.UpdateDoublesSketch;
@SuppressWarnings("javadoc")
public class GetCdfFromDoublesSketchUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetCdfFromStringsSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetCdfFromStringsSketchUDFTest.java
similarity index 64%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/GetCdfFromStringsSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/GetCdfFromStringsSketchUDFTest.java
index e580ed0..83a96ec 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetCdfFromStringsSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetCdfFromStringsSketchUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2019, Verizon Media.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
import java.util.List;
@@ -13,9 +27,9 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.annotations.Test;
import org.testng.Assert;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.quantiles.ItemsSketch;
@SuppressWarnings("javadoc")
public class GetCdfFromStringsSketchUDFTest {
diff --git a/src/test/java/org/apache/datasketches/hive/quantiles/GetKFromDoublesSektchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetKFromDoublesSektchUDFTest.java
new file mode 100644
index 0000000..e8c02c5
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetKFromDoublesSektchUDFTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import org.apache.datasketches.quantiles.DoublesSketch;
+
+import org.testng.annotations.Test;
+import org.apache.hadoop.io.BytesWritable;
+import org.testng.Assert;
+
+@SuppressWarnings("javadoc")
+public class GetKFromDoublesSektchUDFTest {
+
+ @Test
+ public void nullSketch() {
+ Integer result = new GetKFromDoublesSketchUDF().evaluate(null);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ DoublesSketch sketch = DoublesSketch.builder().build();
+ Integer result = new GetKFromDoublesSketchUDF().evaluate(new BytesWritable(sketch.toByteArray()));
+ Assert.assertNotNull(result);
+ Assert.assertEquals(result, Integer.valueOf(128));
+ }
+
+}
diff --git a/src/test/java/org/apache/datasketches/hive/quantiles/GetKFromStringsSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetKFromStringsSketchUDFTest.java
new file mode 100644
index 0000000..0ffa53c
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetKFromStringsSketchUDFTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import java.util.Comparator;
+
+import org.apache.hadoop.io.BytesWritable;
+
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.quantiles.ItemsSketch;
+
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
+@SuppressWarnings("javadoc")
+public class GetKFromStringsSketchUDFTest {
+
+ static final Comparator<String> comparator = Comparator.naturalOrder();
+ static final ArrayOfItemsSerDe<String> serDe = new ArrayOfStringsSerDe();
+
+ @Test
+ public void nullSketch() {
+ Integer result = new GetKFromStringsSketchUDF().evaluate(null);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ ItemsSketch<String> sketch = ItemsSketch.getInstance(comparator);
+ Integer result = new GetKFromStringsSketchUDF().evaluate(new BytesWritable(sketch.toByteArray(serDe)));
+ Assert.assertNotNull(result);
+ Assert.assertEquals(result, Integer.valueOf(128));
+ }
+
+}
diff --git a/src/test/java/org/apache/datasketches/hive/quantiles/GetNFromDoublesSektchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetNFromDoublesSektchUDFTest.java
new file mode 100644
index 0000000..0215fd0
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetNFromDoublesSektchUDFTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.quantiles.UpdateDoublesSketch;
+
+import org.testng.annotations.Test;
+import org.apache.hadoop.io.BytesWritable;
+import org.testng.Assert;
+
+@SuppressWarnings("javadoc")
+public class GetNFromDoublesSektchUDFTest {
+
+ @Test
+ public void nullSketch() {
+ Long result = new GetNFromDoublesSketchUDF().evaluate(null);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ UpdateDoublesSketch sketch = DoublesSketch.builder().build();
+ sketch.update(1);
+ sketch.update(2);
+ sketch.update(3);
+ Long result = new GetNFromDoublesSketchUDF().evaluate(new BytesWritable(sketch.toByteArray()));
+ Assert.assertNotNull(result);
+ Assert.assertEquals(result, Long.valueOf(3));
+ }
+
+}
diff --git a/src/test/java/org/apache/datasketches/hive/quantiles/GetNFromStringsSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetNFromStringsSketchUDFTest.java
new file mode 100644
index 0000000..6b44ac6
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetNFromStringsSketchUDFTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import java.util.Comparator;
+
+import org.apache.hadoop.io.BytesWritable;
+
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.quantiles.ItemsSketch;
+
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
+@SuppressWarnings("javadoc")
+public class GetNFromStringsSketchUDFTest {
+
+ static final Comparator<String> comparator = Comparator.naturalOrder();
+ static final ArrayOfItemsSerDe<String> serDe = new ArrayOfStringsSerDe();
+
+ @Test
+ public void nullSketch() {
+ Long result = new GetNFromStringsSketchUDF().evaluate(null);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ ItemsSketch<String> sketch = ItemsSketch.getInstance(comparator);
+ sketch.update("a");
+ sketch.update("b");
+ sketch.update("c");
+ Long result = new GetNFromStringsSketchUDF().evaluate(new BytesWritable(sketch.toByteArray(serDe)));
+ Assert.assertNotNull(result);
+ Assert.assertEquals(result, Long.valueOf(3));
+ }
+
+}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetPmfFromDoublesSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetPmfFromDoublesSketchUDFTest.java
similarity index 62%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/GetPmfFromDoublesSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/GetPmfFromDoublesSketchUDFTest.java
index e9d2d6b..45cd365 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetPmfFromDoublesSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetPmfFromDoublesSketchUDFTest.java
@@ -1,8 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+
+package org.apache.datasketches.hive.quantiles;
import java.util.List;
@@ -10,8 +25,8 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.quantiles.UpdateDoublesSketch;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.quantiles.UpdateDoublesSketch;
@SuppressWarnings("javadoc")
public class GetPmfFromDoublesSketchUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetPmfFromStringsSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetPmfFromStringsSketchUDFTest.java
similarity index 64%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/GetPmfFromStringsSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/GetPmfFromStringsSketchUDFTest.java
index f7c783a..4e2cad1 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetPmfFromStringsSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetPmfFromStringsSketchUDFTest.java
@@ -1,8 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
import java.util.List;
@@ -12,9 +27,9 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.annotations.Test;
import org.testng.Assert;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.quantiles.ItemsSketch;
@SuppressWarnings("javadoc")
public class GetPmfFromStringsSketchUDFTest {
diff --git a/src/test/java/org/apache/datasketches/hive/quantiles/GetQuantileFromDoublesSektchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetQuantileFromDoublesSektchUDFTest.java
new file mode 100644
index 0000000..7fb757f
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetQuantileFromDoublesSektchUDFTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import org.apache.hadoop.io.BytesWritable;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.quantiles.UpdateDoublesSketch;
+
+@SuppressWarnings("javadoc")
+public class GetQuantileFromDoublesSektchUDFTest {
+
+ @Test
+ public void nullSketch() {
+ Double result = new GetQuantileFromDoublesSketchUDF().evaluate(null, 0);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ UpdateDoublesSketch sketch = DoublesSketch.builder().build();
+ sketch.update(1);
+ sketch.update(2);
+ sketch.update(3);
+ Double result = new GetQuantileFromDoublesSketchUDF().evaluate(new BytesWritable(sketch.toByteArray()), 0.5);
+ Assert.assertNotNull(result);
+ Assert.assertEquals(result, 2.0);
+ }
+
+}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromStringsSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetQuantileFromStringsSketchUDFTest.java
similarity index 58%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromStringsSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/GetQuantileFromStringsSketchUDFTest.java
index 39dd3da..ef4d89d 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantileFromStringsSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetQuantileFromStringsSketchUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
@@ -11,10 +25,10 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfLongsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfLongsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.quantiles.ItemsSketch;
@SuppressWarnings("javadoc")
public class GetQuantileFromStringsSketchUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromDoublesSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromDoublesSketchUDFTest.java
similarity index 69%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromDoublesSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromDoublesSketchUDFTest.java
index 8fb6c16..8ca1d8b 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromDoublesSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromDoublesSketchUDFTest.java
@@ -1,8 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+
+package org.apache.datasketches.hive.quantiles;
import java.util.List;
@@ -10,9 +25,9 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.SketchesArgumentException;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.quantiles.UpdateDoublesSketch;
+import org.apache.datasketches.SketchesArgumentException;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.quantiles.UpdateDoublesSketch;
@SuppressWarnings("javadoc")
public class GetQuantilesFromDoublesSketchUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromStringsSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromStringsSketchUDFTest.java
similarity index 77%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromStringsSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromStringsSketchUDFTest.java
index 973ed38..2c162f6 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/GetQuantilesFromStringsSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/GetQuantilesFromStringsSketchUDFTest.java
@@ -1,8 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+
+package org.apache.datasketches.hive.quantiles;
import java.util.Comparator;
import java.util.List;
@@ -11,11 +26,11 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfLongsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.SketchesArgumentException;
-import com.yahoo.sketches.quantiles.ItemsSketch;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfLongsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.SketchesArgumentException;
+import org.apache.datasketches.quantiles.ItemsSketch;
@SuppressWarnings("javadoc")
public class GetQuantilesFromStringsSketchUDFTest {
diff --git a/src/test/java/org/apache/datasketches/hive/quantiles/StringsSketchToStringUDFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/StringsSketchToStringUDFTest.java
new file mode 100644
index 0000000..cf4731b
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/StringsSketchToStringUDFTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.hive.quantiles;
+
+import java.util.Comparator;
+
+import org.apache.hadoop.io.BytesWritable;
+
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.quantiles.ItemsSketch;
+
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
+@SuppressWarnings("javadoc")
+public class StringsSketchToStringUDFTest {
+
+ static final Comparator<String> COMPARATOR = Comparator.naturalOrder();
+ static final ArrayOfItemsSerDe<String> SERDE = new ArrayOfStringsSerDe();
+
+ @Test
+ public void nullSketch() {
+ final String result = new StringsSketchToStringUDF().evaluate(null);
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void normalCase() {
+ final ItemsSketch<String> sketch = ItemsSketch.getInstance(COMPARATOR);
+ final String result = new StringsSketchToStringUDF().evaluate(new BytesWritable(sketch.toByteArray(SERDE)));
+ Assert.assertNotNull(result);
+ Assert.assertTrue(result.length() > 0);
+ }
+
+}
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/UnionDoublesSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/UnionDoublesSketchUDAFTest.java
similarity index 91%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/UnionDoublesSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/UnionDoublesSketchUDAFTest.java
index 2e63186..bf4f56a 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/UnionDoublesSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/UnionDoublesSketchUDAFTest.java
@@ -1,8 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+
+package org.apache.datasketches.hive.quantiles;
import java.util.Arrays;
@@ -21,9 +36,9 @@ import org.apache.hadoop.io.IntWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.quantiles.UpdateDoublesSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.quantiles.UpdateDoublesSketch;
@SuppressWarnings("javadoc")
public class UnionDoublesSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/quantiles/UnionStringsSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/quantiles/UnionStringsSketchUDAFTest.java
similarity index 91%
rename from src/test/java/com/yahoo/sketches/hive/quantiles/UnionStringsSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/quantiles/UnionStringsSketchUDAFTest.java
index 7a4903d..3ccae95 100644
--- a/src/test/java/com/yahoo/sketches/hive/quantiles/UnionStringsSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/quantiles/UnionStringsSketchUDAFTest.java
@@ -1,8 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.quantiles;
+
+package org.apache.datasketches.hive.quantiles;
import java.util.Arrays;
import java.util.Comparator;
@@ -22,10 +37,10 @@ import org.apache.hadoop.io.IntWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.ArrayOfItemsSerDe;
-import com.yahoo.sketches.ArrayOfStringsSerDe;
-import com.yahoo.sketches.quantiles.ItemsSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.ArrayOfItemsSerDe;
+import org.apache.datasketches.ArrayOfStringsSerDe;
+import org.apache.datasketches.quantiles.ItemsSketch;
@SuppressWarnings("javadoc")
public class UnionStringsSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/theta/DataToSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/theta/DataToSketchUDAFTest.java
similarity index 93%
rename from src/test/java/com/yahoo/sketches/hive/theta/DataToSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/theta/DataToSketchUDAFTest.java
index db4f956..f163d7f 100644
--- a/src/test/java/com/yahoo/sketches/hive/theta/DataToSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/theta/DataToSketchUDAFTest.java
@@ -1,11 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
/*******************************************************************************
* Copyright 2015, Yahoo Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*******************************************************************************/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_NOMINAL_ENTRIES;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
import java.util.List;
@@ -34,12 +53,12 @@ import org.apache.hadoop.io.Text;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.SetOperation;
-import com.yahoo.sketches.theta.Sketch;
-import com.yahoo.sketches.theta.Sketches;
-import com.yahoo.sketches.theta.Union;
-import com.yahoo.sketches.theta.UpdateSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.SetOperation;
+import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.Sketches;
+import org.apache.datasketches.theta.Union;
+import org.apache.datasketches.theta.UpdateSketch;
/**
* Unit tests for DataToSketch UDF
diff --git a/src/test/java/com/yahoo/sketches/hive/theta/EstimateSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/theta/EstimateSketchUDFTest.java
similarity index 68%
rename from src/test/java/com/yahoo/sketches/hive/theta/EstimateSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/theta/EstimateSketchUDFTest.java
index e577264..6261014 100644
--- a/src/test/java/com/yahoo/sketches/hive/theta/EstimateSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/theta/EstimateSketchUDFTest.java
@@ -1,17 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
/*******************************************************************************
* Copyright 2015, Yahoo Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*******************************************************************************/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
import org.apache.hadoop.io.BytesWritable;
import org.testng.annotations.Test;
-import com.yahoo.sketches.hive.theta.EstimateSketchUDF;
+import org.apache.datasketches.hive.theta.EstimateSketchUDF;
-import com.yahoo.sketches.theta.CompactSketch;
-import com.yahoo.sketches.theta.UpdateSketch;
-import com.yahoo.sketches.theta.Sketches;
+import org.apache.datasketches.theta.CompactSketch;
+import org.apache.datasketches.theta.UpdateSketch;
+import org.apache.datasketches.theta.Sketches;
import static org.testng.AssertJUnit.assertEquals;
@SuppressWarnings("javadoc")
diff --git a/src/test/java/com/yahoo/sketches/hive/theta/ExcludeSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/theta/ExcludeSketchUDFTest.java
similarity index 76%
rename from src/test/java/com/yahoo/sketches/hive/theta/ExcludeSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/theta/ExcludeSketchUDFTest.java
index f118e3d..73fad71 100644
--- a/src/test/java/com/yahoo/sketches/hive/theta/ExcludeSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/theta/ExcludeSketchUDFTest.java
@@ -1,19 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
/*******************************************************************************
* Copyright 2015, Yahoo Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*******************************************************************************/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import static org.testng.AssertJUnit.assertEquals;
import org.apache.hadoop.io.BytesWritable;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.Sketch;
-import com.yahoo.sketches.theta.Sketches;
-import com.yahoo.sketches.theta.UpdateSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.Sketches;
+import org.apache.datasketches.theta.UpdateSketch;
@SuppressWarnings("javadoc")
public class ExcludeSketchUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/theta/IntersectSketchUDAFTest.java
similarity index 92%
rename from src/test/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/theta/IntersectSketchUDAFTest.java
index 0f8f689..77facee 100644
--- a/src/test/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/theta/IntersectSketchUDAFTest.java
@@ -1,10 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
/*******************************************************************************
* Copyright 2015, Yahoo Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*******************************************************************************/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
import java.util.List;
@@ -27,10 +46,10 @@ import org.apache.hadoop.io.LongWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.Sketch;
-import com.yahoo.sketches.theta.Sketches;
-import com.yahoo.sketches.theta.UpdateSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.Sketches;
+import org.apache.datasketches.theta.UpdateSketch;
@SuppressWarnings("javadoc")
public class IntersectSketchUDAFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/theta/IntersectSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/theta/IntersectSketchUDFTest.java
similarity index 72%
rename from src/test/java/com/yahoo/sketches/hive/theta/IntersectSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/theta/IntersectSketchUDFTest.java
index 7551f96..a3eb13b 100644
--- a/src/test/java/com/yahoo/sketches/hive/theta/IntersectSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/theta/IntersectSketchUDFTest.java
@@ -1,18 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
/*******************************************************************************
* Copyright 2015, Yahoo Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*******************************************************************************/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
import static org.testng.AssertJUnit.assertEquals;
import org.apache.hadoop.io.BytesWritable;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.Sketch;
-import com.yahoo.sketches.theta.Sketches;
-import com.yahoo.sketches.theta.UpdateSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.Sketches;
+import org.apache.datasketches.theta.UpdateSketch;
@SuppressWarnings("javadoc")
public class IntersectSketchUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/theta/SampleSketchUDF.java b/src/test/java/org/apache/datasketches/hive/theta/SampleSketchUDF.java
similarity index 65%
rename from src/test/java/com/yahoo/sketches/hive/theta/SampleSketchUDF.java
rename to src/test/java/org/apache/datasketches/hive/theta/SampleSketchUDF.java
index 963a5ba..b261164 100644
--- a/src/test/java/com/yahoo/sketches/hive/theta/SampleSketchUDF.java
+++ b/src/test/java/org/apache/datasketches/hive/theta/SampleSketchUDF.java
@@ -1,16 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
/*******************************************************************************
* Copyright 2015, Yahoo Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*******************************************************************************/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.SetOperation;
-import com.yahoo.sketches.theta.Sketch;
-import com.yahoo.sketches.theta.Union;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.SetOperation;
+import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.Union;
/**
* Hive estimate sketch UDF.
diff --git a/src/test/java/com/yahoo/sketches/hive/theta/UnionSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/theta/UnionSketchUDAFTest.java
similarity index 92%
rename from src/test/java/com/yahoo/sketches/hive/theta/UnionSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/theta/UnionSketchUDAFTest.java
index 2b637e9..e5b2151 100644
--- a/src/test/java/com/yahoo/sketches/hive/theta/UnionSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/theta/UnionSketchUDAFTest.java
@@ -1,11 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
/*******************************************************************************
* Copyright 2015, Yahoo Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*******************************************************************************/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
-import static com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES;
-import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
+import static org.apache.datasketches.Util.DEFAULT_NOMINAL_ENTRIES;
+import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import java.util.Arrays;
import java.util.List;
@@ -27,10 +46,10 @@ import org.apache.hadoop.io.LongWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.Sketch;
-import com.yahoo.sketches.theta.Sketches;
-import com.yahoo.sketches.theta.UpdateSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.Sketches;
+import org.apache.datasketches.theta.UpdateSketch;
/**
* Unit tests for UnionSketch UDF
diff --git a/src/test/java/com/yahoo/sketches/hive/theta/UnionSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/theta/UnionSketchUDFTest.java
similarity index 73%
rename from src/test/java/com/yahoo/sketches/hive/theta/UnionSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/theta/UnionSketchUDFTest.java
index 5a1a359..b408cbb 100644
--- a/src/test/java/com/yahoo/sketches/hive/theta/UnionSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/theta/UnionSketchUDFTest.java
@@ -1,17 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
/*******************************************************************************
* Copyright 2015, Yahoo Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*******************************************************************************/
-package com.yahoo.sketches.hive.theta;
+package org.apache.datasketches.hive.theta;
import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.theta.Sketch;
-import com.yahoo.sketches.theta.Sketches;
-import com.yahoo.sketches.theta.UpdateSketch;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.Sketches;
+import org.apache.datasketches.theta.UpdateSketch;
@SuppressWarnings("javadoc")
public class UnionSketchUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDFTest.java b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDFTest.java
similarity index 70%
rename from src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDFTest.java
index 0aa5870..7e8ce64 100644
--- a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimateAndErrorBoundsUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.List;
@@ -11,8 +25,8 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
@SuppressWarnings("javadoc")
public class ArrayOfDoublesSketchToEstimateAndErrorBoundsUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDFTest.java b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDFTest.java
similarity index 57%
rename from src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDFTest.java
index f16c4ed..2ec6a61 100644
--- a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.List;
@@ -11,8 +25,8 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
@SuppressWarnings("javadoc")
public class ArrayOfDoublesSketchToEstimatesUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToMeansUDFTest.java b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToMeansUDFTest.java
similarity index 66%
rename from src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToMeansUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToMeansUDFTest.java
index 078aba3..34db089 100644
--- a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToMeansUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToMeansUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.List;
import java.util.Random;
@@ -12,8 +26,8 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
@SuppressWarnings("javadoc")
public class ArrayOfDoublesSketchToMeansUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDFTest.java b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDFTest.java
similarity index 53%
rename from src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDFTest.java
index 90cf221..d7c40a5 100644
--- a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToNumberOfRetainedEntriesUDFTest.java
@@ -1,16 +1,30 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
@SuppressWarnings("javadoc")
public class ArrayOfDoublesSketchToNumberOfRetainedEntriesUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDFTest.java b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDFTest.java
similarity index 72%
rename from src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDFTest.java
index a9a8928..bec9614 100644
--- a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToQuantilesSketchUDFTest.java
@@ -1,18 +1,32 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.memory.Memory;
-import com.yahoo.sketches.quantiles.DoublesSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.quantiles.DoublesSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
@SuppressWarnings("javadoc")
public class ArrayOfDoublesSketchToQuantilesSketchUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTFTest.java b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTFTest.java
similarity index 83%
rename from src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTFTest.java
rename to src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTFTest.java
index a4bfa25..a7c3367 100644
--- a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTFTest.java
@@ -1,8 +1,23 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+
+package org.apache.datasketches.hive.tuple;
import java.util.ArrayList;
import java.util.Arrays;
@@ -25,8 +40,8 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
@SuppressWarnings("javadoc")
public class ArrayOfDoublesSketchToValuesUDTFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDFTest.java b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDFTest.java
similarity index 67%
rename from src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDFTest.java
index c4435e1..a6f0493 100644
--- a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToVariancesUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.List;
import java.util.Random;
@@ -12,8 +26,8 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
@SuppressWarnings("javadoc")
public class ArrayOfDoublesSketchToVariancesUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchesTTestUDFTest.java b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchesTTestUDFTest.java
similarity index 82%
rename from src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchesTTestUDFTest.java
rename to src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchesTTestUDFTest.java
index 10403fe..26b7c99 100644
--- a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchesTTestUDFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchesTTestUDFTest.java
@@ -1,9 +1,23 @@
/*
- * Copyright 2017, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
import java.util.List;
@@ -11,8 +25,8 @@ import org.apache.hadoop.io.BytesWritable;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch;
-import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketch;
+import org.apache.datasketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
@SuppressWarnings("javadoc")
public class ArrayOfDoublesSketchesTTestUDFTest {
diff --git a/src/test/java/com/yahoo/sketches/hive/tuple/DataToArrayOfDoublesSketchUDAFTest.java b/src/test/java/org/apache/datasketches/hive/tuple/DataToArrayOfDoublesSketchUDAFTest.java
similarity index 94%
rename from src/test/java/com/yahoo/sketches/hive/tuple/DataToArrayOfDoublesSketchUDAFTest.java
rename to src/test/java/org/apache/datasketches/hive/tuple/DataToArrayOfDoublesSketchUDAFTest.java
index f4b2221..fbfd5a7 100644
--- a/src/test/java/com/yahoo/sketches/hive/tuple/DataToArrayOfDoublesSketchUDAFTest.java
+++ b/src/test/java/org/apache/datasketches/hive/tuple/DataToArrayOfDoublesSketchUDAFTest.java
@@ -1,11 +1,25 @@
/*
- * Copyright 2016, Yahoo! Inc.
- * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package com.yahoo.sketches.hive.tuple;
+package org.apache.datasketches.hive.tuple;
-import static com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES;
+import static org.apache.datasketches.Util.DEFAULT_NOMINAL_ENTRIES;
import java.util.Arrays;
import java.util.List;
@@ -32,11 +46,11 @@ import org.apache.hadoop.io.Text;
import org.testng.Assert;
import org.testng.annotations.Test;
... 408 lines suppressed ...
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org