Search in sources :

Example 1 with StringCardinalityAggregatorColumnSelectorStrategy

use of org.apache.druid.query.aggregation.cardinality.types.StringCardinalityAggregatorColumnSelectorStrategy in project druid by druid-io.

the class CardinalityAggregatorBenchmark method setUp.

@Override
protected void setUp() {
    Iterable<String[]> values = FluentIterable.from(ContiguousSet.create(Range.closedOpen(0, 500), DiscreteDomain.integers())).transform(new Function<Integer, String[]>() {

        @Override
        public String[] apply(Integer input) {
            if (multivaluedSized == 1) {
                return new String[] { input.toString() };
            } else {
                String[] res = new String[multivaluedSized];
                String value = input.toString();
                for (int i = 0; i < multivaluedSized; ++i) {
                    res[i] = value + i;
                }
                return res;
            }
        }
    }).cycle().limit(MAX);
    final DimensionSpec dimSpec1 = new DefaultDimensionSpec("dim1", "dim1");
    final CardinalityAggregatorTest.TestDimensionSelector dim1 = new CardinalityAggregatorTest.TestDimensionSelector(values, null);
    final ColumnSelectorPlus<CardinalityAggregatorColumnSelectorStrategy> dimInfo1 = new ColumnSelectorPlus(dimSpec1.getDimension(), dimSpec1.getOutputName(), new StringCardinalityAggregatorColumnSelectorStrategy(), dim1);
    selectorList = Collections.singletonList((DimensionSelector) dim1);
    dimInfos = new ColumnSelectorPlus[] { dimInfo1 };
    agg = new CardinalityBufferAggregator(dimInfos, byRow);
    CardinalityAggregatorFactory factory = new CardinalityAggregatorFactory("billy", Collections.singletonList(new DefaultDimensionSpec("dim1", "dim1")), byRow);
    int maxSize = factory.getMaxIntermediateSizeWithNulls();
    buf = ByteBuffer.allocate(maxSize + 64);
    pos = 10;
    buf.limit(pos + maxSize);
    agg.init(buf, pos);
}
Also used : DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) DimensionSpec(org.apache.druid.query.dimension.DimensionSpec) ColumnSelectorPlus(org.apache.druid.query.ColumnSelectorPlus) DimensionSelector(org.apache.druid.segment.DimensionSelector) CardinalityAggregatorColumnSelectorStrategy(org.apache.druid.query.aggregation.cardinality.types.CardinalityAggregatorColumnSelectorStrategy) StringCardinalityAggregatorColumnSelectorStrategy(org.apache.druid.query.aggregation.cardinality.types.StringCardinalityAggregatorColumnSelectorStrategy) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) StringCardinalityAggregatorColumnSelectorStrategy(org.apache.druid.query.aggregation.cardinality.types.StringCardinalityAggregatorColumnSelectorStrategy)

Aggregations

ColumnSelectorPlus (org.apache.druid.query.ColumnSelectorPlus)1 CardinalityAggregatorColumnSelectorStrategy (org.apache.druid.query.aggregation.cardinality.types.CardinalityAggregatorColumnSelectorStrategy)1 StringCardinalityAggregatorColumnSelectorStrategy (org.apache.druid.query.aggregation.cardinality.types.StringCardinalityAggregatorColumnSelectorStrategy)1 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)1 DimensionSpec (org.apache.druid.query.dimension.DimensionSpec)1 DimensionSelector (org.apache.druid.segment.DimensionSelector)1