本文整理汇总了Java中org.voltdb.plannodes.IndexScanPlanNode类的典型用法代码示例。如果您正苦于以下问题:Java IndexScanPlanNode类的具体用法?Java IndexScanPlanNode怎么用?Java IndexScanPlanNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IndexScanPlanNode类属于org.voltdb.plannodes包,在下文中一共展示了IndexScanPlanNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: injectIndexedJoinWithMaterializedScan
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
private static AbstractPlanNode injectIndexedJoinWithMaterializedScan(AbstractExpression listElements,
IndexScanPlanNode scanNode)
{
MaterializedScanPlanNode matScan = new MaterializedScanPlanNode();
assert(listElements instanceof VectorValueExpression || listElements instanceof ParameterValueExpression);
matScan.setRowData(listElements);
matScan.setSortDirection(scanNode.getSortDirection());
NestLoopIndexPlanNode nlijNode = new NestLoopIndexPlanNode();
nlijNode.setJoinType(JoinType.INNER);
nlijNode.addInlinePlanNode(scanNode);
nlijNode.addAndLinkChild(matScan);
// resolve the sort direction
nlijNode.resolveSortDirection();
return nlijNode;
}
示例2: countSeqScans
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
public int countSeqScans() {
int total = rootPlanGraph.findAllNodesOfType(PlanNodeType.SEQSCAN).size();
if (subPlanGraph != null) {
total += subPlanGraph.findAllNodesOfType(PlanNodeType.SEQSCAN).size();
}
// add full index scans
ArrayList<AbstractPlanNode> indexScanNodes = rootPlanGraph.findAllNodesOfType(PlanNodeType.INDEXSCAN);
if (subPlanGraph != null) {
indexScanNodes.addAll(subPlanGraph.findAllNodesOfType(PlanNodeType.INDEXSCAN));
}
for (AbstractPlanNode node : indexScanNodes) {
if (((IndexScanPlanNode)node).getSearchKeyExpressions().isEmpty()) {
total++;
}
}
return total;
}
示例3: testEng3850ComplexIndexablePlan
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
public void testEng3850ComplexIndexablePlan()
{
AbstractPlanNode pn = compile("select id from a, t where a.id < (t.a + ?);");
pn = pn.getChild(0);
pn = pn.getChild(0);
// System.out.println("DEBUG: " + pn.toExplainPlanString());
assertTrue(pn instanceof NestLoopIndexPlanNode);
IndexScanPlanNode indexScan = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
assertEquals(IndexLookupType.LT, indexScan.getLookupType());
assertTrue(indexScan.toJSONString().contains("\"TARGET_INDEX_NAME\":\"" +
HSQLInterface.AUTO_GEN_CONSTRAINT_WRAPPER_PREFIX + "ID"));
pn = pn.getChild(0);
assertTrue(pn instanceof SeqScanPlanNode);
// System.out.println("DEBUG: " + pn.toJSONString());
assertTrue(pn.toJSONString().contains("\"TARGET_TABLE_NAME\":\"T\""));
}
示例4: testEng4792PlanWithCompoundEQLTEOrderedByPK
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
public void testEng4792PlanWithCompoundEQLTEOrderedByPK() throws JSONException
{
AbstractPlanNode pn = compile("select id from a where deleted=? and updated_date <= ? order by id limit ?;");
// System.out.println("DEBUG: " + pn.toExplainPlanString());
pn = pn.getChild(0);
// ENG-5066: now Limit is pushed under Projection
assertTrue(pn instanceof ProjectionPlanNode);
pn = pn.getChild(0);
// inline limit with order by
assertTrue(pn instanceof OrderByPlanNode);
assertNotNull(pn.getInlinePlanNode(PlanNodeType.LIMIT));
pn = pn.getChild(0);
assertTrue(pn instanceof IndexScanPlanNode);
assertTrue(pn.toJSONString().contains("\"TARGET_INDEX_NAME\":\"DELETED_SINCE_IDX\""));
}
示例5: testMicroOptimizationJoinOrder
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
public void testMicroOptimizationJoinOrder() {
// Microoptimization can be used for determinism only when working with replicated tables or
// single-partition queries.
List<AbstractPlanNode> pns;
AbstractPlanNode n;
pns = compileWithJoinOrderToFragments("select * from J1, P2 where A=B and A=1", "J1, P2");
n = pns.get(0).getChild(0).getChild(0);
assertTrue(((IndexScanPlanNode)n.getChild(0)).getTargetTableName().equals("J1"));
assertTrue(((SeqScanPlanNode)n.getChild(1)).getTargetTableName().equals("P2"));
pns = compileWithJoinOrderToFragments("select * from I1, T2 where A=B", "I1, T2");
/*/ to debug */ System.out.println(pns.get(0).toExplainPlanString());
n = pns.get(0).getChild(0).getChild(0);
assertTrue(((IndexScanPlanNode)n.getChild(0)).getTargetTableName().equals("I1"));
assertTrue(((SeqScanPlanNode)n.getChild(1)).getTargetTableName().equals("T2"));
}
示例6: getScanExpressionTypes
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
/**
* Return all the ExpressionTypes used for scan predicates in the given PlanNode
* @param node
* @return
*/
public static Collection<ExpressionType> getScanExpressionTypes(AbstractPlanNode root) {
final Set<ExpressionType> found = new HashSet<ExpressionType>();
new PlanNodeTreeWalker(true) {
@Override
protected void callback(AbstractPlanNode node) {
Set<AbstractExpression> exps = new HashSet<AbstractExpression>();
switch (node.getPlanNodeType()) {
// SCANS
case INDEXSCAN: {
IndexScanPlanNode idx_node = (IndexScanPlanNode) node;
exps.add(idx_node.getEndExpression());
exps.addAll(idx_node.getSearchKeyExpressions());
}
case SEQSCAN: {
AbstractScanPlanNode scan_node = (AbstractScanPlanNode) node;
exps.add(scan_node.getPredicate());
break;
}
// JOINS
case NESTLOOP:
case NESTLOOPINDEX: {
AbstractJoinPlanNode cast_node = (AbstractJoinPlanNode) node;
exps.add(cast_node.getPredicate());
break;
}
default:
// Do nothing...
} // SWITCH
for (AbstractExpression exp : exps) {
if (exp == null)
continue;
found.addAll(ExpressionUtil.getExpressionTypes(exp));
} // FOR
return;
}
}.traverse(root);
return (found);
}
示例7: testDebug
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
/**
* testDebug
*/
public void testDebug() throws Exception {
// Just make sure this doesn't throw an Exception
AbstractPlanNode root = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);
assertNotNull(root);
//System.err.println(PlanNodeUtil.debug(root));
IndexScanPlanNode scan_node = CollectionUtil.first(PlanNodeUtil.getPlanNodes(root, IndexScanPlanNode.class));
assertNotNull(scan_node);
AbstractExpression exp = scan_node.getEndExpression();
assertNotNull(exp);
String debug = ExpressionUtil.debug(exp);
assertNotNull(debug);
assertFalse(debug.isEmpty());
}
示例8: isOrderByNodeRequired
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
/**
* Determine if an OrderByPlanNode is needed. This may return false if the
* statement has no ORDER BY clause, or if the subtree is already producing
* rows in the correct order.
* @param parsedStmt The statement whose plan may need an OrderByPlanNode
* @param root The subtree which may need its output tuples ordered
* @return true if the plan needs an OrderByPlanNode, false otherwise
*/
private static boolean isOrderByNodeRequired(AbstractParsedStmt parsedStmt, AbstractPlanNode root) {
// Only sort when the statement has an ORDER BY.
if ( ! parsedStmt.hasOrderByColumns()) {
return false;
}
SortDirectionType sortDirection = SortDirectionType.INVALID;
// Skip the explicit ORDER BY plan step if an IndexScan is already providing the equivalent ordering.
// Note that even tree index scans that produce values in their own "key order" only report
// their sort direction != SortDirectionType.INVALID
// when they enforce an ordering equivalent to the one requested in the ORDER BY clause.
// Even an intervening non-hash aggregate will not interfere in this optimization.
AbstractPlanNode nonAggPlan = root;
// EE keeps the insertion ORDER so that ORDER BY could apply before DISTINCT.
// However, this probably is not optimal if there are low cardinality results.
// Again, we have to replace the TVEs for ORDER BY clause for these cases in planning.
if (nonAggPlan.getPlanNodeType() == PlanNodeType.AGGREGATE) {
nonAggPlan = nonAggPlan.getChild(0);
}
if (nonAggPlan instanceof IndexScanPlanNode) {
sortDirection = ((IndexScanPlanNode)nonAggPlan).getSortDirection();
}
// Optimization for NestLoopIndex on IN list, possibly other cases of ordered join results.
// Skip the explicit ORDER BY plan step if NestLoopIndex is providing the equivalent ordering
else if (nonAggPlan instanceof AbstractJoinPlanNode) {
sortDirection = ((AbstractJoinPlanNode)nonAggPlan).getSortDirection();
}
if (sortDirection != SortDirectionType.INVALID) {
return false;
}
return true;
}
示例9: needHashAggregator
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
public boolean needHashAggregator(AbstractPlanNode root) {
// A hash is required to build up per-group aggregates in parallel vs.
// when there is only one aggregation over the entire table OR when the
// per-group aggregates are being built serially from the ordered output
// of an index scan.
// Currently, an index scan only claims to have a sort direction when its output
// matches the order demanded by the ORDER BY clause.
if (! m_parsedSelect.isGrouped()) {
return false;
}
if (isChangedToSerialAggregate() && ! m_multiPartition) {
return false;
}
boolean predeterminedOrdering = false;
if (root instanceof IndexScanPlanNode) {
if (((IndexScanPlanNode)root).getSortDirection() != SortDirectionType.INVALID) {
predeterminedOrdering = true;
}
}
else if (root instanceof AbstractJoinPlanNode) {
if (((AbstractJoinPlanNode)root).getSortDirection() != SortDirectionType.INVALID) {
predeterminedOrdering = true;
}
}
if (predeterminedOrdering) {
// The ordering predetermined by indexed access is known to cover (at least) the
// ORDER BY columns.
// Yet, any additional non-ORDER-BY columns in the GROUP BY clause will need
// partial aggregate.
if (m_parsedSelect.groupByIsAnOrderByPermutation()) {
return false;
}
}
return true;
}
示例10: getIndexAccessPlanForTable
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
/**
* Get a index scan access plan for a table. For multi-site plans/tables,
* scans at all partitions and sends to one partition.
*
* @param tableAliasIndex The table to get data from.
* @param path The access path to access the data in the table (index/scan/etc).
* @return An index scan plan node OR,
in one edge case, an NLIJ of a MaterializedScan and an index scan plan node.
*/
protected static AbstractPlanNode getIndexAccessPlanForTable(StmtTableScan tableScan, AccessPath path)
{
// now assume this will be an index scan and get the relevant index
Index index = path.index;
IndexScanPlanNode scanNode = new IndexScanPlanNode(tableScan, index);
AbstractPlanNode resultNode = scanNode;
// set sortDirection here becase it might be used for IN list
scanNode.setSortDirection(path.sortDirection);
// Build the list of search-keys for the index in question
// They are the rhs expressions of the normalized indexExpr comparisons.
for (AbstractExpression expr : path.indexExprs) {
AbstractExpression expr2 = expr.getRight();
assert(expr2 != null);
if (expr.getExpressionType() == ExpressionType.COMPARE_IN) {
// Replace this method's result with an injected NLIJ.
resultNode = injectIndexedJoinWithMaterializedScan(expr2, scanNode);
// Extract a TVE from the LHS MaterializedScan for use by the IndexScan in its new role.
MaterializedScanPlanNode matscan = (MaterializedScanPlanNode)resultNode.getChild(0);
AbstractExpression elemExpr = matscan.getOutputExpression();
assert(elemExpr != null);
// Replace the IN LIST condition in the end expression referencing all the list elements
// with a more efficient equality filter referencing the TVE for each element in turn.
replaceInListFilterWithEqualityFilter(path.endExprs, expr2, elemExpr);
// Set up the similar VectorValue --> TVE replacement of the search key expression.
expr2 = elemExpr;
}
scanNode.addSearchKeyExpression(expr2);
}
// create the IndexScanNode with all its metadata
scanNode.setLookupType(path.lookupType);
scanNode.setBindings(path.bindings);
scanNode.setEndExpression(ExpressionUtil.combine(path.endExprs));
scanNode.setPredicate(ExpressionUtil.combine(path.otherExprs));
// The initial expression is needed to control a (short?) forward scan to adjust the start of a reverse
// iteration after it had to initially settle for starting at "greater than a prefix key".
scanNode.setInitialExpression(ExpressionUtil.combine(path.initialExpr));
scanNode.setSkipNullPredicate();
return resultNode;
}
示例11: testEng1023
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
public void testEng1023()
{
AbstractPlanNode pn = compile("select a from t where a = ? and b < ?;");
pn = pn.getChild(0);
if (pn != null) {
System.out.println(pn.toJSONString());
}
assertTrue(pn instanceof IndexScanPlanNode);
IndexScanPlanNode ispn = (IndexScanPlanNode)pn;
assertEquals("COVER2_TREE", ispn.getTargetIndexName());
assertEquals(IndexLookupType.LT, ispn.getLookupType());
assertEquals(2, ispn.getSearchKeyExpressions().size());
}
示例12: testCover2ColumnsWithEquality
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
public void testCover2ColumnsWithEquality()
{
AbstractPlanNode pn = compile("select a from t where a = ? and b = ?;");
pn = pn.getChild(0);
if (pn != null) {
System.out.println(pn.toJSONString());
}
assertTrue(pn instanceof IndexScanPlanNode);
IndexScanPlanNode ispn = (IndexScanPlanNode)pn;
assertEquals("COVER2_TREE", ispn.getTargetIndexName());
assertEquals(IndexLookupType.EQ, ispn.getLookupType());
assertEquals(2, ispn.getSearchKeyExpressions().size());
}
示例13: testCover3ColumnsInOrderWithLessThan
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
public void testCover3ColumnsInOrderWithLessThan()
{
AbstractPlanNode pn = compile("select a from t where a = ? and c = ? and b < ?;");
pn = pn.getChild(0);
if (pn != null) {
System.out.println(pn.toJSONString());
}
assertTrue(pn instanceof IndexScanPlanNode);
IndexScanPlanNode ispn = (IndexScanPlanNode)pn;
assertEquals("COVER3_TREE", ispn.getTargetIndexName());
assertEquals(IndexLookupType.LT, ispn.getLookupType());
assertEquals(3, ispn.getSearchKeyExpressions().size());
}
示例14: testCover3ColumnsWithLessThanAndOrderBy
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
public void testCover3ColumnsWithLessThanAndOrderBy()
{
AbstractPlanNode pn = compile("select a, b from t where a = ? and c = ? and b < ? order by b;");
pn = pn.getChild(0);
if (pn != null) {
System.out.println(pn.toJSONString());
}
assertTrue(pn instanceof IndexScanPlanNode);
IndexScanPlanNode ispn = (IndexScanPlanNode)pn;
assertEquals("COVER3_TREE", ispn.getTargetIndexName());
assertEquals(IndexLookupType.GTE, ispn.getLookupType());
assertEquals(2, ispn.getSearchKeyExpressions().size());
}
示例15: testCover3ColumnsInOrderWithLessThanAndOrderBy
import org.voltdb.plannodes.IndexScanPlanNode; //导入依赖的package包/类
public void testCover3ColumnsInOrderWithLessThanAndOrderBy()
{
AbstractPlanNode pn = compile("select a, b from t where a = ? and c = ? and b < ? order by b;");
pn = pn.getChild(0);
if (pn != null) {
System.out.println(pn.toJSONString());
}
assertTrue(pn instanceof IndexScanPlanNode);
IndexScanPlanNode ispn = (IndexScanPlanNode)pn;
assertEquals("COVER3_TREE", ispn.getTargetIndexName());
assertEquals(IndexLookupType.GTE, ispn.getLookupType());
assertEquals(2, ispn.getSearchKeyExpressions().size());
}