Tabnine Logo
RelMdUtil
Code IndexAdd Tabnine to your IDE (free)

How to use
RelMdUtil
in
org.apache.calcite.rel.metadata

Best Java code snippets using org.apache.calcite.rel.metadata.RelMdUtil (Showing top 20 results out of 315)

origin: apache/hive

double residualSelectivity = RelMdUtil.guessSelectivity(constraintBasedResult.right);
double rowCount;
if (constraintBasedResult.left.isPKSideSimple) {
origin: apache/hive

if (!RelMdUtil.areColumnsDefinitelyUniqueWhenNullsFiltered(mq, left,
    correlatedInputRefJoinKeys)) {
if (!RelMdUtil.areColumnsDefinitelyUnique(mq, left, allCols)) {
origin: apache/hive

@Override
public Double getDistinctRowCount(Join rel, RelMetadataQuery mq, ImmutableBitSet groupKey,
  RexNode predicate) {
 if (rel instanceof HiveJoin) {
  HiveJoin hjRel = (HiveJoin) rel;
  //TODO: Improve this
  if (rel instanceof SemiJoin) {
   return mq.getDistinctRowCount(hjRel.getLeft(), groupKey,
     rel.getCluster().getRexBuilder().makeLiteral(true));
  } else {
   return RelMdUtil.getJoinDistinctRowCount(mq, rel, rel.getJoinType(),
     groupKey, predicate, true);
  }
 }
 return mq.getDistinctRowCount(rel, groupKey, predicate);
}
origin: Qihoo360/Quicksql

ImmutableBitSet.Builder projCols = ImmutableBitSet.builder();
List<RexNode> projExprs = rel.getProjects();
RelMdUtil.splitCols(projExprs, groupKey, baseCols, projCols);
 RexNode preds =
   RexUtil.composeConjunction(rexBuilder, notPushable, true);
 distinctRowCount *= RelMdUtil.guessSelectivity(preds);
   RelMdUtil.cardOfProjExpr(mq, rel, projExprs.get(bit));
 if (subRowCount == null) {
  return null;
return RelMdUtil.numDistinctVals(distinctRowCount, mq.getRowCount(rel));
origin: org.apache.calcite/calcite-core

@Deprecated // to be removed before 2.0
public static double estimateFilteredRows(RelNode child, RexNode condition) {
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 return RelMdUtil.estimateFilteredRows(child, condition, mq);
}
origin: apache/hive

if (!RelMdUtil.areColumnsDefinitelyUniqueWhenNullsFiltered(mq, right,
    rightJoinKeys)) {
origin: Qihoo360/Quicksql

 /** Catch-all implementation for
  * {@link BuiltInMetadata.PopulationSize#getPopulationSize(ImmutableBitSet)},
  * invoked using reflection.
  *
  * @see org.apache.calcite.rel.metadata.RelMetadataQuery#getPopulationSize(RelNode, ImmutableBitSet)
  */
 public Double getPopulationSize(RelNode rel, RelMetadataQuery mq,
   ImmutableBitSet groupKey) {
  // if the keys are unique, return the row count; otherwise, we have
  // no further information on which to return any legitimate value

  // REVIEW zfong 4/11/06 - Broadbase code returns the product of each
  // unique key, which would result in the population being larger
  // than the total rows in the relnode
  boolean uniq = RelMdUtil.areColumnsDefinitelyUnique(mq, rel, groupKey);
  if (uniq) {
   return mq.getRowCount(rel);
  }

  return null;
 }
}
origin: Qihoo360/Quicksql

public Double getDistinctRowCount(Values rel, RelMetadataQuery mq,
  ImmutableBitSet groupKey, RexNode predicate) {
 if (predicate == null || predicate.isAlwaysTrue()) {
  if (groupKey.isEmpty()) {
   return 1D;
  }
 }
 double selectivity = RelMdUtil.guessSelectivity(predicate);
 // assume half the rows are duplicates
 double nRows = rel.estimateRowCount(mq) / 2;
 return RelMdUtil.numDistinctVals(nRows, nRows * selectivity);
}
origin: Qihoo360/Quicksql

RelMdUtil.setAggChildKeys(groupKey, rel, childKey);
 RexNode preds =
   RexUtil.composeConjunction(rexBuilder, notPushable, true);
 return distinctRowCount * RelMdUtil.guessSelectivity(preds);
origin: apache/hive

/**
 *
 * @param j
 * @param additionalPredicate
 * @return if predicate is the join condition return (true, joinCond)
 * else return (false, minusPred)
 */
private Pair<Boolean,RexNode> getCombinedPredicateForJoin(Join j, RexNode additionalPredicate) {
 RexNode minusPred = RelMdUtil.minusPreds(j.getCluster().getRexBuilder(), additionalPredicate,
   j.getCondition());
 if (minusPred != null) {
  List<RexNode> minusList = new ArrayList<RexNode>();
  minusList.add(j.getCondition());
  minusList.add(minusPred);
  return new Pair<Boolean,RexNode>(false, minusPred);
 }
 return new Pair<Boolean,RexNode>(true,j.getCondition());
}
origin: org.apache.calcite/calcite-core

  RelMdUtil.computeSemiJoinSelectivity(mq, factRel, dimRel, semiJoin);
if (selectivity > .5) {
 return 0;
  RelMdUtil.areColumnsDefinitelyUniqueWhenNullsFiltered(mq,
    dimRel, dimCols);
if (uniq) {
origin: Qihoo360/Quicksql

private double getIntervalCostMultiplier() {
  int days = 0;
  for (Interval interval : intervals) {
    days += interval.toDuration().getStandardDays();
  }
  // Cost increases with the wider interval being queries.
  // A plan querying 10 or more years of data will have 10x the cost of a
  // plan returning 1 day data.
  // A plan where least interval is queries will be preferred.
  return RelMdUtil.linear(days, 1, DAYS_IN_TEN_YEARS, 0.1d, 1d);
}
origin: org.apache.calcite/calcite-core

@Override public double estimateRowCount(RelMetadataQuery mq) {
 return Util.first(RelMdUtil.getJoinRowCount(mq, this, condition), 1D);
}
origin: Qihoo360/Quicksql

public static boolean areColumnsDefinitelyUnique(RelMetadataQuery mq,
  RelNode rel, List<RexInputRef> columnRefs) {
 Boolean b = areColumnsUnique(mq, rel, columnRefs);
 return b != null && b;
}
origin: org.apache.calcite/calcite-core

ImmutableBitSet.Builder projCols = ImmutableBitSet.builder();
List<RexNode> projExprs = rel.getProjects();
RelMdUtil.splitCols(projExprs, groupKey, baseCols, projCols);
 RexNode preds =
   RexUtil.composeConjunction(rexBuilder, notPushable, true);
 distinctRowCount *= RelMdUtil.guessSelectivity(preds);
   RelMdUtil.cardOfProjExpr(mq, rel, projExprs.get(bit));
 if (subRowCount == null) {
  return null;
return RelMdUtil.numDistinctVals(distinctRowCount, mq.getRowCount(rel));
origin: Qihoo360/Quicksql

@Deprecated // to be removed before 2.0
public static double estimateFilteredRows(RelNode child, RexProgram program) {
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 return RelMdUtil.estimateFilteredRows(child, program, mq);
}
origin: apache/drill

if (!RelMdUtil.areColumnsDefinitelyUniqueWhenNullsFiltered(mq, right,
    rightJoinKeys)) {
origin: org.apache.calcite/calcite-core

 /** Catch-all implementation for
  * {@link BuiltInMetadata.PopulationSize#getPopulationSize(ImmutableBitSet)},
  * invoked using reflection.
  *
  * @see org.apache.calcite.rel.metadata.RelMetadataQuery#getPopulationSize(RelNode, ImmutableBitSet)
  */
 public Double getPopulationSize(RelNode rel, RelMetadataQuery mq,
   ImmutableBitSet groupKey) {
  // if the keys are unique, return the row count; otherwise, we have
  // no further information on which to return any legitimate value

  // REVIEW zfong 4/11/06 - Broadbase code returns the product of each
  // unique key, which would result in the population being larger
  // than the total rows in the relnode
  boolean uniq = RelMdUtil.areColumnsDefinitelyUnique(mq, rel, groupKey);
  if (uniq) {
   return mq.getRowCount(rel);
  }

  return null;
 }
}
origin: org.apache.calcite/calcite-core

public Double getDistinctRowCount(Values rel, RelMetadataQuery mq,
  ImmutableBitSet groupKey, RexNode predicate) {
 if (predicate == null || predicate.isAlwaysTrue()) {
  if (groupKey.isEmpty()) {
   return 1D;
  }
 }
 double selectivity = RelMdUtil.guessSelectivity(predicate);
 // assume half the rows are duplicates
 double nRows = rel.estimateRowCount(mq) / 2;
 return RelMdUtil.numDistinctVals(nRows, nRows * selectivity);
}
origin: org.apache.calcite/calcite-core

RelMdUtil.setAggChildKeys(groupKey, rel, childKey);
 RexNode preds =
   RexUtil.composeConjunction(rexBuilder, notPushable, true);
 return distinctRowCount * RelMdUtil.guessSelectivity(preds);
org.apache.calcite.rel.metadataRelMdUtil

Javadoc

RelMdUtil provides utility methods used by the metadata provider methods.

Most used methods

  • guessSelectivity
    Returns default estimates for selectivities, in the absence of stats.
  • areColumnsDefinitelyUnique
    Returns true if the columns represented in a bit mask are definitely known to form a unique column s
  • areColumnsDefinitelyUniqueWhenNullsFiltered
    Returns true if the columns represented in a bit mask are definitely known to form a unique column s
  • getJoinDistinctRowCount
    Computes the number of distinct rows for a set of keys returned from a join. Also known as NDV (numb
  • minusPreds
    Takes the difference between two predicates, removing from the first any predicates also in the seco
  • estimateFilteredRows
  • linear
    Returns a point on a line.The result is always a value between minY and maxY, even if x is not betwe
  • getJoinRowCount
    Returns an estimate of the number of rows returned by a Join.
  • areColumnsUnique
  • areColumnsUniqueWhenNullsFiltered
  • capInfinity
    Caps a double value at Double.MAX_VALUE if it's currently infinity
  • cardOfProjExpr
    Computes the cardinality of a particular expression from the projection list.
  • capInfinity,
  • cardOfProjExpr,
  • checkInputForCollationAndLimit,
  • computeSemiJoinSelectivity,
  • getJoinPopulationSize,
  • getMinusRowCount,
  • getSelectivityValue,
  • getSemiJoinRowCount,
  • getUnionAllRowCount,
  • makeSemiJoinSelectivityRexNode

Popular in Java

  • Creating JSON documents from java classes using gson
  • getExternalFilesDir (Context)
  • getSupportFragmentManager (FragmentActivity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now