Search in sources :

Example 31 with ColumnValueSelector

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

the class ArrayStringGroupByColumnSelectorStrategyTest method testSanity.

@Test
public void testSanity() {
    ColumnValueSelector columnValueSelector = Mockito.mock(ColumnValueSelector.class);
    Mockito.when(columnValueSelector.getObject()).thenReturn(ImmutableList.of("a", "b"));
    Assert.assertEquals(0, strategy.getOnlyValue(columnValueSelector));
    GroupByColumnSelectorPlus groupByColumnSelectorPlus = Mockito.mock(GroupByColumnSelectorPlus.class);
    Mockito.when(groupByColumnSelectorPlus.getResultRowPosition()).thenReturn(0);
    ResultRow row = ResultRow.create(1);
    buffer1.putInt(0);
    strategy.processValueFromGroupingKey(groupByColumnSelectorPlus, buffer1, row, 0);
    Assert.assertEquals(ComparableStringArray.of("a", "b"), row.get(0));
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) Test(org.junit.Test)

Example 32 with ColumnValueSelector

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

the class ArrayStringGroupByColumnSelectorStrategyTest method testAddingInDictionaryWithObjects.

@Test
public void testAddingInDictionaryWithObjects() {
    ColumnValueSelector columnValueSelector = Mockito.mock(ColumnValueSelector.class);
    Mockito.when(columnValueSelector.getObject()).thenReturn(new Object[] { "f", "a" });
    Assert.assertEquals(3, strategy.getOnlyValue(columnValueSelector));
    GroupByColumnSelectorPlus groupByColumnSelectorPlus = Mockito.mock(GroupByColumnSelectorPlus.class);
    Mockito.when(groupByColumnSelectorPlus.getResultRowPosition()).thenReturn(0);
    ResultRow row = ResultRow.create(1);
    buffer1.putInt(3);
    strategy.processValueFromGroupingKey(groupByColumnSelectorPlus, buffer1, row, 0);
    Assert.assertEquals(ComparableStringArray.of("f", "a"), row.get(0));
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) ColumnValueSelector(org.apache.druid.segment.ColumnValueSelector) Test(org.junit.Test)

Aggregations

ColumnValueSelector (org.apache.druid.segment.ColumnValueSelector)32 Test (org.junit.Test)18 Cursor (org.apache.druid.segment.Cursor)13 QueryableIndexStorageAdapter (org.apache.druid.segment.QueryableIndexStorageAdapter)12 ImmutableList (com.google.common.collect.ImmutableList)9 TestExprMacroTable (org.apache.druid.query.expression.TestExprMacroTable)9 ResultRow (org.apache.druid.query.groupby.ResultRow)9 VirtualColumns (org.apache.druid.segment.VirtualColumns)9 List (java.util.List)8 NullHandling (org.apache.druid.common.config.NullHandling)8 Granularities (org.apache.druid.java.util.common.granularity.Granularities)8 Sequence (org.apache.druid.java.util.common.guava.Sequence)8 Closer (org.apache.druid.java.util.common.io.Closer)8 QueryableIndex (org.apache.druid.segment.QueryableIndex)8 GeneratorSchemaInfo (org.apache.druid.segment.generator.GeneratorSchemaInfo)8 SegmentGenerator (org.apache.druid.segment.generator.SegmentGenerator)8 DataSegment (org.apache.druid.timeline.DataSegment)8 LinearShardSpec (org.apache.druid.timeline.partition.LinearShardSpec)8 TimeUnit (java.util.concurrent.TimeUnit)7 Expr (org.apache.druid.math.expr.Expr)7