You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ro...@apache.org on 2022/08/31 01:39:53 UTC

[pinot] branch master updated: Clean up AggregationFunctionUtils (#9301)

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

rongr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 784f995566 Clean up AggregationFunctionUtils (#9301)
784f995566 is described below

commit 784f995566c598e8052a5978f987e08f5cca68f9
Author: Xiaotian (Jackie) Jiang <17...@users.noreply.github.com>
AuthorDate: Tue Aug 30 18:39:46 2022 -0700

    Clean up AggregationFunctionUtils (#9301)
---
 .../function/AggregationFunctionUtils.java         | 28 ---------
 .../function/AggregationFunctionUtilsTest.java     | 66 ----------------------
 2 files changed, 94 deletions(-)

diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionUtils.java
index 83094876bb..6c31690929 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionUtils.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionUtils.java
@@ -18,14 +18,11 @@
  */
 package org.apache.pinot.core.query.aggregation.function;
 
-import com.google.common.math.DoubleMath;
-import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import javax.annotation.Nullable;
@@ -66,31 +63,6 @@ public class AggregationFunctionUtils {
     return null;
   }
 
-  public static String formatValue(Object value) {
-    if (value instanceof Double) {
-      double doubleValue = (double) value;
-
-      // NOTE: String.format() is very expensive, so avoid it for whole numbers that can fit in Long.
-      //       We simply append ".00000" to long, in order to keep the existing behavior.
-      if (doubleValue <= Long.MAX_VALUE && doubleValue >= Long.MIN_VALUE && DoubleMath.isMathematicalInteger(
-          doubleValue)) {
-        return (long) doubleValue + ".00000";
-      } else {
-        return String.format(Locale.US, "%1.5f", doubleValue);
-      }
-    } else {
-      return value.toString();
-    }
-  }
-
-  public static Serializable getSerializableValue(Object value) {
-    if (value instanceof Number) {
-      return (Number) value;
-    } else {
-      return value.toString();
-    }
-  }
-
   /**
    * Collects all transform expressions required for aggregation/group-by queries.
    * <p>NOTE: We don't need to consider order-by columns here as the ordering is only allowed for aggregation functions
diff --git a/pinot-core/src/test/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionUtilsTest.java b/pinot-core/src/test/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionUtilsTest.java
deleted file mode 100644
index ff74df9f6a..0000000000
--- a/pinot-core/src/test/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionUtilsTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * 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.query.aggregation.function;
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-
-public class AggregationFunctionUtilsTest {
-
-  @Test
-  public void testFormatValue() {
-    double value = Long.MAX_VALUE;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "9223372036854775807.00000");
-
-    value = Long.MIN_VALUE;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "-9223372036854775808.00000");
-
-    value = 1e30;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "1000000000000000000000000000000.00000");
-
-    value = -1e30;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "-1000000000000000000000000000000.00000");
-
-    value = 1e-3;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "0.00100");
-
-    value = -1e-3;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "-0.00100");
-
-    value = 1e-10;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "0.00000");
-
-    value = -1e-10;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "-0.00000");
-
-    value = 123.456789;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "123.45679");
-
-    value = Double.POSITIVE_INFINITY;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "Infinity");
-
-    value = Double.NEGATIVE_INFINITY;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "-Infinity");
-
-    value = Double.NaN;
-    assertEquals(AggregationFunctionUtils.formatValue(value), "NaN");
-  }
-}


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