Search in sources :

Example 6 with RegexDimExtractionFn

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

the class ExtractionDimFilterTest method testGetCacheKey.

@Test
public void testGetCacheKey() {
    ExtractionDimFilter extractionDimFilter = new ExtractionDimFilter("abc", "d", IdentityExtractionFn.getInstance(), null);
    ExtractionDimFilter extractionDimFilter2 = new ExtractionDimFilter("ab", "cd", IdentityExtractionFn.getInstance(), null);
    Assert.assertFalse(Arrays.equals(extractionDimFilter.getCacheKey(), extractionDimFilter2.getCacheKey()));
    ExtractionDimFilter extractionDimFilter3 = new ExtractionDimFilter("ab", "cd", new RegexDimExtractionFn("xx", null, null), null);
    Assert.assertFalse(Arrays.equals(extractionDimFilter2.getCacheKey(), extractionDimFilter3.getCacheKey()));
    Assert.assertNotNull(new ExtractionDimFilter("foo", null, new RegexDimExtractionFn("xx", null, null), null).getCacheKey());
}
Also used : RegexDimExtractionFn(org.apache.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 7 with RegexDimExtractionFn

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

the class JavaScriptDimFilterTest method testGetCacheKey.

@Test
public void testGetCacheKey() {
    JavaScriptDimFilter javaScriptDimFilter = new JavaScriptDimFilter("dim", FN1, null, JavaScriptConfig.getEnabledInstance());
    JavaScriptDimFilter javaScriptDimFilter2 = new JavaScriptDimFilter("di", FN2, null, JavaScriptConfig.getEnabledInstance());
    Assert.assertFalse(Arrays.equals(javaScriptDimFilter.getCacheKey(), javaScriptDimFilter2.getCacheKey()));
    RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null);
    JavaScriptDimFilter javaScriptDimFilter3 = new JavaScriptDimFilter("dim", FN1, regexFn, JavaScriptConfig.getEnabledInstance());
    Assert.assertFalse(Arrays.equals(javaScriptDimFilter.getCacheKey(), javaScriptDimFilter3.getCacheKey()));
}
Also used : RegexDimExtractionFn(org.apache.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 8 with RegexDimExtractionFn

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

the class JavaScriptDimFilterTest method testEquals.

@Test
public void testEquals() {
    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, javaScriptDimFilter2);
    Assert.assertEquals(javaScriptDimFilter2, javaScriptDimFilter3);
    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, javaScriptDimFilter3);
    Assert.assertEquals(javaScriptDimFilter4, javaScriptDimFilter5);
}
Also used : RegexDimExtractionFn(org.apache.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 9 with RegexDimExtractionFn

use of org.apache.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(ColumnHolder.TIME_COLUMN_NAME, Arrays.asList(Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), null);
    DimFilter intervalFilter2 = new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, Arrays.asList(Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), regexFn);
    DimFilter intervalFilter3 = new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, Arrays.asList(Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("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(ColumnHolder.TIME_COLUMN_NAME, Arrays.asList(Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1977-01-01T00:00:00.004Z"), Intervals.of("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(Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z")), null);
    Assert.assertNotEquals(intervalFilter1.hashCode(), intervalFilter5.hashCode());
}
Also used : RegexDimExtractionFn(org.apache.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 10 with RegexDimExtractionFn

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

the class IntervalDimFilterTest method testEquals.

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

Aggregations

RegexDimExtractionFn (org.apache.druid.query.extraction.RegexDimExtractionFn)41 Test (org.junit.Test)40 ExtractionDimensionSpec (org.apache.druid.query.dimension.ExtractionDimensionSpec)15 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)13 Result (org.apache.druid.query.Result)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)5 ExtractionFn (org.apache.druid.query.extraction.ExtractionFn)5 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)4 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)4 SearchQuerySpec (org.apache.druid.query.search.SearchQuerySpec)3 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)2 RegexFilteredDimensionSpec (org.apache.druid.query.dimension.RegexFilteredDimensionSpec)2 CascadeExtractionFn (org.apache.druid.query.extraction.CascadeExtractionFn)2 DimExtractionFn (org.apache.druid.query.extraction.DimExtractionFn)2 JavaScriptExtractionFn (org.apache.druid.query.extraction.JavaScriptExtractionFn)2 SearchQuerySpecDimExtractionFn (org.apache.druid.query.extraction.SearchQuerySpecDimExtractionFn)2 StringFormatExtractionFn (org.apache.druid.query.extraction.StringFormatExtractionFn)2 StrlenExtractionFn (org.apache.druid.query.extraction.StrlenExtractionFn)2 SubstringDimExtractionFn (org.apache.druid.query.extraction.SubstringDimExtractionFn)2