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;
}
}
Aggregations