drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacques-n <...@git.apache.org>
Subject [GitHub] drill pull request: DRILL-4363: Row count based pruning for parque...
Date Wed, 10 Feb 2016 13:25:22 GMT
Github user jacques-n commented on a diff in the pull request:

    https://github.com/apache/drill/pull/371#discussion_r52455844
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillPushLimitToScanRule.java
---
    @@ -0,0 +1,107 @@
    +/**
    + * 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.planner.logical;
    +
    +import com.google.common.collect.ImmutableList;
    +import org.apache.calcite.plan.RelOptRule;
    +import org.apache.calcite.plan.RelOptRuleCall;
    +import org.apache.calcite.plan.RelOptRuleOperand;
    +import org.apache.calcite.rel.RelNode;
    +import org.apache.calcite.util.Pair;
    +import org.apache.drill.exec.physical.base.GroupScan;
    +import org.apache.drill.exec.planner.logical.partition.PruneScanRule;
    +import org.apache.drill.exec.store.parquet.ParquetGroupScan;
    +
    +import java.io.IOException;
    +import java.util.concurrent.TimeUnit;
    +
    +public abstract class DrillPushLimitToScanRule extends RelOptRule {
    +  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillPushLimitToScanRule.class);
    +
    +  private DrillPushLimitToScanRule(RelOptRuleOperand operand, String description) {
    +    super(operand, description);
    +  }
    +
    +  public static DrillPushLimitToScanRule LIMIT_ON_SCAN = new DrillPushLimitToScanRule(
    +      RelOptHelper.some(DrillLimitRel.class, RelOptHelper.any(DrillScanRel.class)), "DrillPushLimitToScanRule_LimitOnScan")
{
    +    @Override
    +    public boolean matches(RelOptRuleCall call) {
    +      DrillScanRel scanRel = call.rel(1);
    +      return scanRel.getGroupScan() instanceof ParquetGroupScan; // It only applies to
Parquet.
    +    }
    +
    +    @Override
    +    public void onMatch(RelOptRuleCall call) {
    +        DrillLimitRel limitRel = call.rel(0);
    +        DrillScanRel scanRel = call.rel(1);
    +        doOnMatch(call, limitRel, scanRel, null);
    +    }
    +  };
    +
    +  public static DrillPushLimitToScanRule LIMIT_ON_PROJECT = new DrillPushLimitToScanRule(
    +      RelOptHelper.some(DrillLimitRel.class, RelOptHelper.some(DrillProjectRel.class,
RelOptHelper.any(DrillScanRel.class))), "DrillPushLimitToScanRule_LimitOnProject") {
    +    @Override
    +    public boolean matches(RelOptRuleCall call) {
    +      DrillScanRel scanRel = call.rel(2);
    +      return scanRel.getGroupScan() instanceof ParquetGroupScan; // It only applies to
Parquet.
    +    }
    +
    +    @Override
    +    public void onMatch(RelOptRuleCall call) {
    +      DrillLimitRel limitRel = call.rel(0);
    +      DrillProjectRel projectRel = call.rel(1);
    +      DrillScanRel scanRel = call.rel(2);
    +      doOnMatch(call, limitRel, scanRel, projectRel);
    +    }
    +  };
    +
    +
    +  protected void doOnMatch(RelOptRuleCall call, DrillLimitRel limitRel, DrillScanRel
scanRel, DrillProjectRel projectRel){
    +    try {
    +      final int rowCountRequested = (int) limitRel.getRows();
    +
    +      final Pair<GroupScan, Boolean>  newGroupScanPair = ParquetGroupScan.filterParquetScanByLimit((ParquetGroupScan)(scanRel.getGroupScan()),
rowCountRequested);
    --- End diff --
    
    It seems like we can move this functionality into a method on groupscan and then make
it generic with only parquet group scan implementing it


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