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 #729: Drill 1328 r4
Date Thu, 26 Jan 2017 00:24:38 GMT
Github user amansinha100 commented on a diff in the pull request:

    https://github.com/apache/drill/pull/729#discussion_r97910777
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdSelectivity.java
---
    @@ -0,0 +1,219 @@
    +/*******************************************************************************
    + * 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.cost;
    +
    +import org.apache.calcite.plan.RelOptUtil;
    +import org.apache.calcite.plan.volcano.RelSubset;
    +import org.apache.calcite.rel.RelNode;
    +import org.apache.calcite.rel.SingleRel;
    +import org.apache.calcite.rel.core.JoinRelType;
    +import org.apache.calcite.rel.core.TableScan;
    +import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
    +import org.apache.calcite.rel.metadata.RelMdSelectivity;
    +import org.apache.calcite.rel.metadata.RelMdUtil;
    +import org.apache.calcite.rel.metadata.RelMetadataProvider;
    +import org.apache.calcite.rel.metadata.RelMetadataQuery;
    +import org.apache.calcite.rel.type.RelDataType;
    +import org.apache.calcite.rex.RexBuilder;
    +import org.apache.calcite.rex.RexCall;
    +import org.apache.calcite.rex.RexInputRef;
    +import org.apache.calcite.rex.RexNode;
    +import org.apache.calcite.rex.RexUtil;
    +import org.apache.calcite.rex.RexVisitor;
    +import org.apache.calcite.rex.RexVisitorImpl;
    +import org.apache.calcite.sql.SqlKind;
    +import org.apache.calcite.util.BuiltInMethod;
    +import org.apache.calcite.util.Util;
    +import org.apache.drill.exec.planner.common.DrillJoinRelBase;
    +import org.apache.drill.exec.planner.common.DrillRelOptUtil;
    +import org.apache.drill.exec.planner.logical.DrillTable;
    +import org.apache.drill.exec.planner.logical.DrillTranslatableTable;
    +
    +import java.util.ArrayList;
    +import java.util.List;
    +
    +public class DrillRelMdSelectivity extends RelMdSelectivity {
    +  private static final org.slf4j.Logger logger =
    +      org.slf4j.LoggerFactory.getLogger(RelMdSelectivity.class);
    +
    +  private static final DrillRelMdSelectivity INSTANCE =
    +      new DrillRelMdSelectivity();
    +
    +  public static final RelMetadataProvider SOURCE =
    +      ReflectiveRelMetadataProvider.reflectiveSource(
    +          BuiltInMethod.SELECTIVITY.method, INSTANCE);
    +
    +  @Override
    +  public Double getSelectivity(RelNode rel, RexNode predicate) {
    +    if (rel instanceof TableScan) {
    +      return getScanSelectivity((TableScan) rel, predicate);
    +    } else if (rel instanceof DrillJoinRelBase) {
    +      return getJoinSelectivity(((DrillJoinRelBase) rel), predicate);
    +    } else if (rel instanceof SingleRel && !DrillRelOptUtil.guessRows(rel)) {
    +        return RelMetadataQuery.getSelectivity(((SingleRel) rel).getInput(), predicate);
    +    } else if (rel instanceof RelSubset && !DrillRelOptUtil.guessRows(rel)) {
    +      if (((RelSubset) rel).getBest() != null) {
    +        return RelMetadataQuery.getSelectivity(((RelSubset)rel).getBest(), predicate);
    +      } else if (((RelSubset)rel).getOriginal() != null) {
    +        return RelMetadataQuery.getSelectivity(((RelSubset)rel).getOriginal(), predicate);
    +      } else {
    +        return super.getSelectivity(rel, predicate);
    +      }
    +    } else {
    +      return super.getSelectivity(rel, predicate);
    +    }
    +  }
    +
    +  private Double getJoinSelectivity(DrillJoinRelBase rel, RexNode predicate) {
    --- End diff --
    
    Let's explore whether this can be done in Calcite instead of Drill since it is a generic
function, not Drill specific. 


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