public StatementContext(PhoenixStatement statement, Scan scan) { this(statement, FromCompiler.EMPTY_TABLE_RESOLVER, scan, new SequenceManager(statement)); }
/** * Constructor that lets you override whether or not to collect request level metrics. */ public StatementContext(PhoenixStatement statement, boolean collectRequestLevelMetrics) { this(statement, FromCompiler.EMPTY_TABLE_RESOLVER, new Scan(), new SequenceManager(statement), collectRequestLevelMetrics); }
public StatementContext(PhoenixStatement statement, ColumnResolver resolver) { this (statement, resolver, new Scan(), new SequenceManager(statement)); }
public QueryCompiler(PhoenixStatement statement, SelectStatement select, ColumnResolver resolver, boolean projectTuples, boolean optimizeSubquery, Map<TableRef, QueryPlan> dataPlans) throws SQLException { this(statement, select, resolver, Collections.<PDatum>emptyList(), null, new SequenceManager(statement), projectTuples, optimizeSubquery, dataPlans); }
public QueryPlan optimize(PhoenixStatement statement, SelectStatement select, ColumnResolver resolver, List<? extends PDatum> targetColumns, ParallelIteratorFactory parallelIteratorFactory) throws SQLException { QueryCompiler compiler = new QueryCompiler(statement, select, resolver, targetColumns, parallelIteratorFactory, new SequenceManager(statement)); QueryPlan dataPlan = compiler.compile(); return optimize(dataPlan, statement, targetColumns, parallelIteratorFactory); }
public MutationPlan compile(final List<TableRef> tableRefs, final byte[] emptyCF, final List<byte[]> projectCFs, final List<PColumn> deleteList, final long timestamp) throws SQLException { PhoenixStatement statement = new PhoenixStatement(connection); final StatementContext context = new StatementContext( statement, new MultipleTableRefColumnResolver(tableRefs), scan, new SequenceManager(statement)); return new PostDDLMutationPlan(context, tableRefs, timestamp, emptyCF, deleteList, projectCFs); }
private boolean getKeyExpressionCombinations(Pair<Expression, Expression> combination, StatementContext context, SelectStatement select, TableRef table, JoinType type, final List<Expression> joinExpressions, final List<Expression> hashExpressions) throws SQLException { if ((type != JoinType.Inner && type != JoinType.Semi) || this.noChildParentJoinOptimization) return false; Scan scanCopy = ScanUtil.newScan(context.getScan()); StatementContext contextCopy = new StatementContext(statement, context.getResolver(), scanCopy, new SequenceManager(statement)); contextCopy.setCurrentTable(table); List<Expression> lhsCombination = Lists.<Expression> newArrayList(); boolean complete = WhereOptimizer.getKeyExpressionCombination(lhsCombination, contextCopy, select, joinExpressions); if (lhsCombination.isEmpty()) return false; List<Expression> rhsCombination = Lists.newArrayListWithExpectedSize(lhsCombination.size()); for (int i = 0; i < lhsCombination.size(); i++) { Expression lhs = lhsCombination.get(i); for (int j = 0; j < joinExpressions.size(); j++) { if (lhs == joinExpressions.get(j)) { rhsCombination.add(hashExpressions.get(j)); break; } } } if (lhsCombination.size() == 1) { combination.setFirst(lhsCombination.get(0)); combination.setSecond(rhsCombination.get(0)); } else { combination.setFirst(new RowValueConstructorExpression(lhsCombination, false)); combination.setSecond(new RowValueConstructorExpression(rhsCombination, false)); } return type == JoinType.Semi && complete; }
@SuppressWarnings("unchecked") @Override public QueryPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { if(!getUdfParseNodes().isEmpty()) { stmt.throwIfUnallowedUserDefinedFunctions(getUdfParseNodes()); } SelectStatement select = SubselectRewriter.flatten(this, stmt.getConnection()); ColumnResolver resolver = FromCompiler.getResolverForQuery(select, stmt.getConnection()); select = StatementNormalizer.normalize(select, resolver); SelectStatement transformedSelect = SubqueryRewriter.transform(select, resolver, stmt.getConnection()); if (transformedSelect != select) { resolver = FromCompiler.getResolverForQuery(transformedSelect, stmt.getConnection()); select = StatementNormalizer.normalize(transformedSelect, resolver); } QueryPlan plan = new QueryCompiler(stmt, select, resolver, Collections.<PDatum>emptyList(), stmt.getConnection().getIteratorFactory(), new SequenceManager(stmt), true, false, null).compile(); plan.getContext().getSequenceManager().validateSequences(seqAction); return plan; }
final ColumnResolver resolver = FromCompiler.getResolver(create, connection, create.getUdfParseNodes()); Scan scan = new Scan(); final StatementContext context = new StatementContext(statement, resolver, scan, new SequenceManager(statement)); ExpressionCompiler expressionCompiler = new ExpressionCompiler(context); List<ParseNode> splitNodes = create.getSplitNodes();
public static ClientAggregators getSingleSumAggregator(String url, Properties props) throws SQLException { try (PhoenixConnection pconn = DriverManager.getConnection(url, props).unwrap(PhoenixConnection.class)) { PhoenixStatement statement = new PhoenixStatement(pconn); StatementContext context = new StatementContext(statement, null, new Scan(), new SequenceManager(statement)); AggregationManager aggregationManager = context.getAggregationManager(); SumAggregateFunction func = new SumAggregateFunction(Arrays.<Expression>asList(new KeyValueColumnExpression(new PLongColumn() {
new StatementContext(statement, resolver, new Scan(), new SequenceManager(statement));; ParseNode dummyWhere = GenSubqueryParamValuesRewriter.replaceWithDummyValues(stmt.getWhere(), context); stmt = FACTORY.select(stmt, dummyWhere);
QueryCompiler compiler = new QueryCompiler(statement, select, resolverToBe, Collections.<PColumn>emptyList(), parallelIteratorFactoryToBe, new SequenceManager(statement)); final QueryPlan dataPlan = compiler.compile();
ViewType viewTypeToBe = null; Scan scan = new Scan(); final StatementContext context = new StatementContext(statement, resolver, scan, new SequenceManager(statement));
PhoenixConnection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); final PhoenixStatement statement = new PhoenixStatement(connection); final StatementContext context = new StatementContext(statement, resolver, scan, new SequenceManager(statement)); context.setScanRanges(scanRanges); ParallelIterators parallelIterators = new ParallelIterators(new QueryPlan() {
JoinSpec joinSpec = joinSpecs.get(i); Scan subScan = ScanUtil.newScan(originalScan); subContexts[i] = new StatementContext(statement, context.getResolver(), subScan, new SequenceManager(statement)); subPlans[i] = compileJoinQuery(subContexts[i], binds, joinSpec.getJoinTable(), true, true, null); boolean hasPostReference = joinSpec.getJoinTable().hasPostReference(); JoinTable lhsJoin = joinTable.getSubJoinTableWithoutPostFilters(); Scan subScan = ScanUtil.newScan(originalScan); StatementContext lhsCtx = new StatementContext(statement, context.getResolver(), subScan, new SequenceManager(statement)); QueryPlan lhsPlan = compileJoinQuery(lhsCtx, binds, lhsJoin, true, true, null); PTable rhsProjTable; StatementContext lhsCtx = new StatementContext(statement, context.getResolver(), lhsScan, new SequenceManager(statement)); boolean preserveRowkey = !projectPKColumns && type != JoinType.Full; QueryPlan lhsPlan = compileJoinQuery(lhsCtx, binds, lhsJoin, true, !preserveRowkey, lhsOrderBy); StatementContext rhsCtx = new StatementContext(statement, context.getResolver(), rhsScan, new SequenceManager(statement)); QueryPlan rhsPlan = compileJoinQuery(rhsCtx, binds, rhsJoin, true, true, rhsOrderBy); PTable rhsProjTable = rhsCtx.getResolver().getTables().get(0).getTable(); StatementContext subCtx = new StatementContext(statement, resolver, ScanUtil.newScan(originalScan), new SequenceManager(statement)); subCtx.setCurrentTable(tableRef); QueryPlan innerPlan = new SortMergeJoinPlan(subCtx, joinTable.getStatement(), tableRef, type == JoinType.Right ? JoinType.Left : type, lhsPlan, rhsPlan, lhsKeyExpressions, rhsKeyExpressions, projectedTable, lhsProjTable, needsMerge ? rhsProjTable : null, fieldPosition, lastJoinSpec.isSingleValueOnly());
StatementContext context = new StatementContext(statement, resolver, scan, new SequenceManager(statement)); long ts = timestamp;
QueryCompiler compiler = new QueryCompiler(statement, select, selectResolver, targetColumns, parallelIteratorFactoryToBe, new SequenceManager(statement), true, false, null); queryPlanToBe = compiler.compile(); final StatementContext context = new StatementContext(statement, resolver, new Scan(), new SequenceManager(statement)); UpsertValuesCompiler expressionBuilder = new UpsertValuesCompiler(context); final List<Expression> constantExpressions = Lists.newArrayListWithExpectedSize(valueNodes.size());
public QueryPlan optimize(PhoenixStatement statement, SelectStatement select, ColumnResolver resolver, List<? extends PDatum> targetColumns, ParallelIteratorFactory parallelIteratorFactory) throws SQLException { QueryCompiler compiler = new QueryCompiler(statement, select, resolver, targetColumns, parallelIteratorFactory, new SequenceManager(statement)); QueryPlan dataPlan = compiler.compile(); return optimize(dataPlan, statement, targetColumns, parallelIteratorFactory); }
public QueryPlan optimize(PhoenixStatement statement, SelectStatement select, ColumnResolver resolver, List<? extends PDatum> targetColumns, ParallelIteratorFactory parallelIteratorFactory) throws SQLException { QueryCompiler compiler = new QueryCompiler(statement, select, resolver, targetColumns, parallelIteratorFactory, new SequenceManager(statement)); QueryPlan dataPlan = compiler.compile(); return optimize(dataPlan, statement, targetColumns, parallelIteratorFactory); }
public MutationPlan compile(final List<TableRef> tableRefs, final byte[] emptyCF, final List<byte[]> projectCFs, final List<PColumn> deleteList, final long timestamp) throws SQLException { PhoenixStatement statement = new PhoenixStatement(connection); final StatementContext context = new StatementContext( statement, new MultipleTableRefColumnResolver(tableRefs), scan, new SequenceManager(statement)); return new PostDDLMutationPlan(context, tableRefs, timestamp, emptyCF, deleteList, projectCFs); }