本文整理匯總了Java中org.apache.tajo.engine.planner.PlanningException類的典型用法代碼示例。如果您正苦於以下問題:Java PlanningException類的具體用法?Java PlanningException怎麽用?Java PlanningException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PlanningException類屬於org.apache.tajo.engine.planner包,在下文中一共展示了PlanningException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testNotBroadcastJoinTwoLargeTable
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testNotBroadcastJoinTwoLargeTable() throws IOException, PlanningException {
// This query is not broadcast join
String query = "select count(*) from large1 " +
"join large2 on large1_id = large2_id ";
LogicalPlanner planner = new LogicalPlanner(catalog);
LogicalOptimizer optimizer = new LogicalOptimizer(conf);
Expr expr = analyzer.parse(query);
LogicalPlan plan = planner.createPlan(LocalTajoTestingUtility.createDummySession(), expr);
optimizer.optimize(plan);
QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0);
QueryContext queryContext = new QueryContext();
MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan);
GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog);
globalPlanner.build(masterPlan);
ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan);
while (ebCursor.hasNext()) {
ExecutionBlock eb = ebCursor.nextBlock();
Collection<String> broadcastTables = eb.getBroadcastTables();
assertTrue(broadcastTables == null || broadcastTables.isEmpty());
}
}
示例2: rewrite
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的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;
}
示例3: updateTableStat
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
private void updateTableStat(PartitionedTableScanNode scanNode) throws PlanningException {
if (scanNode.getInputPaths().length > 0) {
try {
FileSystem fs = scanNode.getInputPaths()[0].getFileSystem(systemConf);
long totalVolume = 0;
for (Path input : scanNode.getInputPaths()) {
ContentSummary summary = fs.getContentSummary(input);
totalVolume += summary.getLength();
totalVolume += summary.getFileCount();
}
scanNode.getTableDesc().getStats().setNumBytes(totalVolume);
} catch (IOException e) {
throw new PlanningException(e);
}
}
}
示例4: findJoin
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
/**
* Find a join between two logical operator trees
*
* @return If there is no join condition between two relation, it returns NULL value.
*/
private static JoinEdge findJoin(LogicalPlan plan, JoinGraph graph, LogicalNode outer, LogicalNode inner) throws PlanningException {
JoinEdge foundJoinEdge = null;
for (String outerName : PlannerUtil.getRelationLineageWithinQueryBlock(plan, outer)) {
for (String innerName : PlannerUtil.getRelationLineageWithinQueryBlock(plan, inner)) {
// Find all joins between two relations and merge them into one join if possible
if (graph.hasEdge(outerName, innerName)) {
JoinEdge existJoinEdge = graph.getEdge(outerName, innerName);
foundJoinEdge = new JoinEdge(existJoinEdge.getJoinType(), outer, inner, existJoinEdge.getJoinQual());
}
}
}
if (foundJoinEdge == null) {
foundJoinEdge = new JoinEdge(JoinType.CROSS, outer, inner);
}
return foundJoinEdge;
}
示例5: testGetContainExprs
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testGetContainExprs() throws CloneNotSupportedException, PlanningException {
Expr expr = analyzer.parse(QUERIES[1]);
LogicalPlan plan = planner.createPlan(expr, true);
Target [] targets = plan.getRootBlock().getRawTargets();
Column col1 = new Column("people.score", TajoDataTypes.Type.INT4);
Collection<EvalNode> exprs =
EvalTreeUtil.getContainExpr(targets[0].getEvalTree(), col1);
EvalNode node = exprs.iterator().next();
assertEquals(EvalType.LTH, node.getType());
assertEquals(EvalType.PLUS, node.getLeftExpr().getType());
assertEquals(new ConstEval(DatumFactory.createInt4(4)), node.getRightExpr());
Column col2 = new Column("people.age", TajoDataTypes.Type.INT4);
exprs = EvalTreeUtil.getContainExpr(targets[1].getEvalTree(), col2);
node = exprs.iterator().next();
assertEquals(EvalType.GTH, node.getType());
assertEquals("people.age", node.getLeftExpr().getName());
assertEquals(new ConstEval(DatumFactory.createInt4(5)), node.getRightExpr());
}
示例6: testGetCNF
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testGetCNF() throws PlanningException {
// "select score from people where score < 10 and 4 < score "
EvalNode node = getRootSelection(QUERIES[5]);
EvalNode [] cnf = AlgebraicUtil.toConjunctiveNormalFormArray(node);
Column col1 = new Column("people.score", TajoDataTypes.Type.INT4);
assertEquals(2, cnf.length);
EvalNode first = cnf[0];
EvalNode second = cnf[1];
FieldEval field = first.getLeftExpr();
assertEquals(col1, field.getColumnRef());
assertEquals(EvalType.LTH, first.getType());
assertEquals(10, first.getRightExpr().eval(null, null).asInt4());
field = second.getRightExpr();
assertEquals(col1, field.getColumnRef());
assertEquals(EvalType.LTH, second.getType());
assertEquals(4, second.getLeftExpr().eval(null, null).asInt4());
}
示例7: testSimplify
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testSimplify() throws PlanningException {
Target [] targets = getRawTargets(QUERIES[0]);
EvalNode node = AlgebraicUtil.eliminateConstantExprs(targets[0].getEvalTree());
assertEquals(EvalType.CONST, node.getType());
assertEquals(7, node.eval(null, null).asInt4());
node = AlgebraicUtil.eliminateConstantExprs(targets[1].getEvalTree());
assertEquals(EvalType.CONST, node.getType());
assertTrue(7.0d == node.eval(null, null).asFloat8());
Expr expr = analyzer.parse(QUERIES[1]);
LogicalPlan plan = planner.createPlan(expr, true);
targets = plan.getRootBlock().getRawTargets();
Column col1 = new Column("people.score", TajoDataTypes.Type.INT4);
Collection<EvalNode> exprs =
EvalTreeUtil.getContainExpr(targets[0].getEvalTree(), col1);
node = exprs.iterator().next();
}
示例8: testTranspose
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testTranspose() throws PlanningException {
Column col1 = new Column("people.score", TajoDataTypes.Type.INT4);
EvalNode node = getRootSelection(QUERIES[3]);
// we expect that score < 3
EvalNode transposed = AlgebraicUtil.transpose(node, col1);
assertEquals(EvalType.GTH, transposed.getType());
FieldEval field = transposed.getLeftExpr();
assertEquals(col1, field.getColumnRef());
assertEquals(1, transposed.getRightExpr().eval(null, null).asInt4());
node = getRootSelection(QUERIES[4]);
// we expect that score < 3
transposed = AlgebraicUtil.transpose(node, col1);
assertEquals(EvalType.LTH, transposed.getType());
field = transposed.getLeftExpr();
assertEquals(col1, field.getColumnRef());
assertEquals(2, transposed.getRightExpr().eval(null, null).asInt4());
}
示例9: testFindDistinctAggFunctions
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testFindDistinctAggFunctions() throws PlanningException {
String query = "select sum(score) + max(age) from people";
Expr expr = analyzer.parse(query);
LogicalPlan plan = planner.createPlan(expr);
GroupbyNode groupByNode = plan.getRootBlock().getNode(NodeType.GROUP_BY);
EvalNode [] aggEvals = groupByNode.getAggFunctions();
List<AggregationFunctionCallEval> list = new ArrayList<AggregationFunctionCallEval>();
for (int i = 0; i < aggEvals.length; i++) {
list.addAll(EvalTreeUtil.findDistinctAggFunction(aggEvals[i]));
}
assertEquals(2, list.size());
Set<String> result = Sets.newHashSet("max", "sum");
for (AggregationFunctionCallEval eval : list) {
assertTrue(result.contains(eval.getName()));
}
}
示例10: testGetContainExprs
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testGetContainExprs() throws CloneNotSupportedException, PlanningException {
Expr expr = analyzer.parse(QUERIES[1]);
LogicalPlan plan = planner.createPlan(session, expr, true);
Target [] targets = plan.getRootBlock().getRawTargets();
Column col1 = new Column("default.people.score", TajoDataTypes.Type.INT4);
Collection<EvalNode> exprs =
EvalTreeUtil.getContainExpr(targets[0].getEvalTree(), col1);
EvalNode node = exprs.iterator().next();
assertEquals(EvalType.LTH, node.getType());
assertEquals(EvalType.PLUS, node.getLeftExpr().getType());
assertEquals(new ConstEval(DatumFactory.createInt4(4)), node.getRightExpr());
Column col2 = new Column("default.people.age", TajoDataTypes.Type.INT4);
exprs = EvalTreeUtil.getContainExpr(targets[1].getEvalTree(), col2);
node = exprs.iterator().next();
assertEquals(EvalType.GTH, node.getType());
assertEquals("default.people.age", node.getLeftExpr().getName());
assertEquals(new ConstEval(DatumFactory.createInt4(5)), node.getRightExpr());
}
示例11: testGetCNF
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testGetCNF() throws PlanningException {
// "select score from people where score < 10 and 4 < score "
EvalNode node = getRootSelection(QUERIES[5]);
EvalNode [] cnf = AlgebraicUtil.toConjunctiveNormalFormArray(node);
Column col1 = new Column("default.people.score", TajoDataTypes.Type.INT4);
assertEquals(2, cnf.length);
EvalNode first = cnf[0];
EvalNode second = cnf[1];
FieldEval field = first.getLeftExpr();
assertEquals(col1, field.getColumnRef());
assertEquals(EvalType.LTH, first.getType());
assertEquals(10, first.getRightExpr().eval(null, null).asInt4());
field = second.getRightExpr();
assertEquals(col1, field.getColumnRef());
assertEquals(EvalType.LTH, second.getType());
assertEquals(4, second.getLeftExpr().eval(null, null).asInt4());
}
示例12: testSimplify
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testSimplify() throws PlanningException {
Target [] targets = getRawTargets(QUERIES[0]);
EvalNode node = AlgebraicUtil.eliminateConstantExprs(targets[0].getEvalTree());
assertEquals(EvalType.CONST, node.getType());
assertEquals(7, node.eval(null, null).asInt4());
node = AlgebraicUtil.eliminateConstantExprs(targets[1].getEvalTree());
assertEquals(EvalType.CONST, node.getType());
assertTrue(7.0d == node.eval(null, null).asFloat8());
Expr expr = analyzer.parse(QUERIES[1]);
LogicalPlan plan = planner.createPlan(session, expr, true);
targets = plan.getRootBlock().getRawTargets();
Column col1 = new Column("default.people.score", TajoDataTypes.Type.INT4);
Collection<EvalNode> exprs =
EvalTreeUtil.getContainExpr(targets[0].getEvalTree(), col1);
node = exprs.iterator().next();
}
示例13: testTranspose
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testTranspose() throws PlanningException {
Column col1 = new Column("default.people.score", TajoDataTypes.Type.INT4);
EvalNode node = getRootSelection(QUERIES[3]);
// we expect that score < 3
EvalNode transposed = AlgebraicUtil.transpose(node, col1);
assertEquals(EvalType.GTH, transposed.getType());
FieldEval field = transposed.getLeftExpr();
assertEquals(col1, field.getColumnRef());
assertEquals(1, transposed.getRightExpr().eval(null, null).asInt4());
node = getRootSelection(QUERIES[4]);
// we expect that score < 3
transposed = AlgebraicUtil.transpose(node, col1);
assertEquals(EvalType.LTH, transposed.getType());
field = transposed.getLeftExpr();
assertEquals(col1, field.getColumnRef());
assertEquals(2, transposed.getRightExpr().eval(null, null).asInt4());
}
示例14: testFindDistinctAggFunctions
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
@Test
public final void testFindDistinctAggFunctions() throws PlanningException {
String query = "select sum(score) + max(age) from people";
Expr expr = analyzer.parse(query);
LogicalPlan plan = planner.createPlan(session, expr);
GroupbyNode groupByNode = plan.getRootBlock().getNode(NodeType.GROUP_BY);
EvalNode [] aggEvals = groupByNode.getAggFunctions();
List<AggregationFunctionCallEval> list = new ArrayList<AggregationFunctionCallEval>();
for (int i = 0; i < aggEvals.length; i++) {
list.addAll(EvalTreeUtil.findDistinctAggFunction(aggEvals[i]));
}
assertEquals(2, list.size());
Set<String> result = Sets.newHashSet("max", "sum");
for (AggregationFunctionCallEval eval : list) {
assertTrue(result.contains(eval.getName()));
}
}
示例15: rewrite
import org.apache.tajo.engine.planner.PlanningException; //導入依賴的package包/類
/**
* Rewrite a logical plan with all query rewrite rules added to this engine.
*
* @param plan The plan to be rewritten with all query rewrite rule.
* @return The rewritten plan.
*/
public LogicalPlan rewrite(LogicalPlan plan) throws PlanningException {
RewriteRule rule;
for (Entry<String, RewriteRule> rewriteRule : rewriteRules.entrySet()) {
rule = rewriteRule.getValue();
if (rule.isEligible(plan)) {
plan = rule.rewrite(plan);
LOG.info("The rule \"" + rule.getName() + " \" rewrites the query.");
}
}
return plan;
}