Search in sources :

Example 1 with BloomFilterExtensionModule

use of org.apache.druid.guice.BloomFilterExtensionModule in project druid by druid-io.

the class BloomFilterAggregatorTest method testSerde.

@Test
public void testSerde() throws Exception {
    BloomFilterAggregatorFactory factory = new BloomFilterAggregatorFactory("billy", new DefaultDimensionSpec("b", "b"), MAX_NUM_VALUES);
    ObjectMapper objectMapper = new DefaultObjectMapper();
    new BloomFilterExtensionModule().getJacksonModules().forEach(objectMapper::registerModule);
    Assert.assertEquals(factory, objectMapper.readValue(objectMapper.writeValueAsString(factory), AggregatorFactory.class));
    String fieldNamesOnly = "{" + "\"type\":\"bloom\"," + "\"name\":\"billy\"," + "\"field\":\"b\"," + "\"maxNumEntries\":15" + "}";
    Assert.assertEquals(factory, objectMapper.readValue(fieldNamesOnly, AggregatorFactory.class));
    BloomFilterAggregatorFactory factory2 = new BloomFilterAggregatorFactory("billy", new ExtractionDimensionSpec("b", "b", new RegexDimExtractionFn(".*", false, null)), MAX_NUM_VALUES);
    Assert.assertEquals(factory2, objectMapper.readValue(objectMapper.writeValueAsString(factory2), AggregatorFactory.class));
    BloomFilterAggregatorFactory factory3 = new BloomFilterAggregatorFactory("billy", new RegexFilteredDimensionSpec(new DefaultDimensionSpec("a", "a"), ".*"), MAX_NUM_VALUES);
    Assert.assertEquals(factory3, objectMapper.readValue(objectMapper.writeValueAsString(factory3), AggregatorFactory.class));
}
Also used : BloomFilterExtensionModule(org.apache.druid.guice.BloomFilterExtensionModule) RegexFilteredDimensionSpec(org.apache.druid.query.dimension.RegexFilteredDimensionSpec) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) AggregatorFactory(org.apache.druid.query.aggregation.AggregatorFactory) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) RegexDimExtractionFn(org.apache.druid.query.extraction.RegexDimExtractionFn) ExtractionDimensionSpec(org.apache.druid.query.dimension.ExtractionDimensionSpec) CardinalityAggregatorTest(org.apache.druid.query.aggregation.cardinality.CardinalityAggregatorTest) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BloomFilterExtensionModule (org.apache.druid.guice.BloomFilterExtensionModule)1 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)1 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)1 CardinalityAggregatorTest (org.apache.druid.query.aggregation.cardinality.CardinalityAggregatorTest)1 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)1 ExtractionDimensionSpec (org.apache.druid.query.dimension.ExtractionDimensionSpec)1 RegexFilteredDimensionSpec (org.apache.druid.query.dimension.RegexFilteredDimensionSpec)1 RegexDimExtractionFn (org.apache.druid.query.extraction.RegexDimExtractionFn)1 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)1 Test (org.junit.Test)1