use of org.apache.drill.exec.planner.logical.partition.RewriteAsBinaryOperators in project drill by apache.
the class DbScanToIndexScanPrule method doOnMatch.
protected void doOnMatch(IndexLogicalPlanCallContext indexContext) {
Stopwatch indexPlanTimer = Stopwatch.createStarted();
final PlannerSettings settings = PrelUtil.getPlannerSettings(indexContext.call.getPlanner());
final IndexCollection indexCollection = getIndexCollection(settings, indexContext.scan);
if (indexCollection == null) {
return;
}
logger.debug("Index Rule {} starts", this.description);
RexBuilder builder = indexContext.filter.getCluster().getRexBuilder();
RexNode condition = null;
if (indexContext.lowerProject == null) {
condition = indexContext.filter.getCondition();
} else {
// get the filter as if it were below the projection.
condition = RelOptUtil.pushFilterPastProject(indexContext.filter.getCondition(), indexContext.lowerProject);
}
// save this pushed down condition, in case it is needed later to build filter when joining back primary table
indexContext.origPushedCondition = condition;
RewriteAsBinaryOperators visitor = new RewriteAsBinaryOperators(true, builder);
condition = condition.accept(visitor);
if (indexCollection.supportsIndexSelection()) {
try {
processWithIndexSelection(indexContext, settings, condition, indexCollection, builder);
} catch (Exception e) {
logger.warn("Exception while doing index planning ", e);
}
} else {
throw new UnsupportedOperationException("Index collection must support index selection");
}
indexPlanTimer.stop();
logger.info("index_plan_info: Index Planning took {} ms", indexPlanTimer.elapsed(TimeUnit.MILLISECONDS));
}
Aggregations