blob: c62752097deab169242080e44be67e3920d01906 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="zh">
<head>
<!-- Generated by javadoc -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>org.apache.calcite.rel.hint (Apache Calcite calcite API)</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="org.apache.calcite.rel.hint (Apache Calcite calcite API)";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>您的浏览器已禁用 JavaScript。</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="跳过导航链接">跳过导航链接</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="导航">
<li><a href="../../../../../overview-summary.html">概览</a></li>
<li class="navBarCell1Rev">程序包</li>
<li></li>
<li><a href="package-tree.html"></a></li>
<li><a href="../../../../../deprecated-list.html">已过时</a></li>
<li><a href="../../../../../index-all.html">索引</a></li>
<li><a href="../../../../../help-doc.html">帮助</a></li>
</ul>
<div class="aboutLanguage"><b>Apache Calcite</b></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/calcite/rel/externalize/package-summary.html">上一个程序包</a></li>
<li><a href="../../../../../org/apache/calcite/rel/logical/package-summary.html">下一个程序包</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/calcite/rel/hint/package-summary.html" target="_top">框架</a></li>
<li><a href="package-summary.html" target="_top">无框架</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">所有类</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 title="程序包" class="title">程序包&nbsp;org.apache.calcite.rel.hint</h1>
<div class="docSummary">
<div class="block">Defines hints interfaces and utilities for relational expressions.</div>
</div>
<p>请参阅:&nbsp;<a href="#package.description">说明</a></p>
</div>
<div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="接口概要表, 列表接口和解释">
<caption><span>接口概要</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">接口</th>
<th class="colLast" scope="col">说明</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/Hintable.html" title="org.apache.calcite.rel.hint中的接口">Hintable</a></td>
<td class="colLast">
<div class="block"><a href="../../../../../org/apache/calcite/rel/hint/Hintable.html" title="org.apache.calcite.rel.hint中的接口"><code>Hintable</code></a> is a kind of <a href="../../../../../org/apache/calcite/rel/RelNode.html" title="org.apache.calcite.rel中的接口"><code>RelNode</code></a> that can attach <a href="../../../../../org/apache/calcite/rel/hint/RelHint.html" title="org.apache.calcite.rel.hint中的类"><code>RelHint</code></a>s.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/HintOptionChecker.html" title="org.apache.calcite.rel.hint中的接口">HintOptionChecker</a></td>
<td class="colLast">
<div class="block">A <code>HintOptionChecker</code> checks if a <a href="../../../../../org/apache/calcite/rel/hint/RelHint.html" title="org.apache.calcite.rel.hint中的类"><code>RelHint</code></a>'s options are valid.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/HintPredicate.html" title="org.apache.calcite.rel.hint中的接口">HintPredicate</a></td>
<td class="colLast">
<div class="block">A <code>HintPredicate</code> indicates whether a <a href="../../../../../org/apache/calcite/rel/RelNode.html" title="org.apache.calcite.rel中的接口"><code>RelNode</code></a>
can apply the specified hint.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="类概要表, 列表类和解释">
<caption><span>类概要</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col"></th>
<th class="colLast" scope="col">说明</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/CompositeHintPredicate.html" title="org.apache.calcite.rel.hint中的类">CompositeHintPredicate</a></td>
<td class="colLast">
<div class="block">A <a href="../../../../../org/apache/calcite/rel/hint/HintPredicate.html" title="org.apache.calcite.rel.hint中的接口"><code>HintPredicate</code></a> to combine multiple hint predicates into one.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/HintPredicates.html" title="org.apache.calcite.rel.hint中的类">HintPredicates</a></td>
<td class="colLast">
<div class="block">A collection of hint predicates.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/HintStrategy.html" title="org.apache.calcite.rel.hint中的类">HintStrategy</a></td>
<td class="colLast">
<div class="block">Represents a hint strategy entry of <a href="../../../../../org/apache/calcite/rel/hint/HintStrategyTable.html" title="org.apache.calcite.rel.hint中的类"><code>HintStrategyTable</code></a>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/HintStrategy.Builder.html" title="org.apache.calcite.rel.hint中的类">HintStrategy.Builder</a></td>
<td class="colLast">
<div class="block">Builder for <a href="../../../../../org/apache/calcite/rel/hint/HintStrategy.html" title="org.apache.calcite.rel.hint中的类"><code>HintStrategy</code></a>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/HintStrategyTable.html" title="org.apache.calcite.rel.hint中的类">HintStrategyTable</a></td>
<td class="colLast">
<div class="block">A collections of <a href="../../../../../org/apache/calcite/rel/hint/HintStrategy.html" title="org.apache.calcite.rel.hint中的类"><code>HintStrategy</code></a>s.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/HintStrategyTable.Builder.html" title="org.apache.calcite.rel.hint中的类">HintStrategyTable.Builder</a></td>
<td class="colLast">
<div class="block">Builder for <code>HintStrategyTable</code>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/HintStrategyTable.HintErrorLogger.html" title="org.apache.calcite.rel.hint中的类">HintStrategyTable.HintErrorLogger</a></td>
<td class="colLast">
<div class="block">Implementation of <a href="../../../../../org/apache/calcite/util/Litmus.html" title="org.apache.calcite.util中的接口"><code>Litmus</code></a> that returns
a status code, it logs warnings for fail check and does not throw.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/NodeTypeHintPredicate.html" title="org.apache.calcite.rel.hint中的类">NodeTypeHintPredicate</a></td>
<td class="colLast">
<div class="block">A hint predicate that specifies which kind of relational
expression the hint can be applied to.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/RelHint.html" title="org.apache.calcite.rel.hint中的类">RelHint</a></td>
<td class="colLast">
<div class="block">Represents hint within a relation expression.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/RelHint.Builder.html" title="org.apache.calcite.rel.hint中的类">RelHint.Builder</a></td>
<td class="colLast">
<div class="block">Builder for <a href="../../../../../org/apache/calcite/rel/hint/RelHint.html" title="org.apache.calcite.rel.hint中的类"><code>RelHint</code></a>.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="枚举概要表, 列表枚举和解释">
<caption><span>枚举概要</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">枚举</th>
<th class="colLast" scope="col">说明</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../../org/apache/calcite/rel/hint/CompositeHintPredicate.Composition.html" title="org.apache.calcite.rel.hint中的枚举">CompositeHintPredicate.Composition</a></td>
<td class="colLast">
<div class="block">How hint predicates are composed.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
<a name="package.description">
<!-- -->
</a>
<h2 title="程序包org.apache.calcite.rel.hint的说明">程序包org.apache.calcite.rel.hint的说明</h2>
<div class="block">Defines hints interfaces and utilities for relational expressions.
<h2>The Syntax</h2>
We support the Oracle style hint grammar for both query hint(right after the "SELECT" keyword)
and the table hint(right after the table name reference). i.e.
<blockquote><pre>
select &#47;&#42;&#43; NO_HASH_JOIN, RESOURCE(mem='128mb', parallelism='24') &#42;&#47;
from
emp &#47;&#42;&#43; INDEX(idx1, idx2) &#42;&#47;
join
dept &#47;&#42;&#43; PROPERTIES(k1='v1', k2='v2') &#42;&#47;
on emp.deptno=dept.deptno
</pre></blockquote>
<h2>Customize Hint Match Rules</h2>
Calcite implements a framework to define and propagate the hints. In order to make the hints
propagate efficiently, every hint referenced in the sql statement needs to
register the match rules for hints propagation.
<p>A match rule is defined though <a href="../../../../../org/apache/calcite/rel/hint/HintPredicate.html" title="org.apache.calcite.rel.hint中的接口"><code>HintPredicate</code></a>.
<a href="../../../../../org/apache/calcite/rel/hint/NodeTypeHintPredicate.html" title="org.apache.calcite.rel.hint中的类"><code>NodeTypeHintPredicate</code></a> matches a relational expression
by its node type; you can also define a custom instance with more complicated rules,
i.e. JOIN with specified relations from the hint options.
<p>Here is the code snippet to illustrate how to config the strategies:
<pre>
// Initialize a HintStrategyTable.
HintStrategyTable strategies = HintStrategyTable.builder()
.addHintStrategy("time_zone", HintPredicates.SET_VAR)
.addHintStrategy("index", HintPredicates.TABLE_SCAN)
.addHintStrategy("resource", HintPredicates.PROJECT)
.addHintStrategy("use_hash_join",
HintPredicates.and(HintPredicates.JOIN,
HintPredicates.explicit((hint, rel) -&gt; {
...
})))
.hintStrategy("use_merge_join",
HintStrategyTable.strategyBuilder(
HintPredicates.and(HintPredicates.JOIN, joinWithFixedTableName()))
.excludedRules(EnumerableRules.ENUMERABLE_JOIN_RULE).build())
.build();
// Config the strategies in the config.
SqlToRelConverter.Config config = SqlToRelConverter.configBuilder()
.withHintStrategyTable(strategies)
.build();
// Use the config to initialize the SqlToRelConverter.
...
</pre>
<h2>Hints Propagation</h2>
There are two cases that need to consider the hints propagation:
<ul>
<li>Right after a <code>SqlNode</code> tree is converted to <code>RelNode</code> tree, we would
propagate the hints from the attaching node to its input(children) nodes. The hints are
propagated recursively with a <code>RelShuttle</code>, see
RelOptUtil#RelHintPropagateShuttle for how it works.</li>
<li>During rule planning, in the transforming phrase of a <code>RelOptRule</code>,
you <strong>should not</strong> copy the hints by hand. To ensure correctness,
the hints copy work within planner rule is taken care of by Calcite;
We make some effort to make the thing easier: right before the new relational expression
was registered into the planner, the hints of the old relational expression was
copied into the new expression sub-tree(by "new" we mean, the node was created
just in the planner rule) if the nodes implement
<a href="../../../../../org/apache/calcite/rel/hint/Hintable.html" title="org.apache.calcite.rel.hint中的接口"><code>Hintable</code></a>.</li>
</ul>
<h2>Design Doc</h2>
<a href="https://docs.google.com/document/d/1mykz-w2t1Yw7CH6NjUWpWqCAf_6YNKxSc59gXafrNCs/edit?usp=sharing">Calcite SQL and Planner Hints Design</a>.</div>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="跳过导航链接">跳过导航链接</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="导航">
<li><a href="../../../../../overview-summary.html">概览</a></li>
<li class="navBarCell1Rev">程序包</li>
<li></li>
<li><a href="package-tree.html"></a></li>
<li><a href="../../../../../deprecated-list.html">已过时</a></li>
<li><a href="../../../../../index-all.html">索引</a></li>
<li><a href="../../../../../help-doc.html">帮助</a></li>
</ul>
<div class="aboutLanguage"><b>Apache Calcite</b></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/calcite/rel/externalize/package-summary.html">上一个程序包</a></li>
<li><a href="../../../../../org/apache/calcite/rel/logical/package-summary.html">下一个程序包</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/calcite/rel/hint/package-summary.html" target="_top">框架</a></li>
<li><a href="package-summary.html" target="_top">无框架</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">所有类</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &copy; 2012-2020 Apache Software Foundation. All Rights Reserved.</small></p>
</body>
</html>