private EvalNode sortQual(EvalNode[] cnf) { Arrays.sort(cnf, evalNodeComparator); return AlgebraicUtil.createSingletonExprFromCNF(cnf); }
private EvalNode sortQual(EvalNode[] cnf) { Arrays.sort(cnf, evalNodeComparator); return AlgebraicUtil.createSingletonExprFromCNF(cnf); }
public static EvalNode createSingletonExprFromCNF(Collection<EvalNode> cnfExprs) { return createSingletonExprFromCNF(cnfExprs.toArray(new EvalNode[cnfExprs.size()])); }
public static EvalNode createSingletonExprFromCNF(Collection<EvalNode> cnfExprs) { return createSingletonExprFromCNF(cnfExprs.toArray(new EvalNode[cnfExprs.size()])); }
public EvalNode getSingletonPredicate() { if (predicates.size() > 1) { return AlgebraicUtil.createSingletonExprFromCNF(predicates.toArray(new EvalNode[predicates.size()])); } else if (predicates.size() == 1) { return predicates.iterator().next(); } else { return null; } }
public EvalNode getSingletonPredicate() { if (predicates.size() > 1) { return AlgebraicUtil.createSingletonExprFromCNF(predicates.toArray(new EvalNode[predicates.size()])); } else if (predicates.size() == 1) { return predicates.iterator().next(); } else { return null; } }
joinQuals.isEmpty() ? null : AlgebraicUtil.createSingletonExprFromCNF(joinQuals), leftFilters.isEmpty() ? null : AlgebraicUtil.createSingletonExprFromCNF(leftFilters), rightFilters.isEmpty() ? null : AlgebraicUtil.createSingletonExprFromCNF(rightFilters) };
selNode.setQual(AlgebraicUtil.createSingletonExprFromCNF(matched.toArray(new EvalNode[matched.size()]))); context.pushingDownFilters.removeAll(matched);
selNode.setQual(AlgebraicUtil.createSingletonExprFromCNF(matched.toArray(new EvalNode[matched.size()]))); context.pushingDownFilters.removeAll(matched);
joinQuals.isEmpty() ? null : AlgebraicUtil.createSingletonExprFromCNF(joinQuals), leftFilters.isEmpty() ? null : AlgebraicUtil.createSingletonExprFromCNF(leftFilters), rightFilters.isEmpty() ? null : AlgebraicUtil.createSingletonExprFromCNF(rightFilters) };
EvalNode filterPerLevel = AlgebraicUtil.createSingletonExprFromCNF( accumulatedFilters.toArray(new EvalNode[accumulatedFilters.size()])); filters[i] = new PartitionPathFilter(partitionColumns, filterPerLevel);
EvalNode filterPerLevel = AlgebraicUtil.createSingletonExprFromCNF( accumulatedFilters.toArray(new EvalNode[accumulatedFilters.size()])); filters[i] = new PartitionPathFilter(partitionColumns, filterPerLevel);
filters.addAll(TUtil.newHashSet(AlgebraicUtil.toConjunctiveNormalFormArray(topParentSelect.getQual()))); filters.addAll(remainingQuals); topParentSelect.setQual(AlgebraicUtil.createSingletonExprFromCNF( filters.toArray(new EvalNode[filters.size()]))); return newJoinNode; } else { SelectionNode newSelection = plan.createNode(SelectionNode.class); newSelection.setQual(AlgebraicUtil.createSingletonExprFromCNF( remainingQuals.toArray(new EvalNode[remainingQuals.size()]))); newSelection.setChild(newJoinNode);
if (notMatched.size() > 1) { qual = AlgebraicUtil.createSingletonExprFromCNF(notMatched.toArray(new EvalNode[notMatched.size()])); } else if (notMatched.size() == 1) {
} else { scanNode.setQual( AlgebraicUtil.createSingletonExprFromCNF(remainExprs.toArray(new EvalNode[remainExprs.size()])));
} else { scanNode.setQual( AlgebraicUtil.createSingletonExprFromCNF(remainExprs.toArray(new EvalNode[remainExprs.size()])));
@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); }
/** * Build algebra expressions for querying partitions and partition keys by using EvalNodeToExprConverter. * * @param databaseName the database name * @param tableName the table name * @param conjunctiveForms EvalNode which contains filter conditions * @return */ public static PartitionsByAlgebraProto getPartitionsAlgebraProto( String databaseName, String tableName, EvalNode [] conjunctiveForms) { PartitionsByAlgebraProto.Builder request = PartitionsByAlgebraProto.newBuilder(); request.setDatabaseName(databaseName); request.setTableName(tableName); if (conjunctiveForms != null) { EvalNode evalNode = AlgebraicUtil.createSingletonExprFromCNF(conjunctiveForms); EvalNodeToExprConverter convertor = new EvalNodeToExprConverter(databaseName + "." + tableName); convertor.visit(null, evalNode, new Stack<>()); request.setAlgebra(convertor.getResult().toJson()); } else { request.setAlgebra(""); } return request.build(); }
private SelectionNode createSelectionParentForNonEquiThetaJoinQuals(LogicalPlan plan, QueryBlock block, Stack<LogicalNode> stack, JoinNode joinNode, List<EvalNode> nonEquiThetaJoinQuals) { SelectionNode selectionNode = plan.createNode(SelectionNode.class); selectionNode.setInSchema(joinNode.getOutSchema()); selectionNode.setOutSchema(joinNode.getOutSchema()); selectionNode.setQual(AlgebraicUtil.createSingletonExprFromCNF(nonEquiThetaJoinQuals)); block.registerNode(selectionNode); LogicalNode parent = stack.peek(); if (parent instanceof UnaryNode) { ((UnaryNode) parent).setChild(selectionNode); } else if (parent instanceof BinaryNode) { BinaryNode binaryParent = (BinaryNode) parent; if (binaryParent.getLeftChild().getPID() == joinNode.getPID()) { binaryParent.setLeftChild(selectionNode); } else if (binaryParent.getRightChild().getPID() == joinNode.getPID()) { binaryParent.setRightChild(selectionNode); } } else if (parent instanceof TableSubQueryNode) { ((TableSubQueryNode) parent).setSubQuery(selectionNode); } selectionNode.setChild(joinNode); return selectionNode; }
private SelectionNode createSelectionParentForNonEquiThetaJoinQuals(LogicalPlan plan, QueryBlock block, Stack<LogicalNode> stack, JoinNode joinNode, List<EvalNode> nonEquiThetaJoinQuals) { SelectionNode selectionNode = plan.createNode(SelectionNode.class); selectionNode.setInSchema(joinNode.getOutSchema()); selectionNode.setOutSchema(joinNode.getOutSchema()); selectionNode.setQual(AlgebraicUtil.createSingletonExprFromCNF(nonEquiThetaJoinQuals)); block.registerNode(selectionNode); LogicalNode parent = stack.peek(); if (parent instanceof UnaryNode) { ((UnaryNode) parent).setChild(selectionNode); } else if (parent instanceof BinaryNode) { BinaryNode binaryParent = (BinaryNode) parent; if (binaryParent.getLeftChild().getPID() == joinNode.getPID()) { binaryParent.setLeftChild(selectionNode); } else if (binaryParent.getRightChild().getPID() == joinNode.getPID()) { binaryParent.setRightChild(selectionNode); } } else if (parent instanceof TableSubQueryNode) { ((TableSubQueryNode) parent).setSubQuery(selectionNode); } selectionNode.setChild(joinNode); return selectionNode; }