AlgebraicUtil
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using org.apache.tajo.plan.expr.AlgebraicUtil (Showing top 20 results out of 315)

origin: org.apache.tajo/tajo-plan

@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()))));
   selNode.setQual(AlgebraicUtil.createSingletonExprFromCNF(matched.toArray(new EvalNode[matched.size()])));
   context.pushingDownFilters.removeAll(matched);
origin: org.apache.tajo/tajo-plan

/**
 * Check if an expression consists of one variable and one constant and
 * the expression is a comparison operator.
 *
 * @param evalNode The expression to be checked
 * @return true if an expression consists of one variable and one constant
 * and the expression is a comparison operator. Other, false.
 */
private boolean checkIfIndexablePredicate(EvalNode evalNode) {
 // TODO - LIKE with a trailing wild-card character and IN with an array can be indexable
 return AlgebraicUtil.containSingleVar(evalNode) && AlgebraicUtil.isIndexableOperator(evalNode);
}
origin: org.apache.tajo/tajo-storage-hbase

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;
}
origin: apache/tajo

  new HashSet<>(Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(leftChild))) :
  new HashSet<>(Arrays.asList(AlgebraicUtil.toDisjunctiveNormalFormArray(leftChild)));
Set<EvalNode> rightChildSplits = innerType == EvalType.AND ?
  new HashSet<>(Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(rightChild))) :
  new HashSet<>(Arrays.asList(AlgebraicUtil.toDisjunctiveNormalFormArray(rightChild)));
  leftChild = AlgebraicUtil.createSingletonExprFromCNF(leftChildSplits);
  rightChild = AlgebraicUtil.createSingletonExprFromCNF(rightChildSplits);
  commonQual = AlgebraicUtil.createSingletonExprFromCNF(commonQuals);
 } else {
  leftChild = AlgebraicUtil.createSingletonExprFromDNF(leftChildSplits);
  rightChild = AlgebraicUtil.createSingletonExprFromDNF(rightChildSplits);
  commonQual = AlgebraicUtil.createSingletonExprFromDNF(commonQuals);
origin: org.apache.tajo/tajo-core

private EvalNode sortQual(EvalNode qual) {
 EvalNode[] cnf = AlgebraicUtil.toConjunctiveNormalFormArray(qual);
 return sortQual(cnf);
}
origin: org.apache.tajo/tajo-core

private EvalNode sortQual(EvalNode[] cnf) {
 Arrays.sort(cnf, evalNodeComparator);
 return AlgebraicUtil.createSingletonExprFromCNF(cnf);
}
origin: apache/tajo

 exprs = AlgebraicUtil.toConjunctiveNormalFormArray(algebra);
visitor.setIsHiveCatalog(true);
Expr[] filters = AlgebraicUtil.getRearrangedCNFExpressions(databaseName + "." + tableName, partitionColumns, exprs);
origin: org.apache.tajo/tajo-plan

private static EvalNode _transpose(BinaryEval _expr, Column target) {
  EvalNode expr = eliminateConstantExprs(_expr);
  if (isSingleVar(binaryEval.getLeftExpr())) {
   return expr;
    PartialBinaryExpr tmpTerm = splitRightTerm((BinaryEval) left);
    tmpTerm.type = inverseOperator(tmpTerm.type);
    tmpTerm.setLeftExpr(((BinaryEval)expr).getRightExpr());
    lTerm = ((BinaryEval)left).getLeftExpr();
   } else {
    PartialBinaryExpr tmpTerm = splitLeftTerm((BinaryEval) left);
    tmpTerm.type = inverseOperator(tmpTerm.type);
    tmpTerm.setLeftExpr(((BinaryEval)expr).getRightExpr());
    lTerm = ((BinaryEval)left).getRightExpr();
  return _transpose(new BinaryEval(expr.getType(), lTerm, rTerm), target);
 } else {
  return _expr;
origin: org.apache.tajo/tajo-storage-hbase

/**
 * Check if an expression consists of one variable and one constant and
 * the expression is a comparison operator.
 *
 * @param evalNode The expression to be checked
 * @return true if an expression consists of one variable and one constant
 * and the expression is a comparison operator. Other, false.
 */
private boolean checkIfIndexablePredicate(EvalNode evalNode) {
 return AlgebraicUtil.containSingleVar(evalNode) && isIndexableOperator(evalNode);
}
origin: apache/tajo

@Test
public final void testGetDNF() throws TajoException {
 // "select score from people where score > 1 and score < 3 or score > 7 and score < 10", // 7
 EvalNode node = getRootSelection(QUERIES[7]);
 EvalNode [] cnf = AlgebraicUtil.toDisjunctiveNormalFormArray(node);
 assertEquals(2, cnf.length);
 assertEquals("(default.people.score (INT4) > 1 AND default.people.score (INT4) < 3)", cnf[0].toString());
 assertEquals("(7 < default.people.score (INT4) AND default.people.score (INT4) < 10)", cnf[1].toString());
}

origin: apache/tajo

@Test
public final void testSimplify() throws TajoException {
 List<Target> targets = getRawTargets(QUERIES[0]);
 EvalNode node = AlgebraicUtil.eliminateConstantExprs(targets.get(0).getEvalTree());
 assertEquals(EvalType.CONST, node.getType());
 assertEquals(7, node.bind(null, null).eval(null).asInt4());
 node = AlgebraicUtil.eliminateConstantExprs(targets.get(1).getEvalTree());
 assertEquals(EvalType.CONST, node.getType());
 assertTrue(7.0d == node.bind(null, null).eval(null).asFloat8());
 Expr expr = analyzer.parse(QUERIES[1]);
 LogicalPlan plan = planner.createPlan(defaultContext, expr, true);
 targets = plan.getRootBlock().getRawTargets();
 Column col1 = new Column("default.people.score", TajoDataTypes.Type.INT4);
 Collection<EvalNode> exprs =
   EvalTreeUtil.getContainExpr(targets.get(0).getEvalTree(), col1);
 node = exprs.iterator().next();
}

origin: org.apache.tajo/tajo-plan

  TUtil.newHashSet(AlgebraicUtil.toConjunctiveNormalFormArray(leftChild)) :
  TUtil.newHashSet(AlgebraicUtil.toDisjunctiveNormalFormArray(leftChild));
Set<EvalNode> rightChildSplits = innerType == EvalType.AND ?
  TUtil.newHashSet(AlgebraicUtil.toConjunctiveNormalFormArray(rightChild)) :
  TUtil.newHashSet(AlgebraicUtil.toDisjunctiveNormalFormArray(rightChild));
  leftChild = AlgebraicUtil.createSingletonExprFromCNF(leftChildSplits);
  rightChild = AlgebraicUtil.createSingletonExprFromCNF(rightChildSplits);
  commonQual = AlgebraicUtil.createSingletonExprFromCNF(commonQuals);
 } else {
  leftChild = AlgebraicUtil.createSingletonExprFromDNF(leftChildSplits);
  rightChild = AlgebraicUtil.createSingletonExprFromDNF(rightChildSplits);
  commonQual = AlgebraicUtil.createSingletonExprFromDNF(commonQuals);
origin: apache/tajo

private EvalNode sortQual(EvalNode qual) {
 EvalNode[] cnf = AlgebraicUtil.toConjunctiveNormalFormArray(qual);
 return sortQual(cnf);
}
origin: apache/tajo

private EvalNode sortQual(EvalNode[] cnf) {
 Arrays.sort(cnf, evalNodeComparator);
 return AlgebraicUtil.createSingletonExprFromCNF(cnf);
}
origin: apache/tajo

 exprs = AlgebraicUtil.toConjunctiveNormalFormArray(algebra);
visitor.setIsHiveCatalog(false);
Expr[] filters = AlgebraicUtil.getRearrangedCNFExpressions(tableName, partitionColumns, exprs);
origin: apache/tajo

private static EvalNode _transpose(BinaryEval _expr, Column target) {
  EvalNode expr = eliminateConstantExprs(_expr);
  if (isSingleVar(binaryEval.getLeftExpr())) {
   return expr;
    PartialBinaryExpr tmpTerm = splitRightTerm((BinaryEval) left);
    tmpTerm.type = inverseOperator(tmpTerm.type);
    tmpTerm.setLeftExpr(((BinaryEval)expr).getRightExpr());
    lTerm = ((BinaryEval)left).getLeftExpr();
   } else {
    PartialBinaryExpr tmpTerm = splitLeftTerm((BinaryEval) left);
    tmpTerm.type = inverseOperator(tmpTerm.type);
    tmpTerm.setLeftExpr(((BinaryEval)expr).getRightExpr());
    lTerm = ((BinaryEval)left).getRightExpr();
  return _transpose(new BinaryEval(expr.getType(), lTerm, rTerm), target);
 } else {
  return _expr;
origin: apache/tajo

/**
 * Check if an expression consists of one variable and one constant and
 * the expression is a comparison operator.
 *
 * @param evalNode The expression to be checked
 * @return true if an expression consists of one variable and one constant
 * and the expression is a comparison operator. Other, false.
 */
private boolean checkIfIndexablePredicate(EvalNode evalNode) {
 return AlgebraicUtil.containSingleVar(evalNode) && isIndexableOperator(evalNode);
}
origin: apache/tajo

List<EvalNode> leftFilters = Lists.newArrayList();
List<EvalNode> rightFilters = Lists.newArrayList();
for (EvalNode eachQual : AlgebraicUtil.toConjunctiveNormalFormArray(joinQual)) {
 if (!(eachQual instanceof BinaryEval)) {
  continue; // todo 'between', etc.
  joinQuals.isEmpty() ? null : AlgebraicUtil.createSingletonExprFromCNF(joinQuals),
  leftFilters.isEmpty() ? null : AlgebraicUtil.createSingletonExprFromCNF(leftFilters),
  rightFilters.isEmpty() ? null : AlgebraicUtil.createSingletonExprFromCNF(rightFilters)
};
origin: apache/tajo

EvalNode[] originDnfs = AlgebraicUtil.toDisjunctiveNormalFormArray(node.getQual());
List<EvalNode> rewrittenDnfs = new ArrayList<>();
for (EvalNode eachDnf : originDnfs) {
 Set<EvalNode> cnfs = new HashSet<>(Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(eachDnf)));
 cnfs.removeAll(inSubqueries);
 if (!cnfs.isEmpty()) {
  rewrittenDnfs.add(AlgebraicUtil.createSingletonExprFromCNF(cnfs));
 node.setQual(AlgebraicUtil.createSingletonExprFromDNF(rewrittenDnfs.toArray(new EvalNode[rewrittenDnfs.size()])));
origin: apache/tajo

public void setSingletonPredicate(EvalNode predicates) {
 this.setPredicates(Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(predicates)));
}
org.apache.tajo.plan.exprAlgebraicUtil

Most used methods

  • toConjunctiveNormalFormArray
    Transforms a expression to an array of conjunctive normal formed expressions.
  • containSingleVar
  • createSingletonExprFromCNF
    Convert a list of conjunctive normal forms into a singleton expression.
  • toDisjunctiveNormalFormArray
    Transforms a expression to an array of disjunctive normal formed expressions.
  • eliminateConstantExprs
    Simplify the given expr. That is, all subexprs consisting of only constants are calculated immediate
  • getRearrangedCNFExpressions
    Build Exprs for all columns with a list of filter conditions. For example, consider you have a parti
  • _transpose
  • commutate
    Commutate two terms which are added, subtracted and multiplied.
  • createSingletonExprFromCNFByExpr
    Convert a list of conjunctive normal forms into a singleton expression.
  • createSingletonExprFromCNFRecursive
  • createSingletonExprFromCNFRecursiveByExpr
  • createSingletonExprFromDNF
    Convert a list of conjunctive normal forms into a singleton expression.
  • createSingletonExprFromCNFRecursiveByExpr,
  • createSingletonExprFromDNF,
  • createSingletonExprFromDNFRecursive,
  • findMostBottomExpr,
  • findTopExpr,
  • inverseOperator,
  • isIndexableOperator,
  • isSingleVar,
  • splitLeftTerm,
  • splitRightTerm

Popular in Java

  • Start an intent from android
  • runOnUiThread (Activity)
  • findViewById (Activity)
  • getContentResolver (Context)
  • Menu (java.awt)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • JFrame (javax.swing)

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)