当前位置: 首页>>代码示例>>Java>>正文


Java LogicalPlan.QueryBlock方法代码示例

本文整理汇总了Java中org.apache.tajo.engine.planner.LogicalPlan.QueryBlock方法的典型用法代码示例。如果您正苦于以下问题:Java LogicalPlan.QueryBlock方法的具体用法?Java LogicalPlan.QueryBlock怎么用?Java LogicalPlan.QueryBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tajo.engine.planner.LogicalPlan的用法示例。


在下文中一共展示了LogicalPlan.QueryBlock方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rewrite

import org.apache.tajo.engine.planner.LogicalPlan; //导入方法依赖的package包/类
@Override
public LogicalPlan rewrite(LogicalPlan plan) throws PlanningException {
  boolean containsPartitionedTables;
  for (LogicalPlan.QueryBlock block : plan.getQueryBlocks()) {
    containsPartitionedTables = false;
    for (RelationNode relation : block.getRelations()) {
      if (relation.getType() == NodeType.SCAN) {
        TableDesc table = ((ScanNode)relation).getTableDesc();
        if (table.hasPartition()) {
          containsPartitionedTables = true;
        }
      }
    }
    if (containsPartitionedTables) {
      rewriter.visit(block, plan, block, block.getRoot(), new Stack<LogicalNode>());
    }
  }
  return plan;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:20,代码来源:PartitionedTableRewriter.java

示例2: isEligible

import org.apache.tajo.engine.planner.LogicalPlan; //导入方法依赖的package包/类
@Override
public boolean isEligible(LogicalPlan plan) {
  for (LogicalPlan.QueryBlock block : plan.getQueryBlocks()) {
    for (RelationNode relation : block.getRelations()) {
      if (relation.getType() == NodeType.SCAN) {
        TableDesc table = ((ScanNode)relation).getTableDesc();
        if (table.hasPartition()) {
          return true;
        }
      }
    }
  }
  return false;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:15,代码来源:PartitionedTableRewriter.java

示例3: visitScan

import org.apache.tajo.engine.planner.LogicalPlan; //导入方法依赖的package包/类
@Override
public Object visitScan(Object object, LogicalPlan plan, LogicalPlan.QueryBlock block, ScanNode scanNode,
                        Stack<LogicalNode> stack) throws PlanningException {

  TableDesc table = scanNode.getTableDesc();
  if (!table.hasPartition()) {
    return null;
  }

  try {
    Path [] filteredPaths = findFilteredPartitionPaths(scanNode);
    plan.addHistory("PartitionTableRewriter chooses " + filteredPaths.length + " of partitions");
    PartitionedTableScanNode rewrittenScanNode = plan.createNode(PartitionedTableScanNode.class);
    rewrittenScanNode.init(scanNode, filteredPaths);
    updateTableStat(rewrittenScanNode);

    // if it is topmost node, set it as the rootnode of this block.
    if (stack.empty()) {
      block.setRoot(rewrittenScanNode);
    } else {
      PlannerUtil.replaceNode(plan, stack.peek(), scanNode, rewrittenScanNode);
    }
  } catch (IOException e) {
    throw new PlanningException("Partitioned Table Rewrite Failed: \n" + e.getMessage());
  }
  return null;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:28,代码来源:PartitionedTableRewriter.java

示例4: findBestOrder

import org.apache.tajo.engine.planner.LogicalPlan; //导入方法依赖的package包/类
@Override
public FoundJoinOrder findBestOrder(LogicalPlan plan, LogicalPlan.QueryBlock block, JoinGraph joinGraph,
                                    Set<String> relationsWithoutQual) throws PlanningException {

  // Setup a remain relation set to be joined
  // Why we should use LinkedHashSet? - it should keep the deterministic for the order of joins.
  // Otherwise, join orders can be different even if join costs are the same to each other.
  Set<LogicalNode> remainRelations = new LinkedHashSet<LogicalNode>();
  for (RelationNode relation : block.getRelations()) {
    remainRelations.add(relation);
  }

  LogicalNode latestJoin;
  JoinEdge bestPair;

  while (remainRelations.size() > 1) {
    // Find the best join pair among all joinable operators in candidate set.
    bestPair = getBestPair(plan, joinGraph, remainRelations);

    remainRelations.remove(bestPair.getLeftRelation()); // remainRels = remainRels \ Ti
    remainRelations.remove(bestPair.getRightRelation()); // remainRels = remainRels \ Tj

    latestJoin = createJoinNode(plan, bestPair);
    remainRelations.add(latestJoin);

    // all logical nodes should be registered to corresponding blocks
    block.registerNode(latestJoin);
  }

  JoinNode joinTree = (JoinNode) remainRelations.iterator().next();
  // all generated nodes should be registered to corresponding blocks
  block.registerNode(joinTree);
  return new FoundJoinOrder(joinTree, getCost(joinTree));
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:35,代码来源:GreedyHeuristicJoinOrderAlgorithm.java

示例5: addJoin

import org.apache.tajo.engine.planner.LogicalPlan; //导入方法依赖的package包/类
public Collection<EvalNode> addJoin(LogicalPlan plan, LogicalPlan.QueryBlock block,
                                    JoinNode joinNode) throws PlanningException {
  Set<EvalNode> cnf = Sets.newHashSet(AlgebraicUtil.toConjunctiveNormalFormArray(joinNode.getJoinQual()));
  Set<EvalNode> nonJoinQuals = Sets.newHashSet();
  for (EvalNode singleQual : cnf) {
    if (PlannerUtil.isJoinQual(singleQual)) {

      String [] relations = guessRelationsFromJoinQual(block, singleQual);
      String leftExprRelName = relations[0];
      String rightExprRelName = relations[1];

      Collection<String> leftLineage = PlannerUtil.getRelationLineageWithinQueryBlock(plan, joinNode.getLeftChild());

      boolean isLeftExprForLeftTable = leftLineage.contains(leftExprRelName);
      JoinEdge edge;
      edge = getEdge(leftExprRelName, rightExprRelName);

      if (edge != null) {
        edge.addJoinQual(singleQual);
      } else {
        if (isLeftExprForLeftTable) {
          edge = new JoinEdge(joinNode.getJoinType(),
              block.getRelation(leftExprRelName), block.getRelation(rightExprRelName), singleQual);
          addEdge(leftExprRelName, rightExprRelName, edge);
        } else {
          edge = new JoinEdge(joinNode.getJoinType(),
              block.getRelation(rightExprRelName), block.getRelation(leftExprRelName), singleQual);
          addEdge(rightExprRelName, leftExprRelName, edge);
        }
      }
    } else {
      nonJoinQuals.add(singleQual);
    }
  }
  cnf.retainAll(nonJoinQuals);
  return cnf;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:38,代码来源:JoinGraph.java

示例6: addJoin

import org.apache.tajo.engine.planner.LogicalPlan; //导入方法依赖的package包/类
public Collection<EvalNode> addJoin(LogicalPlan plan, LogicalPlan.QueryBlock block,
                                    JoinNode joinNode) throws PlanningException {
  Set<EvalNode> cnf = Sets.newHashSet(AlgebraicUtil.toConjunctiveNormalFormArray(joinNode.getJoinQual()));
  Set<EvalNode> nonJoinQuals = Sets.newHashSet();
  for (EvalNode singleQual : cnf) {
    if (EvalTreeUtil.isJoinQual(singleQual, true)) {

      String [] relations = guessRelationsFromJoinQual(block, singleQual);
      String leftExprRelName = relations[0];
      String rightExprRelName = relations[1];

      Collection<String> leftLineage = PlannerUtil.getRelationLineageWithinQueryBlock(plan, joinNode.getLeftChild());

      boolean isLeftExprForLeftTable = leftLineage.contains(leftExprRelName);
      JoinEdge edge;
      edge = getEdge(leftExprRelName, rightExprRelName);

      if (edge != null) {
        edge.addJoinQual(singleQual);
      } else {
        if (isLeftExprForLeftTable) {
          edge = new JoinEdge(joinNode.getJoinType(),
              block.getRelation(leftExprRelName), block.getRelation(rightExprRelName), singleQual);
          addEdge(leftExprRelName, rightExprRelName, edge);
        } else {
          edge = new JoinEdge(joinNode.getJoinType(),
              block.getRelation(rightExprRelName), block.getRelation(leftExprRelName), singleQual);
          addEdge(rightExprRelName, leftExprRelName, edge);
        }
      }
    } else {
      nonJoinQuals.add(singleQual);
    }
  }
  cnf.retainAll(nonJoinQuals);
  return cnf;
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:38,代码来源:JoinGraph.java

示例7: findBestOrder

import org.apache.tajo.engine.planner.LogicalPlan; //导入方法依赖的package包/类
/**
 *
 * @param plan
 * @param block
 * @param joinGraph A join graph represents join conditions and their connections among relations.
 *                  Given a graph, each vertex represents a relation, and each edge contains a join condition.
 *                  A join graph does not contain relations that do not have any corresponding join condition.
 * @param relationsWithoutQual The names of relations that do not have any corresponding join condition.
 * @return
 * @throws PlanningException
 */
FoundJoinOrder findBestOrder(LogicalPlan plan, LogicalPlan.QueryBlock block, JoinGraph joinGraph,
                             Set<String> relationsWithoutQual) throws PlanningException;
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:14,代码来源:JoinOrderAlgorithm.java


注:本文中的org.apache.tajo.engine.planner.LogicalPlan.QueryBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。