asdf2014 commented on a change in pull request #6904: add bloom filter druid
expression
URL: https://github.com/apache/incubator-druid/pull/6904#discussion_r250489791
##########
File path:
extensions-core/druid-bloom-filter/src/test/java/org/apache/druid/query/filter/sql/BloomDimFilterSqlTest.java
##########
@@ -112,6 +130,74 @@ public void testBloomFilter() throws Exception
);
}
+ @Test
+ public void testBloomFilterVirtualColumn() throws Exception
+ {
+ BloomKFilter filter = new BloomKFilter(1500);
+ filter.addString("a-foo");
+ filter.addString("-foo");
+ if (!NullHandling.replaceWithDefault()) {
+ filter.addBytes(null, 0, 0);
+ }
+ byte[] bytes = BloomFilterSerializersModule.bloomKFilterToBytes(filter);
+ String base64 = Base64.encodeBase64String(bytes);
+
+ testQuery(
+ StringUtils.format("SELECT COUNT(*) FROM druid.foo WHERE
bloom_filter_test(concat(dim2, '-foo'), '%s')", base64),
+ ImmutableList.of(
+ Druids.newTimeseriesQueryBuilder()
+ .dataSource(CalciteTests.DATASOURCE1)
+ .intervals(QSS(Filtration.eternity()))
+ .granularity(Granularities.ALL)
+ .virtualColumns()
+ .filters(
+ new ExpressionDimFilter(
+
StringUtils.format("bloom_filter_test(concat(\"dim2\",'-foo'),'%s')", base64),
+ createExprMacroTable()
+ )
+ )
+ .aggregators(AGGS(new CountAggregatorFactory("a0")))
+ .context(TIMESERIES_CONTEXT_DEFAULT)
+ .build()
+ ),
+ ImmutableList.of(
+ new Object[]{5L}
+ )
+ );
+ }
+
+ @Test
+ public void testBloomFilterVirtualColumnNumber() throws Exception
+ {
+ BloomKFilter filter = new BloomKFilter(1500);
+ filter.addDouble(20.2);
+ byte[] bytes = BloomFilterSerializersModule.bloomKFilterToBytes(filter);
+ String base64 = Base64.encodeBase64String(bytes);
Review comment:
The same, use `java.util.Base64.getEncoder().encodeToString(bytes)` would be
better.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]