Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 207E3200C2A for ; Wed, 15 Feb 2017 01:44:22 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1F1D0160B6A; Wed, 15 Feb 2017 00:44:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4697D160B5F for ; Wed, 15 Feb 2017 01:44:21 +0100 (CET) Received: (qmail 2918 invoked by uid 500); 15 Feb 2017 00:44:20 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 2907 invoked by uid 99); 15 Feb 2017 00:44:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Feb 2017 00:44:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 12576DFD8C; Wed, 15 Feb 2017 00:44:20 +0000 (UTC) From: gparai To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request #729: Drill 1328: Support table statistics for Parquet Content-Type: text/plain Message-Id: <20170215004420.12576DFD8C@git1-us-west.apache.org> Date: Wed, 15 Feb 2017 00:44:20 +0000 (UTC) archived-at: Wed, 15 Feb 2017 00:44:22 -0000 Github user gparai commented on a diff in the pull request: https://github.com/apache/drill/pull/729#discussion_r101181131 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/statistics/StatisticsMergeBatch.java --- @@ -0,0 +1,532 @@ +/** + * 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.drill.exec.physical.impl.statistics; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.drill.common.expression.LogicalExpression; +import org.apache.drill.common.expression.ErrorCollector; +import org.apache.drill.common.expression.ErrorCollectorImpl; +import org.apache.drill.common.expression.FunctionCallFactory; +import org.apache.drill.common.expression.SchemaPath; +import org.apache.drill.common.expression.ValueExpressions; +import org.apache.drill.common.types.TypeProtos; +import org.apache.drill.common.types.TypeProtos.MajorType; +import org.apache.drill.exec.exception.OutOfMemoryException; +import org.apache.drill.exec.exception.SchemaChangeException; +import org.apache.drill.exec.expr.ExpressionTreeMaterializer; +import org.apache.drill.exec.expr.TypeHelper; +import org.apache.drill.exec.expr.holders.BigIntHolder; +import org.apache.drill.exec.expr.holders.NullableFloat8Holder; +import org.apache.drill.exec.expr.holders.ObjectHolder; +import org.apache.drill.exec.expr.holders.ValueHolder; +import org.apache.drill.exec.ops.FragmentContext; +import org.apache.drill.exec.physical.config.StatisticsMerge; +import org.apache.drill.exec.record.AbstractSingleRecordBatch; +import org.apache.drill.exec.record.MaterializedField; +import org.apache.drill.exec.record.RecordBatch; +import org.apache.drill.exec.record.TransferPair; +import org.apache.drill.exec.record.VectorContainer; +import org.apache.drill.exec.record.VectorWrapper; +import org.apache.drill.exec.vector.ValueVector; +import org.apache.drill.exec.vector.DateVector; +import org.apache.drill.exec.vector.BigIntVector; +import org.apache.drill.exec.vector.NullableBigIntVector; +import org.apache.drill.exec.vector.NullableFloat8Vector; +import org.apache.drill.exec.vector.NullableVarBinaryVector; +import org.apache.drill.exec.vector.VarCharVector; +import org.apache.drill.exec.vector.complex.MapVector; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; +import java.util.List; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Map; +import java.util.TimeZone; + +import com.clearspring.analytics.stream.cardinality.HyperLogLog; + +public class StatisticsMergeBatch extends AbstractSingleRecordBatch { + private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StatisticsMergeBatch.class); + private Map functions; + private boolean first = true; + private boolean finished = false; + private int schema = 0; + private int recordCount = 0; + private List keyList = null; + private Map dataSrcVecMap = null; + // Map of non-map fields to VV in the incoming schema + private Map copySrcVecMap = null; + private Map> aggregationMap = null; + public StatisticsMergeBatch(StatisticsMerge popConfig, RecordBatch incoming, + FragmentContext context) throws OutOfMemoryException { + super(popConfig, context, incoming); + this.functions = new HashMap<>(); + this.aggregationMap = new HashMap<>(); + + /*for (String key : popConfig.getFunctions()) { + aggregationMap.put(key, new HashMap()); + if (key.equalsIgnoreCase("statcount") || key.equalsIgnoreCase("nonnullstatcount")) { + functions.put(key, "sum"); + } else if (key.equalsIgnoreCase("hll")) { + functions.put(key, "hll_merge"); + } else if (key.equalsIgnoreCase("sum_width")) { + functions.put(key, "avg_width"); + } + }*/ + for (String key : popConfig.getFunctions()) { + if (key.equalsIgnoreCase("sum_width")) { + functions.put(key, "avg_width"); + } else if (key.equalsIgnoreCase("hll")) { + functions.put(key, "hll_merge"); + } else { + functions.put(key, key); + } + aggregationMap.put(functions.get(key), new HashMap()); + } + } + + private void createKeyColumn(String name, LogicalExpression expr, Map parentMap) + throws SchemaChangeException { + ErrorCollector collector = new ErrorCollectorImpl(); + + LogicalExpression mle = ExpressionTreeMaterializer.materialize(expr, incoming, collector, + context.getFunctionRegistry()); + + MaterializedField outputField = MaterializedField.create(name, mle.getMajorType()); + ValueVector vector = TypeHelper.getNewVector(outputField, oContext.getAllocator()); + container.add(vector); + + if (collector.hasErrors()) { + throw new SchemaChangeException("Failure while materializing expression. " + + collector.toErrorString()); + } + parentMap.put(outputField, vector); + } + + private ValueVector addMapVector(String name, MapVector parent, LogicalExpression expr) throws SchemaChangeException { + ErrorCollector collector = new ErrorCollectorImpl(); --- End diff -- Done --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---