Search in sources :

Example 6 with BaseLongColumnValueSelector

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

the class ExpressionVirtualColumnTest method testLongSelectorUsingStringFunction.

@Test
public void testLongSelectorUsingStringFunction() {
    final BaseLongColumnValueSelector selector = Z_CONCAT_X.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);
    if (NullHandling.replaceWithDefault()) {
        Assert.assertEquals(0L, selector.getLong());
    } else {
        Assert.assertTrue(selector.isNull());
    }
    CURRENT_ROW.set(ROW3);
    if (NullHandling.replaceWithDefault()) {
        Assert.assertEquals(0L, selector.getLong());
    } else {
        Assert.assertTrue(selector.isNull());
    }
}
Also used : BaseLongColumnValueSelector(org.apache.druid.segment.BaseLongColumnValueSelector) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 7 with BaseLongColumnValueSelector

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

the class ExpressionVirtualColumnTest method testLongSelectorWithConstantNullArithmetic.

@Test
public void testLongSelectorWithConstantNullArithmetic() {
    final BaseLongColumnValueSelector selector = CONSTANT_NULL_ARITHMETIC.makeColumnValueSelector("expr", COLUMN_SELECTOR_FACTORY);
    CURRENT_ROW.set(ROW0);
    if (NullHandling.replaceWithDefault()) {
        Assert.assertEquals(2L, selector.getLong());
        Assert.assertFalse(selector.isNull());
    } else {
        Assert.assertTrue(selector.isNull());
    }
}
Also used : BaseLongColumnValueSelector(org.apache.druid.segment.BaseLongColumnValueSelector) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 8 with BaseLongColumnValueSelector

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

the class VirtualColumnsTest method testMakeSelectorsWithDotSupportBaseNameOnly.

@Test
public void testMakeSelectorsWithDotSupportBaseNameOnly() {
    final VirtualColumns virtualColumns = makeVirtualColumns();
    final BaseObjectColumnValueSelector objectSelector = virtualColumns.makeColumnValueSelector("foo", null);
    final DimensionSelector dimensionSelector = virtualColumns.makeDimensionSelector(new DefaultDimensionSpec("foo", "x"), null);
    final BaseFloatColumnValueSelector floatSelector = virtualColumns.makeColumnValueSelector("foo", null);
    final BaseLongColumnValueSelector longSelector = virtualColumns.makeColumnValueSelector("foo", null);
    Assert.assertEquals(-1L, objectSelector.getObject());
    Assert.assertEquals("-1", dimensionSelector.lookupName(dimensionSelector.getRow().get(0)));
    Assert.assertEquals(-1.0f, floatSelector.getFloat(), 0.0f);
    Assert.assertEquals(-1L, longSelector.getLong());
}
Also used : BaseFloatColumnValueSelector(org.apache.druid.segment.BaseFloatColumnValueSelector) DimensionSelector(org.apache.druid.segment.DimensionSelector) BaseObjectColumnValueSelector(org.apache.druid.segment.BaseObjectColumnValueSelector) BaseLongColumnValueSelector(org.apache.druid.segment.BaseLongColumnValueSelector) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) VirtualColumns(org.apache.druid.segment.VirtualColumns) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

BaseLongColumnValueSelector (org.apache.druid.segment.BaseLongColumnValueSelector)8 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)7 Test (org.junit.Test)7 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)3 BaseFloatColumnValueSelector (org.apache.druid.segment.BaseFloatColumnValueSelector)3 BaseObjectColumnValueSelector (org.apache.druid.segment.BaseObjectColumnValueSelector)3 DimensionSelector (org.apache.druid.segment.DimensionSelector)3 VirtualColumns (org.apache.druid.segment.VirtualColumns)3 ExtractionDimensionSpec (org.apache.druid.query.dimension.ExtractionDimensionSpec)1 BucketExtractionFn (org.apache.druid.query.extraction.BucketExtractionFn)1