use of org.apache.druid.segment.ConstantExprEvalSelector in project druid by druid-io.
the class ExpressionSelectors method makeExprEvalSelector.
public static ColumnValueSelector<ExprEval> makeExprEvalSelector(ColumnSelectorFactory columnSelectorFactory, ExpressionPlan plan) {
if (plan.is(ExpressionPlan.Trait.SINGLE_INPUT_SCALAR)) {
final String column = plan.getSingleInputName();
final ColumnType inputType = plan.getSingleInputType();
if (inputType.is(ValueType.LONG)) {
return new SingleLongInputCachingExpressionColumnValueSelector(columnSelectorFactory.makeColumnValueSelector(column), plan.getExpression(), // __time doesn't need an LRU cache since it is sorted.
!ColumnHolder.TIME_COLUMN_NAME.equals(column));
} else if (inputType.is(ValueType.STRING)) {
return new SingleStringInputCachingExpressionColumnValueSelector(columnSelectorFactory.makeDimensionSelector(new DefaultDimensionSpec(column, column, ColumnType.STRING)), plan.getExpression());
}
}
final Expr.ObjectBinding bindings = createBindings(columnSelectorFactory, plan);
// Optimization for constant expressions
if (bindings.equals(InputBindings.nilBindings())) {
return new ConstantExprEvalSelector(plan.getExpression().eval(bindings));
}
// per row basis
if (plan.any(ExpressionPlan.Trait.UNKNOWN_INPUTS, ExpressionPlan.Trait.INCOMPLETE_INPUTS)) {
return new RowBasedExpressionColumnValueSelector(plan, bindings);
}
// generic expression value selector for fully known input types
return new ExpressionColumnValueSelector(plan.getAppliedExpression(), bindings);
}
Aggregations