asolimando commented on code in PR #3317: URL: https://github.com/apache/hive/pull/3317#discussion_r1015228879
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/common/histogram/KllHistogramEstimatorFactory.java: ########## @@ -0,0 +1,75 @@ +/* + * 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.common.histogram; + +import org.apache.hadoop.hive.common.histogram.kll.KllUtils; + +public class KllHistogramEstimatorFactory { + + private KllHistogramEstimatorFactory() { + throw new AssertionError("Suppress default constructor for non instantiation"); + } + + /** + * This function deserializes the serialized KLL histogram estimator from a byte array. + * @param buf to deserialize + * @return KLL histogram estimator + */ + public static KllHistogramEstimator getKllHistogramEstimator(byte[] buf) { + return new KllHistogramEstimator(KllUtils.deserializeKll(buf, 0, buf.length)); + } + + /** + * This function deserializes the serialized KLL histogram estimator from a byte array. + * @param buf to deserialize + * @param start start index for deserialization + * @param len start+len is deserialized + * @return KLL histogram estimator + */ + public static KllHistogramEstimator getKllHistogramEstimator(byte[] buf, int start, int len) { + return new KllHistogramEstimator(KllUtils.deserializeKll(buf, start, len)); + } + + /** + * This method creates an empty histogram estimator with a KLL sketch with k=200. + * @return an empty histogram estimator with a KLL sketch with k=200 + */ + public static KllHistogramEstimator getEmptyHistogramEstimator() { Review Comment: They will be re-introduced by the next PR implementing histograms, but it's true that they are not useful in the context of this PR, so it's confusing to add them now, I will defer them to the next PR -- 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]
