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