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

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

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

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-druid

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

/** Unit test for {@link RelMdUtil#linear(int, int, int, double, double)}. */
@Test public void testLinear() {
 assertThat(RelMdUtil.linear(0, 0, 10, 100, 200), is(100d));
 assertThat(RelMdUtil.linear(5, 0, 10, 100, 200), is(150d));
 assertThat(RelMdUtil.linear(6, 0, 10, 100, 200), is(160d));
 assertThat(RelMdUtil.linear(10, 0, 10, 100, 200), is(200d));
 assertThat(RelMdUtil.linear(-2, 0, 10, 100, 200), is(100d));
 assertThat(RelMdUtil.linear(12, 0, 10, 100, 200), is(200d));
}
origin: Qihoo360/Quicksql

/** Unit test for {@link RelMdUtil#linear(int, int, int, double, double)}. */
@Test public void testLinear() {
 assertThat(RelMdUtil.linear(0, 0, 10, 100, 200), is(100d));
 assertThat(RelMdUtil.linear(5, 0, 10, 100, 200), is(150d));
 assertThat(RelMdUtil.linear(6, 0, 10, 100, 200), is(160d));
 assertThat(RelMdUtil.linear(10, 0, 10, 100, 200), is(200d));
 assertThat(RelMdUtil.linear(-2, 0, 10, 100, 200), is(100d));
 assertThat(RelMdUtil.linear(12, 0, 10, 100, 200), is(200d));
}
origin: org.apache.calcite/calcite-druid

@Override public RelOptCost computeSelfCost(RelOptPlanner planner,
  RelMetadataQuery mq) {
 return Util.last(rels)
   .computeSelfCost(planner, mq)
   // Cost increases with the number of fields queried.
   // A plan returning 100 or more columns will have 2x the cost of a
   // plan returning 2 columns.
   // A plan where all extra columns are pruned will be preferred.
   .multiplyBy(
     RelMdUtil.linear(querySpec.fieldNames.size(), 2, 100, 1d, 2d))
   .multiplyBy(getQueryTypeCostMultiplier())
   // A Scan leaf filter is better than having filter spec if possible.
   .multiplyBy(rels.size() > 1 && rels.get(1) instanceof Filter ? 0.5 : 1.0)
   // a plan with sort pushed to druid is better than doing sort outside of druid
   .multiplyBy(Util.last(rels) instanceof Sort ? 0.1 : 1.0)
   .multiplyBy(getIntervalCostMultiplier());
}
origin: Qihoo360/Quicksql

@Override public RelOptCost computeSelfCost(RelOptPlanner planner,
  RelMetadataQuery mq) {
  return Util.last(rels)
    .computeSelfCost(planner, mq)
    // Cost increases with the number of fields queried.
    // A plan returning 100 or more columns will have 2x the cost of a
    // plan returning 2 columns.
    // A plan where all extra columns are pruned will be preferred.
    .multiplyBy(
      RelMdUtil.linear(querySpec.fieldNames.size(), 2, 100, 1d, 2d))
    .multiplyBy(getQueryTypeCostMultiplier())
    // a plan with sort pushed to druid is better than doing sort outside of druid
    .multiplyBy(Util.last(rels) instanceof Sort ? 0.1 : 1.0)
    .multiplyBy(getIntervalCostMultiplier());
}
org.apache.calcite.rel.metadataRelMdUtillinear

Javadoc

Returns a point on a line.

The result is always a value between minY and maxY, even if x is not between minX and maxX.

Examples:

  • linear(0, 0, 10, 100, 200} returns 100 because 0 is minX
  • linear(5, 0, 10, 100, 200} returns 150 because 5 is mid-way between minX and maxX
  • linear(5, 0, 10, 100, 200} returns 160
  • linear(10, 0, 10, 100, 200} returns 200 because 10 is maxX
  • linear(-2, 0, 10, 100, 200} returns 100 because -2 is less than minX and is therefore treated as minX
  • linear(12, 0, 10, 100, 200} returns 100 because 12 is greater than maxX and is therefore treated as maxX

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
  • 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.
  • checkInputForCollationAndLimit
    Returns whether a relational expression is already sorted and has fewer rows than the sum of offset
  • cardOfProjExpr,
  • checkInputForCollationAndLimit,
  • computeSemiJoinSelectivity,
  • getJoinPopulationSize,
  • getMinusRowCount,
  • getSelectivityValue,
  • getSemiJoinRowCount,
  • getUnionAllRowCount,
  • makeSemiJoinSelectivityRexNode

Popular in Java

  • Start an intent from android
  • notifyDataSetChanged (ArrayAdapter)
  • getResourceAsStream (ClassLoader)
  • getContentResolver (Context)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Path (java.nio.file)
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • JFrame (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Github Copilot alternatives
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