use of org.apache.druid.segment.BaseLongColumnValueSelector in project druid by druid-io.
the class ExpressionVirtualColumnTest method testLongSelector.
@Test
public void testLongSelector() {
final BaseLongColumnValueSelector selector = X_PLUS_Y.makeColumnValueSelector("expr", COLUMN_SELECTOR_FACTORY);
CURRENT_ROW.set(ROW0);
if (NullHandling.replaceWithDefault()) {
Assert.assertEquals(0L, selector.getLong());
} else {
Assert.assertTrue(selector.isNull());
}
CURRENT_ROW.set(ROW1);
if (NullHandling.replaceWithDefault()) {
Assert.assertEquals(4L, selector.getLong());
} else {
// y is null for row1
Assert.assertTrue(selector.isNull());
}
CURRENT_ROW.set(ROW2);
Assert.assertEquals(5L, selector.getLong());
CURRENT_ROW.set(ROW3);
Assert.assertEquals(5L, selector.getLong());
}
use of org.apache.druid.segment.BaseLongColumnValueSelector in project druid by druid-io.
the class ExpressionVirtualColumnTest method testLongSelectorWithConstantLikeExprMacro.
@Test
public void testLongSelectorWithConstantLikeExprMacro() {
final BaseLongColumnValueSelector selector = CONSTANT_LIKE.makeColumnValueSelector("expr", COLUMN_SELECTOR_FACTORY);
CURRENT_ROW.set(ROW0);
Assert.assertEquals(1L, selector.getLong());
}
use of org.apache.druid.segment.BaseLongColumnValueSelector in project druid by druid-io.
the class VirtualColumnsTest method testMakeSelectors.
@Test
public void testMakeSelectors() {
final VirtualColumns virtualColumns = makeVirtualColumns();
final BaseObjectColumnValueSelector objectSelector = virtualColumns.makeColumnValueSelector("expr", null);
final DimensionSelector dimensionSelector = virtualColumns.makeDimensionSelector(new DefaultDimensionSpec("expr", "x"), null);
final DimensionSelector extractionDimensionSelector = virtualColumns.makeDimensionSelector(new ExtractionDimensionSpec("expr", "x", new BucketExtractionFn(1.0, 0.5)), null);
final BaseFloatColumnValueSelector floatSelector = virtualColumns.makeColumnValueSelector("expr", null);
final BaseLongColumnValueSelector longSelector = virtualColumns.makeColumnValueSelector("expr", null);
Assert.assertEquals(1L, objectSelector.getObject());
Assert.assertEquals("1", dimensionSelector.lookupName(dimensionSelector.getRow().get(0)));
Assert.assertEquals("0.5", extractionDimensionSelector.lookupName(extractionDimensionSelector.getRow().get(0)));
Assert.assertEquals(1.0f, floatSelector.getFloat(), 0.0f);
Assert.assertEquals(1L, longSelector.getLong());
}
use of org.apache.druid.segment.BaseLongColumnValueSelector in project druid by druid-io.
the class VirtualColumnsTest method testMakeSelectorsWithDotSupport.
@Test
public void testMakeSelectorsWithDotSupport() {
final VirtualColumns virtualColumns = makeVirtualColumns();
final BaseObjectColumnValueSelector objectSelector = virtualColumns.makeColumnValueSelector("foo.5", null);
final DimensionSelector dimensionSelector = virtualColumns.makeDimensionSelector(new DefaultDimensionSpec("foo.5", "x"), null);
final BaseFloatColumnValueSelector floatSelector = virtualColumns.makeColumnValueSelector("foo.5", null);
final BaseLongColumnValueSelector longSelector = virtualColumns.makeColumnValueSelector("foo.5", null);
Assert.assertEquals(5L, objectSelector.getObject());
Assert.assertEquals("5", dimensionSelector.lookupName(dimensionSelector.getRow().get(0)));
Assert.assertEquals(5.0f, floatSelector.getFloat(), 0.0f);
Assert.assertEquals(5L, longSelector.getLong());
}
use of org.apache.druid.segment.BaseLongColumnValueSelector in project druid by druid-io.
the class FilterPartitionBenchmark method readCursorsLong.
private void readCursorsLong(Sequence<Cursor> cursors, final Blackhole blackhole) {
final Sequence<Void> voids = Sequences.map(cursors, input -> {
BaseLongColumnValueSelector selector = input.getColumnSelectorFactory().makeColumnValueSelector("sumLongSequential");
while (!input.isDone()) {
long rowval = selector.getLong();
blackhole.consume(rowval);
input.advance();
}
return null;
});
blackhole.consume(voids.toList());
}
Aggregations