private EvalNode sortQual(EvalNode qual) { EvalNode[] cnf = AlgebraicUtil.toConjunctiveNormalFormArray(qual); return sortQual(cnf); }
private EvalNode sortQual(EvalNode qual) { EvalNode[] cnf = AlgebraicUtil.toConjunctiveNormalFormArray(qual); return sortQual(cnf); }
public void setSingletonPredicate(EvalNode predicates) { this.setPredicates(Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(predicates))); }
public List<Set<EvalNode>> findIndexablePredicateSet(@Nullable EvalNode qual, Column[] indexableColumns) throws IOException { List<Set<EvalNode>> indexablePredicateList = new ArrayList<>(); // if a query statement has a search condition, try to find indexable predicates if (indexableColumns != null && qual != null) { EvalNode[] disjunctiveForms = AlgebraicUtil.toDisjunctiveNormalFormArray(qual); // add qualifier to schema for qual for (Column column : indexableColumns) { for (EvalNode disjunctiveExpr : disjunctiveForms) { EvalNode[] conjunctiveForms = AlgebraicUtil.toConjunctiveNormalFormArray(disjunctiveExpr); Set<EvalNode> indexablePredicateSet = Sets.newHashSet(); for (EvalNode conjunctiveExpr : conjunctiveForms) { if (checkIfIndexablePredicateOnTargetColumn(conjunctiveExpr, column)) { indexablePredicateSet.add(conjunctiveExpr); } } if (!indexablePredicateSet.isEmpty()) { indexablePredicateList.add(indexablePredicateSet); } } } } return indexablePredicateList; }
public List<Set<EvalNode>> findIndexablePredicateSet(@Nullable EvalNode qual, Column[] indexableColumns) throws IOException { List<Set<EvalNode>> indexablePredicateList = new ArrayList<>(); // if a query statement has a search condition, try to find indexable predicates if (indexableColumns != null && qual != null) { EvalNode[] disjunctiveForms = AlgebraicUtil.toDisjunctiveNormalFormArray(qual); // add qualifier to schema for qual for (Column column : indexableColumns) { for (EvalNode disjunctiveExpr : disjunctiveForms) { EvalNode[] conjunctiveForms = AlgebraicUtil.toConjunctiveNormalFormArray(disjunctiveExpr); Set<EvalNode> indexablePredicateSet = Sets.newHashSet(); for (EvalNode conjunctiveExpr : conjunctiveForms) { if (checkIfIndexablePredicateOnTargetColumn(conjunctiveExpr, column)) { indexablePredicateSet.add(conjunctiveExpr); } } if (!indexablePredicateSet.isEmpty()) { indexablePredicateList.add(indexablePredicateSet); } } } } return indexablePredicateList; }
public void setSingletonPredicate(EvalNode predicates) { this.setPredicates(TUtil.newHashSet(AlgebraicUtil.toConjunctiveNormalFormArray(predicates))); }
@Override public LogicalNode visitFilter(JoinGraphContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node, Stack<LogicalNode> stack) throws TajoException { // all join predicate candidates must be collected before building the join tree except non-equality conditions // TODO: non-equality conditions should also be considered as join conditions after TAJO-1554 List<EvalNode> candidateJoinQuals = new ArrayList<>(); for (EvalNode eachEval : AlgebraicUtil.toConjunctiveNormalFormArray(node.getQual())) { if (EvalTreeUtil.isJoinQual(eachEval, false)) { candidateJoinQuals.add(eachEval); } } context.addCandidateJoinFilters(candidateJoinQuals); super.visitFilter(context, plan, block, node, stack); return node; }
@Override public LogicalNode visitFilter(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode selNode, Stack<LogicalNode> stack) throws TajoException { context.pushingDownFilters.addAll(new HashSet<>(Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(selNode.getQual()))));
@Override public LogicalNode visitFilter(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode selNode, Stack<LogicalNode> stack) throws TajoException { context.pushingDownFilters.addAll(new HashSet<>(Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(selNode.getQual()))));
exprs = AlgebraicUtil.toConjunctiveNormalFormArray(algebra);
@Override public LogicalNode visitFilter(JoinGraphContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node, Stack<LogicalNode> stack) throws TajoException { // all join predicate candidates must be collected before building the join tree except non-equality conditions // TODO: non-equality conditions should also be considered as join conditions after TAJO-1554 List<EvalNode> candidateJoinQuals = TUtil.newList(); for (EvalNode eachEval : AlgebraicUtil.toConjunctiveNormalFormArray(node.getQual())) { if (EvalTreeUtil.isJoinQual(eachEval, false)) { candidateJoinQuals.add(eachEval); } } context.addCandidateJoinFilters(candidateJoinQuals); super.visitFilter(context, plan, block, node, stack); return node; }
@Test public final void testTransformCNF2Singleton() throws TajoException { // "select score from people where score < 10 and 4 < score " EvalNode node = getRootSelection(QUERIES[6]); EvalNode [] cnf1 = AlgebraicUtil.toConjunctiveNormalFormArray(node); assertEquals(3, cnf1.length); EvalNode conj = AlgebraicUtil.createSingletonExprFromCNF(cnf1); EvalNode [] cnf2 = AlgebraicUtil.toConjunctiveNormalFormArray(conj); Set<EvalNode> set1 = Sets.newHashSet(cnf1); Set<EvalNode> set2 = Sets.newHashSet(cnf2); assertEquals(set1, set2); }
List<EvalNode> leftFilters = Lists.newArrayList(); List<EvalNode> rightFilters = Lists.newArrayList(); for (EvalNode eachQual : AlgebraicUtil.toConjunctiveNormalFormArray(joinQual)) { if (!(eachQual instanceof BinaryEval)) { continue; // todo 'between', etc.
EvalNode [] conjunctiveForms = AlgebraicUtil.toConjunctiveNormalFormArray(scanNode.getQual()); Set<EvalNode> remainExprs = Sets.newHashSet(conjunctiveForms);
@Override public LogicalNode visitJoin(CostContext joinGraphContext, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode joinNode, Stack<LogicalNode> stack) throws TajoException { super.visitJoin(joinGraphContext, plan, block, joinNode, stack); double filterFactor = 1; if (joinNode.hasJoinQual()) { EvalNode [] quals = AlgebraicUtil.toConjunctiveNormalFormArray(joinNode.getJoinQual()); filterFactor = Math.pow(GreedyHeuristicJoinOrderAlgorithm.DEFAULT_SELECTION_FACTOR, quals.length); } if (joinNode.getLeftChild() instanceof RelationNode) { joinGraphContext.accumulatedCost = getCost(joinNode.getLeftChild()) * getCost(joinNode.getRightChild()) * filterFactor; } else { joinGraphContext.accumulatedCost = joinGraphContext.accumulatedCost + (joinGraphContext.accumulatedCost * getCost(joinNode.getRightChild()) * filterFactor); } return joinNode; } }
@Override public LogicalNode visitJoin(CostContext joinGraphContext, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode joinNode, Stack<LogicalNode> stack) throws TajoException { super.visitJoin(joinGraphContext, plan, block, joinNode, stack); double filterFactor = 1; if (joinNode.hasJoinQual()) { EvalNode [] quals = AlgebraicUtil.toConjunctiveNormalFormArray(joinNode.getJoinQual()); filterFactor = Math.pow(GreedyHeuristicJoinOrderAlgorithm.DEFAULT_SELECTION_FACTOR, quals.length); } if (joinNode.getLeftChild() instanceof RelationNode) { joinGraphContext.accumulatedCost = getCost((RelationNode)joinNode.getLeftChild()) * getCost((LogicalNode)joinNode.getRightChild())* filterFactor; } else { joinGraphContext.accumulatedCost = joinGraphContext.accumulatedCost + (joinGraphContext.accumulatedCost * getCost((RelationNode)joinNode.getRightChild()) * filterFactor); } return joinNode; } }
ScanNode scanNode = (ScanNode)eachNode; if (scanNode.hasQual()) { EvalNode[] evalNodes = AlgebraicUtil.toConjunctiveNormalFormArray(scanNode.getQual());
ScanNode scanNode = (ScanNode)eachNode; if (scanNode.hasQual()) { EvalNode[] evalNodes = AlgebraicUtil.toConjunctiveNormalFormArray(scanNode.getQual());
EvalNode[] evalNodes = AlgebraicUtil.toConjunctiveNormalFormArray(joinNode.getJoinQual());
@Test public final void testGetCNF() throws TajoException { // "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); BinaryEval first = (BinaryEval) cnf[0]; BinaryEval second = (BinaryEval) cnf[1]; FieldEval field = first.getLeftExpr(); assertEquals(col1, field.getColumnRef()); assertEquals(EvalType.LTH, first.getType()); assertEquals(10, first.getRightExpr().bind(null, null).eval(null).asInt4()); field = second.getRightExpr(); assertEquals(col1, field.getColumnRef()); assertEquals(EvalType.LTH, second.getType()); assertEquals(4, second.getLeftExpr().bind(null, null).eval(null).asInt4()); }