drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amansinha100 <...@git.apache.org>
Subject [GitHub] drill pull request #637: Drill 1950 : Parquet row group filter pushdown.
Date Thu, 03 Nov 2016 16:29:20 GMT
Github user amansinha100 commented on a diff in the pull request:

    https://github.com/apache/drill/pull/637#discussion_r86373342
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetRGFilterEvaluator.java
---
    @@ -0,0 +1,252 @@
    +/**
    + * 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
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * 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.store.parquet;
    +
    +import com.google.common.collect.Sets;
    +import org.apache.drill.common.expression.ErrorCollector;
    +import org.apache.drill.common.expression.ErrorCollectorImpl;
    +import org.apache.drill.common.expression.LogicalExpression;
    +import org.apache.drill.common.expression.SchemaPath;
    +import org.apache.drill.common.expression.visitors.AbstractExprVisitor;
    +import org.apache.drill.exec.compile.sig.ConstantExpressionIdentifier;
    +import org.apache.drill.exec.expr.ExpressionTreeMaterializer;
    +import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
    +import org.apache.drill.exec.expr.stat.ParquetFilterPredicate;
    +import org.apache.drill.exec.expr.stat.RangeExprEvaluator;
    +import org.apache.drill.exec.ops.FragmentContext;
    +import org.apache.drill.exec.ops.UdfUtilities;
    +import org.apache.drill.exec.server.options.OptionManager;
    +import org.apache.drill.exec.store.parquet.stat.ColumnStatCollector;
    +import org.apache.drill.exec.store.parquet.stat.ColumnStatistics;
    +import org.apache.drill.exec.store.parquet.stat.ParquetFooterStatCollector;
    +import org.apache.parquet.filter2.predicate.FilterPredicate;
    +import org.apache.parquet.filter2.statisticslevel.StatisticsFilter;
    +import org.apache.parquet.hadoop.metadata.ColumnChunkMetaData;
    +import org.apache.parquet.hadoop.metadata.ParquetMetadata;
    +
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Set;
    +
    +public class ParquetRGFilterEvaluator {
    +  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ParquetRGFilterEvaluator.class);
    +
    +  public static boolean evalFilter(LogicalExpression expr, ParquetMetadata footer, int
rowGroupIndex,
    +      OptionManager options, FragmentContext fragmentContext) {
    +    final HashMap<String, String> emptyMap = new HashMap<String, String>();
    +    return evalFilter(expr, footer, rowGroupIndex, options, fragmentContext, emptyMap);
    +  }
    +
    +  public static boolean evalFilter(LogicalExpression expr, ParquetMetadata footer, int
rowGroupIndex,
    +      OptionManager options, FragmentContext fragmentContext, Map<String, String>
implicitColValues) {
    +    // figure out the set of columns referenced in expression.
    +    final Set<SchemaPath> schemaPathsInExpr = expr.accept(new FieldReferenceFinder(),
null);
    +    final ColumnStatCollector columnStatCollector = new ParquetFooterStatCollector(footer,
rowGroupIndex, implicitColValues,true, options);
    +
    +    Map<SchemaPath, ColumnStatistics> columnStatisticsMap = columnStatCollector.collectColStat(schemaPathsInExpr);
    +
    +    boolean canDrop = canDrop(expr, columnStatisticsMap, footer.getBlocks().get(rowGroupIndex).getRowCount(),
fragmentContext, fragmentContext.getFunctionRegistry());
    +    return canDrop;
    +  }
    +
    +
    +  public static boolean canDrop(ParquetFilterPredicate parquetPredicate, Map<SchemaPath,
    +      ColumnStatistics> columnStatisticsMap, long rowCount) {
    +    boolean canDrop = false;
    +    if (parquetPredicate != null) {
    +      RangeExprEvaluator rangeExprEvaluator = new RangeExprEvaluator(columnStatisticsMap,
rowCount);
    +      canDrop = parquetPredicate.canDrop(rangeExprEvaluator);
    +    }
    +    return canDrop;
    +  }
    +
    +
    +  public static boolean canDrop(LogicalExpression expr, Map<SchemaPath, ColumnStatistics>
columnStatisticsMap,
    +      long rowCount, UdfUtilities udfUtilities, FunctionImplementationRegistry functionImplementationRegistry)
{
    +    ErrorCollector errorCollector = new ErrorCollectorImpl();
    +    LogicalExpression materializedFilter = ExpressionTreeMaterializer.materializeFilterExpr(
    +        expr, columnStatisticsMap, errorCollector, functionImplementationRegistry);
    +
    +    if (errorCollector.hasErrors()) {
    +      logger.error("{} error(s) encountered when materialize filter expression : {}",
    +          errorCollector.getErrorCount(), errorCollector.toErrorString());
    +      return false;
    +    }
    +
    +    Set<LogicalExpression> constantBoundaries = ConstantExpressionIdentifier.getConstantExpressionSet(materializedFilter);
    +    ParquetFilterPredicate parquetPredicate = (ParquetFilterPredicate) ParquetFilterBuilder.buildParquetFilterPredicate(
    +        materializedFilter, constantBoundaries, udfUtilities);
    +
    +    return canDrop(parquetPredicate, columnStatisticsMap, rowCount);
    +  }
    +
    +//  public static boolean evalFilter2(LogicalExpression expr, ParquetMetadata footer,
int rowGroupIndex, OptionManager options, FragmentContext fragmentContext, Map<String,
String> implicitColValues) {
    --- End diff --
    
    Why not remove this entire commented code ?


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

Mime
View raw message