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

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

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

origin: Qihoo360/Quicksql

public Double visitLiteral(RexLiteral literal) {
 return numDistinctVals(1.0, mq.getRowCount(rel));
}
origin: org.apache.calcite/calcite-core

public Double visitLiteral(RexLiteral literal) {
 return numDistinctVals(1.0, mq.getRowCount(rel));
}
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: 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

public Double visitInputRef(RexInputRef var) {
 int index = var.getIndex();
 ImmutableBitSet col = ImmutableBitSet.of(index);
 Double distinctRowCount =
   mq.getDistinctRowCount(rel.getInput(), col, null);
 if (distinctRowCount == null) {
  return null;
 } else {
  return numDistinctVals(distinctRowCount, mq.getRowCount(rel));
 }
}
origin: Qihoo360/Quicksql

public Double visitInputRef(RexInputRef var) {
 int index = var.getIndex();
 ImmutableBitSet col = ImmutableBitSet.of(index);
 Double distinctRowCount =
   mq.getDistinctRowCount(rel.getInput(), col, null);
 if (distinctRowCount == null) {
  return null;
 } else {
  return numDistinctVals(distinctRowCount, mq.getRowCount(rel));
 }
}
origin: org.apache.calcite/calcite-core

return numDistinctVals(distinctRowCount, rowCount);
origin: Qihoo360/Quicksql

return numDistinctVals(distinctRowCount, rowCount);
origin: org.apache.calcite/calcite-core

/**
 * Computes the population size for a set of keys returned from a join
 *
 * @param joinRel  the join rel
 * @param groupKey keys to compute the population for
 * @return computed population size
 */
public static Double getJoinPopulationSize(RelMetadataQuery mq,
  RelNode joinRel, ImmutableBitSet groupKey) {
 ImmutableBitSet.Builder leftMask = ImmutableBitSet.builder();
 ImmutableBitSet.Builder rightMask = ImmutableBitSet.builder();
 RelNode left = joinRel.getInputs().get(0);
 RelNode right = joinRel.getInputs().get(1);
 // separate the mask into masks for the left and right
 RelMdUtil.setLeftRightBitmaps(
   groupKey, leftMask, rightMask, left.getRowType().getFieldCount());
 Double population =
   NumberUtil.multiply(
     mq.getPopulationSize(left, leftMask.build()),
     mq.getPopulationSize(right, rightMask.build()));
 return numDistinctVals(population, mq.getRowCount(joinRel));
}
origin: Qihoo360/Quicksql

/**
 * Computes the population size for a set of keys returned from a join
 *
 * @param joinRel  the join rel
 * @param groupKey keys to compute the population for
 * @return computed population size
 */
public static Double getJoinPopulationSize(RelMetadataQuery mq,
  RelNode joinRel, ImmutableBitSet groupKey) {
 ImmutableBitSet.Builder leftMask = ImmutableBitSet.builder();
 ImmutableBitSet.Builder rightMask = ImmutableBitSet.builder();
 RelNode left = joinRel.getInputs().get(0);
 RelNode right = joinRel.getInputs().get(1);
 // separate the mask into masks for the left and right
 RelMdUtil.setLeftRightBitmaps(
   groupKey, leftMask, rightMask, left.getRowType().getFieldCount());
 Double population =
   NumberUtil.multiply(
     mq.getPopulationSize(left, leftMask.build()),
     mq.getPopulationSize(right, rightMask.build()));
 return numDistinctVals(population, mq.getRowCount(joinRel));
}
origin: org.apache.calcite/calcite-core

public Double getPopulationSize(Project rel, RelMetadataQuery mq,
  ImmutableBitSet groupKey) {
 ImmutableBitSet.Builder baseCols = ImmutableBitSet.builder();
 ImmutableBitSet.Builder projCols = ImmutableBitSet.builder();
 List<RexNode> projExprs = rel.getProjects();
 RelMdUtil.splitCols(projExprs, groupKey, baseCols, projCols);
 Double population =
   mq.getPopulationSize(rel.getInput(), baseCols.build());
 if (population == null) {
  return null;
 }
 // No further computation required if the projection expressions are
 // all column references
 if (projCols.cardinality() == 0) {
  return population;
 }
 for (int bit : projCols.build()) {
  Double subRowCount =
    RelMdUtil.cardOfProjExpr(mq, rel, projExprs.get(bit));
  if (subRowCount == null) {
   return null;
  }
  population *= subRowCount;
 }
 // REVIEW zfong 6/22/06 - Broadbase did not have the call to
 // numDistinctVals.  This is needed; otherwise, population can be
 // larger than the number of rows in the RelNode.
 return RelMdUtil.numDistinctVals(population, mq.getRowCount(rel));
}
origin: Qihoo360/Quicksql

public Double getPopulationSize(Project rel, RelMetadataQuery mq,
  ImmutableBitSet groupKey) {
 ImmutableBitSet.Builder baseCols = ImmutableBitSet.builder();
 ImmutableBitSet.Builder projCols = ImmutableBitSet.builder();
 List<RexNode> projExprs = rel.getProjects();
 RelMdUtil.splitCols(projExprs, groupKey, baseCols, projCols);
 Double population =
   mq.getPopulationSize(rel.getInput(), baseCols.build());
 if (population == null) {
  return null;
 }
 // No further computation required if the projection expressions are
 // all column references
 if (projCols.cardinality() == 0) {
  return population;
 }
 for (int bit : projCols.build()) {
  Double subRowCount =
    RelMdUtil.cardOfProjExpr(mq, rel, projExprs.get(bit));
  if (subRowCount == null) {
   return null;
  }
  population *= subRowCount;
 }
 // REVIEW zfong 6/22/06 - Broadbase did not have the call to
 // numDistinctVals.  This is needed; otherwise, population can be
 // larger than the number of rows in the RelNode.
 return RelMdUtil.numDistinctVals(population, mq.getRowCount(rel));
}
origin: org.apache.calcite/calcite-core

return RelMdUtil.numDistinctVals(distRowCount, mq.getRowCount(joinRel));
origin: Qihoo360/Quicksql

return RelMdUtil.numDistinctVals(distRowCount, mq.getRowCount(joinRel));
origin: Qihoo360/Quicksql

return RelMdUtil.numDistinctVals(distinctRowCount, mq.getRowCount(rel));
origin: org.apache.calcite/calcite-core

return RelMdUtil.numDistinctVals(distinctRowCount, mq.getRowCount(rel));
org.apache.calcite.rel.metadataRelMdUtilnumDistinctVals

Javadoc

Returns the number of distinct values provided numSelected are selected where there are domainSize distinct values.

Note that in the case where domainSize == numSelected, it's not true that the return value should be domainSize. If you pick 100 random values between 1 and 100, you'll most likely end up with fewer than 100 distinct values, because you'll pick some values more than once.

Popular methods of RelMdUtil

  • 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

  • Finding current android device location
  • findViewById (Activity)
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • JButton (javax.swing)
  • JTextField (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top 12 Jupyter Notebook extensions
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