Search in sources :

Example 31 with RegexDimExtractionFn

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

the class SelectorDimFilterTest method testGetCacheKey.

@Test
public void testGetCacheKey() {
    SelectorDimFilter selectorDimFilter = new SelectorDimFilter("abc", "d", null);
    SelectorDimFilter selectorDimFilter2 = new SelectorDimFilter("ab", "cd", null);
    Assert.assertFalse(Arrays.equals(selectorDimFilter.getCacheKey(), selectorDimFilter2.getCacheKey()));
    RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null);
    SelectorDimFilter selectorDimFilter3 = new SelectorDimFilter("abc", "d", regexFn);
    Assert.assertFalse(Arrays.equals(selectorDimFilter.getCacheKey(), selectorDimFilter3.getCacheKey()));
}
Also used : RegexDimExtractionFn(org.apache.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 32 with RegexDimExtractionFn

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

the class SelectorDimFilterTest method testToString.

@Test
public void testToString() {
    SelectorDimFilter selectorDimFilter = new SelectorDimFilter("abc", "d", null);
    RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null);
    SelectorDimFilter selectorDimFilter2 = new SelectorDimFilter("abc", "d", regexFn);
    Assert.assertEquals("abc = d", selectorDimFilter.toString());
    Assert.assertEquals("regex(/.*/, 1)(abc) = d", selectorDimFilter2.toString());
}
Also used : RegexDimExtractionFn(org.apache.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 33 with RegexDimExtractionFn

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

the class SelectorDimFilterTest method testHashCode.

@Test
public void testHashCode() {
    SelectorDimFilter selectorDimFilter = new SelectorDimFilter("abc", "d", null);
    RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null);
    SelectorDimFilter selectorDimFilter2 = new SelectorDimFilter("abc", "d", regexFn);
    Assert.assertNotEquals(selectorDimFilter.hashCode(), selectorDimFilter2.hashCode());
}
Also used : RegexDimExtractionFn(org.apache.druid.query.extraction.RegexDimExtractionFn) Test(org.junit.Test)

Example 34 with RegexDimExtractionFn

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

the class InDimFilterTest method testGetCacheKeyDifferentKeysForListOfStringsAndSingleStringOfListsWithExtractFn.

@Test
public void testGetCacheKeyDifferentKeysForListOfStringsAndSingleStringOfListsWithExtractFn() {
    RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null);
    final InDimFilter inDimFilter1 = new InDimFilter("dimTest", Arrays.asList("good", "bad"), regexFn);
    final InDimFilter inDimFilter2 = new InDimFilter("dimTest", Collections.singletonList("good,bad"), regexFn);
    Assert.assertFalse(Arrays.equals(inDimFilter1.getCacheKey(), inDimFilter2.getCacheKey()));
}
Also used : RegexDimExtractionFn(org.apache.druid.query.extraction.RegexDimExtractionFn) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 35 with RegexDimExtractionFn

use of org.apache.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(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