use of org.apache.druid.segment.ColumnValueSelector in project druid by druid-io.
the class ExpressionVirtualColumnTest method testLongSelectorOfTimeColumn.
@Test
public void testLongSelectorOfTimeColumn() {
final ColumnValueSelector selector = TIME_FLOOR.makeColumnValueSelector("expr", COLUMN_SELECTOR_FACTORY);
CURRENT_ROW.set(ROW0);
Assert.assertEquals(DateTimes.of("2000-01-01").getMillis(), selector.getLong());
Assert.assertEquals((float) DateTimes.of("2000-01-01").getMillis(), selector.getFloat(), 0.0f);
Assert.assertEquals((double) DateTimes.of("2000-01-01").getMillis(), selector.getDouble(), 0.0d);
Assert.assertEquals(DateTimes.of("2000-01-01").getMillis(), selector.getObject());
CURRENT_ROW.set(ROW1);
Assert.assertEquals(DateTimes.of("2000-01-01").getMillis(), selector.getLong());
CURRENT_ROW.set(ROW2);
Assert.assertEquals(DateTimes.of("2000-01-01").getMillis(), selector.getLong());
CURRENT_ROW.set(ROW3);
Assert.assertEquals(DateTimes.of("2000-01-02").getMillis(), selector.getLong());
Assert.assertEquals(DateTimes.of("2000-01-02").getMillis(), selector.getDouble(), 0.0);
}
use of org.apache.druid.segment.ColumnValueSelector in project druid by druid-io.
the class ExpressionVirtualColumnTest method testLongSelectorWithZLikeExprMacro.
@Test
public void testLongSelectorWithZLikeExprMacro() {
final ColumnValueSelector selector = Z_LIKE.makeColumnValueSelector("expr", COLUMN_SELECTOR_FACTORY);
CURRENT_ROW.set(ROW0);
Assert.assertEquals(0L, selector.getLong());
CURRENT_ROW.set(ROW1);
Assert.assertEquals(0L, selector.getLong());
CURRENT_ROW.set(ROW2);
Assert.assertEquals(1L, selector.getLong());
CURRENT_ROW.set(ROW3);
Assert.assertEquals(1L, selector.getLong());
}
use of org.apache.druid.segment.ColumnValueSelector in project druid by druid-io.
the class ArrayDoubleGroupByColumnSelectorStrategyTest method testAddingInDictionaryWithObjects.
@Test
public void testAddingInDictionaryWithObjects() {
ColumnValueSelector columnValueSelector = Mockito.mock(ColumnValueSelector.class);
Mockito.when(columnValueSelector.getObject()).thenReturn(new Object[] { 4.0D, 2.0D });
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(new ComparableList(ImmutableList.of(4.0, 2.0)), row.get(0));
}
use of org.apache.druid.segment.ColumnValueSelector in project druid by druid-io.
the class ArrayDoubleGroupByColumnSelectorStrategyTest method testSanity.
@Test
public void testSanity() {
ColumnValueSelector columnValueSelector = Mockito.mock(ColumnValueSelector.class);
Mockito.when(columnValueSelector.getObject()).thenReturn(ImmutableList.of(1.0, 2.0));
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(new ComparableList(ImmutableList.of(1.0, 2.0)), row.get(0));
}
use of org.apache.druid.segment.ColumnValueSelector in project druid by druid-io.
the class ArrayStringGroupByColumnSelectorStrategyTest method testAddingInDictionary.
@Test
public void testAddingInDictionary() {
ColumnValueSelector columnValueSelector = Mockito.mock(ColumnValueSelector.class);
Mockito.when(columnValueSelector.getObject()).thenReturn(ImmutableList.of("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));
}
Aggregations