kasakrisz commented on code in PR #6177:
URL: https://github.com/apache/hive/pull/6177#discussion_r2533569066


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/columnstats/DecimalComparator.java:
##########
@@ -0,0 +1,249 @@
+/*
+ * 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.hadoop.hive.metastore.columnstats;
+
+import org.apache.hadoop.hive.metastore.api.Decimal;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Comparator;
+import java.util.function.Consumer;
+
+public class DecimalComparator implements Comparator<Decimal> {

Review Comment:
   Based on my findings so far, for high performance we use `HiveDecimal`. The 
`Decimal` class is only used for data transfer via Thrift.
   
   * stats autogather and `analyze table command` persist fresh stats: The stat 
values are collected into `HiveDecimal` instances in the Tez task. Later, a 
StatsTask 
[converts](https://github.com/apache/hive/blob/c0fde0fec0729c986c62f7b13aaebaab1be985ef/ql/src/java/org/apache/hadoop/hive/ql/stats/ColumnStatisticsObjTranslator.java#L175-L177)
 the `HiveDecimal`s to `Decimal`s and sends them to HMS, where the stats data 
is persisted (merged if needed).
   * using the stats in queries: the stats stored in `Decimal` are converted 
back to `HiveDecimal` and used to annotate the plan.
   
   In the Tez task, we need high performance because the stats data is 
collected by aggregating all records affected by the SQL statement. However, 
processing the aggregated stats data in HMS is just merging two records: 
compare is called once per column and stats type (minValue, maxValue, …). I 
haven't measured the performance of these functions but I suspect that the 
thrift and backend db calls are the most time consuming parts.



-- 
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