use of org.apache.druid.query.dimension.ColumnSelectorStrategy in project druid by druid-io.
the class DimensionHandlerUtils method createColumnSelectorPluses.
/**
* Creates an array of ColumnSelectorPlus objects, selectors that handle type-specific operations within
* query processing engines, using a strategy factory provided by the query engine. One ColumnSelectorPlus
* will be created for each column specified in dimensionSpecs.
* <p>
* The ColumnSelectorPlus provides access to a type strategy (e.g., how to group on a float column)
* and a value selector for a single column.
* <p>
* A caller should define a strategy factory that provides an interface for type-specific operations
* in a query engine. See GroupByStrategyFactory for a reference.
*
* @param <Strategy> The strategy type created by the provided strategy factory.
* @param strategyFactory A factory provided by query engines that generates type-handling strategies
* @param dimensionSpecs The set of columns to generate ColumnSelectorPlus objects for
* @param columnSelectorFactory Used to create value selectors for columns.
* @return An array of ColumnSelectorPlus objects, in the order of the columns specified in dimensionSpecs
* @see ColumnProcessors#makeProcessor which may replace this in the future
*/
public static <Strategy extends ColumnSelectorStrategy> ColumnSelectorPlus<Strategy>[] createColumnSelectorPluses(ColumnSelectorStrategyFactory<Strategy> strategyFactory, List<DimensionSpec> dimensionSpecs, ColumnSelectorFactory columnSelectorFactory) {
int dimCount = dimensionSpecs.size();
@SuppressWarnings("unchecked") ColumnSelectorPlus<Strategy>[] dims = new ColumnSelectorPlus[dimCount];
for (int i = 0; i < dimCount; i++) {
final DimensionSpec dimSpec = dimensionSpecs.get(i);
final String dimName = dimSpec.getDimension();
final ColumnValueSelector<?> selector = getColumnValueSelectorFromDimensionSpec(dimSpec, columnSelectorFactory);
Strategy strategy = makeStrategy(strategyFactory, dimSpec, columnSelectorFactory.getColumnCapabilities(dimSpec.getDimension()), selector);
final ColumnSelectorPlus<Strategy> selectorPlus = new ColumnSelectorPlus<>(dimName, dimSpec.getOutputName(), strategy, selector);
dims[i] = selectorPlus;
}
return dims;
}
Aggregations