當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。