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));
}
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());
}
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());
}
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());
}
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());
}
Aggregations