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 6F09C200C3D for ; Tue, 28 Feb 2017 04:20:20 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6BE88160B6C; Tue, 28 Feb 2017 03:20:20 +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 B75A7160B60 for ; Tue, 28 Feb 2017 04:20:19 +0100 (CET) Received: (qmail 4021 invoked by uid 500); 28 Feb 2017 03:20:18 -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 4010 invoked by uid 99); 28 Feb 2017 03:20:18 -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; Tue, 28 Feb 2017 03:20:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 520EADFDE6; Tue, 28 Feb 2017 03:20:18 +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: <20170228032018.520EADFDE6@git1-us-west.apache.org> Date: Tue, 28 Feb 2017 03:20:18 +0000 (UTC) archived-at: Tue, 28 Feb 2017 03:20:20 -0000 Github user gparai commented on a diff in the pull request: https://github.com/apache/drill/pull/729#discussion_r103368921 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/statistics/AvgWidthMergedStatistic.java --- @@ -0,0 +1,135 @@ +/* + * 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 org.apache.drill.common.types.TypeProtos; +import org.apache.drill.exec.expr.holders.NullableFloat8Holder; +import org.apache.drill.exec.expr.holders.ValueHolder; +import org.apache.drill.exec.vector.NullableFloat8Vector; +import org.apache.drill.exec.vector.ValueVector; +import org.apache.drill.exec.vector.complex.MapVector; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class AvgWidthMergedStatistic extends AbstractMergedStatistic { + + private String name; + private String inputName; + private boolean configureComplete = false; + private boolean mergeComplete = false; + private Map sumHolder; + MergedStatistic types, nonNullStatCounts, statCounts; + + public AvgWidthMergedStatistic (String name, String inputName) { + this.name = name; + this.inputName = inputName; + this.sumHolder = new HashMap<>(); + types = nonNullStatCounts = statCounts = null; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getInput() { + return inputName; + } + + @Override + public void merge(ValueVector input) { + // Check the input is a Map Vector + assert (input.getField().getType().getMinorType() == TypeProtos.MinorType.MAP); + MapVector inputMap = (MapVector) input; + for (ValueVector vv : inputMap) { + String colName = vv.getField().getLastName(); + NullableFloat8Holder colSumHolder; + if (sumHolder.get(colName) != null) { + colSumHolder = (NullableFloat8Holder) sumHolder.get(colName); + } else { + colSumHolder = new NullableFloat8Holder(); + sumHolder.put(colName, colSumHolder); + } + Object val = vv.getAccessor().getObject(0); + if (val != null) { + colSumHolder.value += (double) val; + colSumHolder.isSet = 1; + } + } + } + + @Override + public Object getStat(String colName) { + if (mergeComplete != true) { + throw new IllegalStateException( + String.format("Statistic `%s` has not completed merging statistics", name)); + } + NullableFloat8Holder colSumHolder = (NullableFloat8Holder) sumHolder.get(colName); + return (long) (colSumHolder.value/ getRowCount(colName)); + } + + @Override + public void setOutput(ValueVector output) { --- 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. ---