[ 
https://issues.apache.org/jira/browse/TAJO-838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14260379#comment-14260379
 ] 

ASF GitHub Bot commented on TAJO-838:
-------------------------------------

Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/231#discussion_r22325778
  
    --- Diff: 
tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/AccessPathRewriter.java
 ---
    @@ -0,0 +1,126 @@
    +/*
    + * 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.tajo.plan.rewrite.rules;
    +
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.tajo.OverridableConf;
    +import org.apache.tajo.SessionVars;
    +import org.apache.tajo.plan.LogicalPlan;
    +import org.apache.tajo.plan.PlanningException;
    +import org.apache.tajo.plan.logical.IndexScanNode;
    +import org.apache.tajo.plan.logical.LogicalNode;
    +import org.apache.tajo.plan.logical.RelationNode;
    +import org.apache.tajo.plan.logical.ScanNode;
    +import org.apache.tajo.plan.rewrite.RewriteRule;
    +import org.apache.tajo.plan.util.PlannerUtil;
    +import org.apache.tajo.plan.visitor.BasicLogicalPlanVisitor;
    +
    +import java.util.List;
    +import java.util.Stack;
    +
    +public class AccessPathRewriter implements RewriteRule {
    +  private static final Log LOG = 
LogFactory.getLog(AccessPathRewriter.class);
    +
    +  private static final String NAME = "Access Path Rewriter";
    +  private Rewriter rewriter = null;
    +
    +  @Override
    +  public String getName() {
    +    return NAME;
    +  }
    +
    +  @Override
    +  public boolean isEligible(OverridableConf conf, LogicalPlan plan) {
    +    if (conf.getBool(SessionVars.INDEX_ENABLED)) {
    +      for (LogicalPlan.QueryBlock block : plan.getQueryBlocks()) {
    +        for (RelationNode relationNode : block.getRelations()) {
    +          List<AccessPathInfo> accessPathInfos = 
block.getAccessInfos(relationNode);
    +          // If there are any alternative access paths
    +          if (accessPathInfos.size() > 1) {
    +            for (AccessPathInfo accessPathInfo : accessPathInfos) {
    +              if (accessPathInfo.getScanType() == 
AccessPathInfo.ScanTypeControl.INDEX_SCAN) {
    +                rewriter = new Rewriter(conf);
    --- End diff --
    
    It would be better if Rewrite is a singleton instance and its visitor takes 
TajoConf. If so, it does not need to create a Rewriter instance for each query.


> Improve query planner to utilize index
> --------------------------------------
>
>                 Key: TAJO-838
>                 URL: https://issues.apache.org/jira/browse/TAJO-838
>             Project: Tajo
>          Issue Type: Sub-task
>          Components: planner/optimizer
>            Reporter: Jihoon Son
>            Assignee: Jihoon Son
>            Priority: Minor
>
> Index can improve the query performance when the selectivity of query is high.
> Thus, query planner should decide whether index is used or not for a given 
> query.
> The selectivity can be guessed using statistics.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to