andimiller commented on code in PR #10347:
URL: https://github.com/apache/pinot/pull/10347#discussion_r1119344492


##########
pinot-core/src/main/java/org/apache/pinot/core/function/scalar/SketchFunctions.java:
##########
@@ -0,0 +1,133 @@
+/**
+ * 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.pinot.core.function.scalar;
+
+import com.clearspring.analytics.stream.cardinality.HyperLogLog;
+import java.math.BigDecimal;
+import org.apache.datasketches.theta.Sketches;
+import org.apache.datasketches.theta.UpdateSketch;
+import org.apache.pinot.core.common.ObjectSerDeUtils;
+import org.apache.pinot.spi.annotations.ScalarFunction;
+import org.apache.pinot.spi.utils.CommonConstants;
+
+
+/**
+ * Inbuilt Sketch Transformation Functions
+ * The functions can be used as UDFs in Query when added in the 
FunctionRegistry.
+ * @ScalarFunction annotation is used with each method for the registration
+ *
+ * Note these will just make sketches that contain a single item, these are 
intended to be used during ingestion to
+ * create sketches from raw data, which can be rolled up later.
+ *
+ * Note this is defined in pinot-core rather than pinot-common because 
pinot-core has dependencies on
+ * datasketches/clearspring analytics.
+ *
+ * Example usage:
+ *
+ * {
+ *   "transformConfigs": [
+ *     {
+ *       "columnName": "players",
+ *       "transformFunction": "DistinctCountRawThetaSketch(playerID)"
+ *     },
+ *     {
+ *       "columnName": "players",
+ *       "transformFunction": "DistinctCountRawThetaSketch(playerID, 1024)"
+ *     },
+ *     {
+ *       "columnName": "names",
+ *       "transformFunction": "DistinctCountRawHLL(playerName)"
+ *     },
+ *     {
+ *       "columnName": "names",
+ *       "transformFunction": "DistinctCountRawHLL(playerName, 8)"
+ *     }
+ *   ]
+ * }
+ */
+public class SketchFunctions {
+  private SketchFunctions() {
+  }
+
+  /**
+   * Create a Theta Sketch containing the input
+   *
+   * @param input an Object we want to insert into the sketch, may be null to 
return an empty sketch
+   * @return serialized theta sketch as bytes
+   */
+  @ScalarFunction(nullableParameters = true)
+  public static byte[] distinctCountRawThetaSketch(Object input) {

Review Comment:
   renamed to `toThetaSketch` and `toHLL`



##########
pinot-core/src/main/java/org/apache/pinot/core/function/scalar/SketchFunctions.java:
##########
@@ -0,0 +1,133 @@
+/**
+ * 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.pinot.core.function.scalar;
+
+import com.clearspring.analytics.stream.cardinality.HyperLogLog;
+import java.math.BigDecimal;
+import org.apache.datasketches.theta.Sketches;
+import org.apache.datasketches.theta.UpdateSketch;
+import org.apache.pinot.core.common.ObjectSerDeUtils;
+import org.apache.pinot.spi.annotations.ScalarFunction;
+import org.apache.pinot.spi.utils.CommonConstants;
+
+
+/**
+ * Inbuilt Sketch Transformation Functions
+ * The functions can be used as UDFs in Query when added in the 
FunctionRegistry.
+ * @ScalarFunction annotation is used with each method for the registration
+ *
+ * Note these will just make sketches that contain a single item, these are 
intended to be used during ingestion to
+ * create sketches from raw data, which can be rolled up later.
+ *
+ * Note this is defined in pinot-core rather than pinot-common because 
pinot-core has dependencies on
+ * datasketches/clearspring analytics.
+ *
+ * Example usage:
+ *
+ * {
+ *   "transformConfigs": [
+ *     {
+ *       "columnName": "players",
+ *       "transformFunction": "DistinctCountRawThetaSketch(playerID)"
+ *     },
+ *     {
+ *       "columnName": "players",
+ *       "transformFunction": "DistinctCountRawThetaSketch(playerID, 1024)"
+ *     },
+ *     {
+ *       "columnName": "names",
+ *       "transformFunction": "DistinctCountRawHLL(playerName)"
+ *     },
+ *     {
+ *       "columnName": "names",
+ *       "transformFunction": "DistinctCountRawHLL(playerName, 8)"
+ *     }
+ *   ]
+ * }
+ */
+public class SketchFunctions {
+  private SketchFunctions() {
+  }
+
+  /**
+   * Create a Theta Sketch containing the input
+   *
+   * @param input an Object we want to insert into the sketch, may be null to 
return an empty sketch
+   * @return serialized theta sketch as bytes
+   */
+  @ScalarFunction(nullableParameters = true)

Review Comment:
   added



##########
pinot-core/src/main/java/org/apache/pinot/core/function/scalar/SketchFunctions.java:
##########
@@ -0,0 +1,133 @@
+/**
+ * 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.pinot.core.function.scalar;
+
+import com.clearspring.analytics.stream.cardinality.HyperLogLog;
+import java.math.BigDecimal;
+import org.apache.datasketches.theta.Sketches;
+import org.apache.datasketches.theta.UpdateSketch;
+import org.apache.pinot.core.common.ObjectSerDeUtils;
+import org.apache.pinot.spi.annotations.ScalarFunction;
+import org.apache.pinot.spi.utils.CommonConstants;
+
+
+/**
+ * Inbuilt Sketch Transformation Functions
+ * The functions can be used as UDFs in Query when added in the 
FunctionRegistry.
+ * @ScalarFunction annotation is used with each method for the registration
+ *
+ * Note these will just make sketches that contain a single item, these are 
intended to be used during ingestion to
+ * create sketches from raw data, which can be rolled up later.
+ *
+ * Note this is defined in pinot-core rather than pinot-common because 
pinot-core has dependencies on
+ * datasketches/clearspring analytics.
+ *
+ * Example usage:
+ *
+ * {
+ *   "transformConfigs": [
+ *     {
+ *       "columnName": "players",
+ *       "transformFunction": "DistinctCountRawThetaSketch(playerID)"
+ *     },
+ *     {
+ *       "columnName": "players",
+ *       "transformFunction": "DistinctCountRawThetaSketch(playerID, 1024)"
+ *     },
+ *     {
+ *       "columnName": "names",
+ *       "transformFunction": "DistinctCountRawHLL(playerName)"
+ *     },
+ *     {
+ *       "columnName": "names",
+ *       "transformFunction": "DistinctCountRawHLL(playerName, 8)"
+ *     }
+ *   ]
+ * }
+ */
+public class SketchFunctions {
+  private SketchFunctions() {
+  }
+
+  /**
+   * Create a Theta Sketch containing the input
+   *
+   * @param input an Object we want to insert into the sketch, may be null to 
return an empty sketch
+   * @return serialized theta sketch as bytes
+   */
+  @ScalarFunction(nullableParameters = true)
+  public static byte[] distinctCountRawThetaSketch(Object input) {
+    return distinctCountRawThetaSketch(input, 
CommonConstants.Helix.DEFAULT_THETA_SKETCH_NOMINAL_ENTRIES);
+  }
+
+  /**
+   * Create a Theta Sketch containing the input, with a configured nominal 
entries
+   *
+   * @param input an Object we want to insert into the sketch, may be null to 
return an empty sketch
+   * @param nominalEntries number of nominal entries the sketch is configured 
to keep
+   * @return serialized theta sketch as bytes
+   */
+  @ScalarFunction(nullableParameters = true)
+  public static byte[] distinctCountRawThetaSketch(Object input, int 
nominalEntries) {
+    UpdateSketch sketch = 
Sketches.updateSketchBuilder().setNominalEntries(nominalEntries).build();
+    if (input instanceof String) {

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to