Search in sources :

Example 6 with DocKeys

use of io.crate.analyze.where.DocKeys in project crate by crate.

the class OptimizeCollectWhereClauseAccess method apply.

@Override
public LogicalPlan apply(Collect collect, Captures captures, TableStats tableStats, TransactionContext txnCtx, NodeContext nodeCtx) {
    var relation = (DocTableRelation) collect.relation();
    var normalizer = new EvaluatingNormalizer(nodeCtx, RowGranularity.CLUSTER, null, relation);
    WhereClause where = collect.where();
    var detailedQuery = WhereClauseOptimizer.optimize(normalizer, where.queryOrFallback(), relation.tableInfo(), txnCtx, nodeCtx);
    Optional<DocKeys> docKeys = detailedQuery.docKeys();
    // noinspection OptionalIsPresent no capturing lambda allocation
    if (docKeys.isPresent()) {
        return new Get(relation, docKeys.get(), detailedQuery.query(), collect.outputs(), tableStats.estimatedSizePerRow(relation.relationName()));
    } else if (!detailedQuery.clusteredBy().isEmpty() && collect.detailedQuery() == null) {
        return new Collect(collect, detailedQuery);
    } else {
        return null;
    }
}
Also used : EvaluatingNormalizer(io.crate.expression.eval.EvaluatingNormalizer) DocKeys(io.crate.analyze.where.DocKeys) Collect(io.crate.planner.operators.Collect) Get(io.crate.planner.operators.Get) WhereClause(io.crate.analyze.WhereClause) DocTableRelation(io.crate.analyze.relations.DocTableRelation)

Aggregations

DocKeys (io.crate.analyze.where.DocKeys)6 DocTableRelation (io.crate.analyze.relations.DocTableRelation)3 WhereClause (io.crate.analyze.WhereClause)2 Symbol (io.crate.expression.symbol.Symbol)2 DocTableInfo (io.crate.metadata.doc.DocTableInfo)2 NoopPlan (io.crate.planner.NoopPlan)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IndexNotFoundException (org.elasticsearch.index.IndexNotFoundException)2 ShardId (org.elasticsearch.index.shard.ShardId)2 OrderBy (io.crate.analyze.OrderBy)1 QuerySpec (io.crate.analyze.QuerySpec)1 AbstractTableRelation (io.crate.analyze.relations.AbstractTableRelation)1 EqualityExtractor (io.crate.analyze.where.EqualityExtractor)1 Lists2 (io.crate.common.collections.Lists2)1 Row (io.crate.data.Row)1 VersionInvalidException (io.crate.exceptions.VersionInvalidException)1 PKLookupPhase (io.crate.execution.dsl.phases.PKLookupPhase)1 EvalProjection (io.crate.execution.dsl.projection.EvalProjection)1 Projection (io.crate.execution.dsl.projection.Projection)1