Search in sources :

Example 1 with BaseDoubleColumnValueSelector

use of org.apache.druid.segment.BaseDoubleColumnValueSelector in project druid by druid-io.

the class ArrayOfDoublesSketchAggregatorFactory method factorizeBuffered.

@Override
public BufferAggregator factorizeBuffered(final ColumnSelectorFactory metricFactory) {
    if (metricColumns == null) {
        // input is sketches, use merge aggregator
        final BaseObjectColumnValueSelector<ArrayOfDoublesSketch> selector = metricFactory.makeColumnValueSelector(fieldName);
        if (selector instanceof NilColumnValueSelector) {
            return new NoopArrayOfDoublesSketchBufferAggregator(numberOfValues);
        }
        return new ArrayOfDoublesSketchMergeBufferAggregator(selector, nominalEntries, numberOfValues, getMaxIntermediateSizeWithNulls());
    }
    // input is raw data (key and array of values), use build aggregator
    final DimensionSelector keySelector = metricFactory.makeDimensionSelector(new DefaultDimensionSpec(fieldName, fieldName));
    if (DimensionSelector.isNilSelector(keySelector)) {
        return new NoopArrayOfDoublesSketchBufferAggregator(numberOfValues);
    }
    final List<BaseDoubleColumnValueSelector> valueSelectors = new ArrayList<>();
    for (final String column : metricColumns) {
        final BaseDoubleColumnValueSelector valueSelector = metricFactory.makeColumnValueSelector(column);
        valueSelectors.add(valueSelector);
    }
    return new ArrayOfDoublesSketchBuildBufferAggregator(keySelector, valueSelectors, nominalEntries, getMaxIntermediateSizeWithNulls());
}
Also used : BaseDoubleColumnValueSelector(org.apache.druid.segment.BaseDoubleColumnValueSelector) DimensionSelector(org.apache.druid.segment.DimensionSelector) ArrayList(java.util.ArrayList) ArrayOfDoublesSketch(org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketch) NilColumnValueSelector(org.apache.druid.segment.NilColumnValueSelector) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec)

Example 2 with BaseDoubleColumnValueSelector

use of org.apache.druid.segment.BaseDoubleColumnValueSelector in project druid by druid-io.

the class ArrayOfDoublesSketchAggregatorFactory method factorize.

@Override
public Aggregator factorize(final ColumnSelectorFactory metricFactory) {
    if (metricColumns == null) {
        // input is sketches, use merge aggregator
        final BaseObjectColumnValueSelector<ArrayOfDoublesSketch> selector = metricFactory.makeColumnValueSelector(fieldName);
        if (selector instanceof NilColumnValueSelector) {
            return new NoopArrayOfDoublesSketchAggregator(numberOfValues);
        }
        return new ArrayOfDoublesSketchMergeAggregator(selector, nominalEntries, numberOfValues);
    }
    // input is raw data (key and array of values), use build aggregator
    final DimensionSelector keySelector = metricFactory.makeDimensionSelector(new DefaultDimensionSpec(fieldName, fieldName));
    if (DimensionSelector.isNilSelector(keySelector)) {
        return new NoopArrayOfDoublesSketchAggregator(numberOfValues);
    }
    final List<BaseDoubleColumnValueSelector> valueSelectors = new ArrayList<>();
    for (final String column : metricColumns) {
        final BaseDoubleColumnValueSelector valueSelector = metricFactory.makeColumnValueSelector(column);
        valueSelectors.add(valueSelector);
    }
    return new ArrayOfDoublesSketchBuildAggregator(keySelector, valueSelectors, nominalEntries);
}
Also used : BaseDoubleColumnValueSelector(org.apache.druid.segment.BaseDoubleColumnValueSelector) DimensionSelector(org.apache.druid.segment.DimensionSelector) ArrayList(java.util.ArrayList) ArrayOfDoublesSketch(org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketch) NilColumnValueSelector(org.apache.druid.segment.NilColumnValueSelector) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec)

Aggregations

ArrayList (java.util.ArrayList)2 ArrayOfDoublesSketch (org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketch)2 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)2 BaseDoubleColumnValueSelector (org.apache.druid.segment.BaseDoubleColumnValueSelector)2 DimensionSelector (org.apache.druid.segment.DimensionSelector)2 NilColumnValueSelector (org.apache.druid.segment.NilColumnValueSelector)2