Search in sources :

Example 26 with RegexDimExtractionFn

use of io.druid.query.extraction.RegexDimExtractionFn in project druid by druid-io.

the class ExtractionDimensionSpecTest method testSerde.

@Test
public void testSerde() throws Exception {
    final ObjectMapper objectMapper = new DefaultObjectMapper();
    final String oldJson = "{\n" + "    \"type\": \"extraction\",\n" + "    \"outputName\": \"first3Letters\",\n" + "    \"dimension\": \"myDim\"," + "    \"extractionFn\": {\n" + "        \"type\": \"regex\",\n" + "        \"expr\": \"(...).*\"\n" + "    }\n" + "}";
    final ExtractionDimensionSpec extractionDimensionSpec = (ExtractionDimensionSpec) objectMapper.readValue(oldJson, DimensionSpec.class);
    Assert.assertEquals("first3Letters", extractionDimensionSpec.getOutputName());
    Assert.assertEquals("myDim", extractionDimensionSpec.getDimension());
    Assert.assertNotNull(extractionDimensionSpec.getExtractionFn());
    Assert.assertEquals(ValueType.STRING, extractionDimensionSpec.getOutputType());
    Assert.assertTrue(extractionDimensionSpec.getExtractionFn() instanceof RegexDimExtractionFn);
    Assert.assertEquals(extractionDimensionSpec, objectMapper.readValue(objectMapper.writeValueAsBytes(extractionDimensionSpec), DimensionSpec.class));
}
Also used : DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RegexDimExtractionFn(io.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 27 with RegexDimExtractionFn

use of io.druid.query.extraction.RegexDimExtractionFn in project druid by druid-io.

the class InDimFilterSerDesrTest method testGetCacheKey.

@Test
public void testGetCacheKey() {
    final InDimFilter inDimFilter_1 = new InDimFilter("dimTest", Arrays.asList("good", "bad"), null);
    final InDimFilter inDimFilter_2 = new InDimFilter("dimTest", Arrays.asList("good,bad"), null);
    Assert.assertNotEquals(inDimFilter_1.getCacheKey(), inDimFilter_2.getCacheKey());
    RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null);
    final InDimFilter inDimFilter_3 = new InDimFilter("dimTest", Arrays.asList("good", "bad"), regexFn);
    final InDimFilter inDimFilter_4 = new InDimFilter("dimTest", Arrays.asList("good,bad"), regexFn);
    Assert.assertNotEquals(inDimFilter_3.getCacheKey(), inDimFilter_4.getCacheKey());
}
Also used : RegexDimExtractionFn(io.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 28 with RegexDimExtractionFn

use of io.druid.query.extraction.RegexDimExtractionFn in project druid by druid-io.

the class IntervalDimFilterTest method testGetCacheKey.

@Test
public void testGetCacheKey() {
    DimFilter intervalFilter1 = new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Interval.parse("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), null);
    DimFilter intervalFilter2 = new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Interval.parse("1976-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), null);
    Assert.assertNotEquals(intervalFilter1.getCacheKey(), intervalFilter2.getCacheKey());
    RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null);
    DimFilter intervalFilter3 = new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Interval.parse("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), regexFn);
    DimFilter intervalFilter4 = new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Interval.parse("1976-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), regexFn);
    Assert.assertNotEquals(intervalFilter3.getCacheKey(), intervalFilter4.getCacheKey());
}
Also used : RegexDimExtractionFn(io.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 29 with RegexDimExtractionFn

use of io.druid.query.extraction.RegexDimExtractionFn in project druid by druid-io.

the class IntervalDimFilterTest method testHashCode.

@Test
public void testHashCode() {
    RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null);
    DimFilter intervalFilter1 = new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Interval.parse("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), null);
    DimFilter intervalFilter2 = new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Interval.parse("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), regexFn);
    DimFilter intervalFilter3 = new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Interval.parse("1977-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), null);
    Assert.assertNotEquals(intervalFilter1.hashCode(), intervalFilter2.hashCode());
    Assert.assertNotEquals(intervalFilter1.hashCode(), intervalFilter3.hashCode());
    DimFilter intervalFilter4 = new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Interval.parse("1975-01-01T00:00:00.001Z/1977-01-01T00:00:00.004Z"), Interval.parse("1976-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), null);
    Assert.assertEquals(intervalFilter1.hashCode(), intervalFilter4.hashCode());
    DimFilter intervalFilter5 = new IntervalDimFilter("__thyme", Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Interval.parse("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), null);
    Assert.assertNotEquals(intervalFilter1.hashCode(), intervalFilter5.hashCode());
}
Also used : RegexDimExtractionFn(io.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 30 with RegexDimExtractionFn

use of io.druid.query.extraction.RegexDimExtractionFn in project druid by druid-io.

the class JavaScriptDimFilterTest method testHashcode.

@Test
public void testHashcode() {
    JavaScriptDimFilter javaScriptDimFilter = new JavaScriptDimFilter("dim", FN1, null, JavaScriptConfig.getEnabledInstance());
    JavaScriptDimFilter javaScriptDimFilter2 = new JavaScriptDimFilter("di", FN2, null, JavaScriptConfig.getEnabledInstance());
    JavaScriptDimFilter javaScriptDimFilter3 = new JavaScriptDimFilter("di", FN2, null, JavaScriptConfig.getEnabledInstance());
    Assert.assertNotEquals(javaScriptDimFilter.hashCode(), javaScriptDimFilter2.hashCode());
    Assert.assertEquals(javaScriptDimFilter2.hashCode(), javaScriptDimFilter3.hashCode());
    RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null);
    JavaScriptDimFilter javaScriptDimFilter4 = new JavaScriptDimFilter("dim", FN1, regexFn, JavaScriptConfig.getEnabledInstance());
    JavaScriptDimFilter javaScriptDimFilter5 = new JavaScriptDimFilter("dim", FN1, regexFn, JavaScriptConfig.getEnabledInstance());
    Assert.assertNotEquals(javaScriptDimFilter.hashCode(), javaScriptDimFilter3.hashCode());
    Assert.assertEquals(javaScriptDimFilter4.hashCode(), javaScriptDimFilter5.hashCode());
}
Also used : RegexDimExtractionFn(io.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Aggregations

RegexDimExtractionFn (io.druid.query.extraction.RegexDimExtractionFn)35 Test (org.junit.Test)35 ExtractionDimensionSpec (io.druid.query.dimension.ExtractionDimensionSpec)11 Result (io.druid.query.Result)7 PostAggregator (io.druid.query.aggregation.PostAggregator)7 HyperUniqueFinalizingPostAggregator (io.druid.query.aggregation.hyperloglog.HyperUniqueFinalizingPostAggregator)7 DateTime (org.joda.time.DateTime)7 ExtractionFn (io.druid.query.extraction.ExtractionFn)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)4 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)4 RegexFilteredDimensionSpec (io.druid.query.dimension.RegexFilteredDimensionSpec)4 IdentityExtractionFn (io.druid.query.extraction.IdentityExtractionFn)4 Row (io.druid.data.input.Row)3 LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)3 DimensionSpec (io.druid.query.dimension.DimensionSpec)3 ListFilteredDimensionSpec (io.druid.query.dimension.ListFilteredDimensionSpec)3 SearchQuerySpec (io.druid.query.search.search.SearchQuerySpec)3 CascadeExtractionFn (io.druid.query.extraction.CascadeExtractionFn)2 DimExtractionFn (io.druid.query.extraction.DimExtractionFn)2