kfaraz commented on a change in pull request #12046:
URL: https://github.com/apache/druid/pull/12046#discussion_r766419912
##########
File path:
core/src/test/java/org/apache/druid/timeline/partition/DimensionRangeShardSpecTest.java
##########
@@ -297,6 +301,98 @@ public void testIsInChunk_withMultiValues()
));
}
+ @Test
+ public void testPossibleInDomain()
+ {
+ setDimensions("planet", "country", "city");
+
+ final StringTuple start = StringTuple.create("Earth", "France", "Paris");
+ final StringTuple end = StringTuple.create("Earth", "USA", "New York");
+
+ final RangeSet<String> emptySet = TreeRangeSet.create();
+ final RangeSet<String> universalSet = TreeRangeSet.create();
+ universalSet.add(Range.all());
+
+ ShardSpec shard = new DimensionRangeShardSpec(dimensions, start, end, 0,
null);
+ Map<String, RangeSet<String>> domain = new HashMap<>();
+ RangeSet<String> planetSet;
+ RangeSet<String> countrySet;
+ RangeSet<String> citySet;
+
+ // null * null * null === (-INF, INF) * (-INF, INF) * (-INF, INF)
+ assertTrue(shard.possibleInDomain(domain));
+
+ // (-INF, INF) * (-INF, INF) * (-INF, INF)
+ populateDomain(domain, universalSet, universalSet, universalSet);
+ assertTrue(shard.possibleInDomain(domain));
+
+ // {} * {} * {}
+ populateDomain(domain, emptySet, emptySet, emptySet);
+ assertFalse(shard.possibleInDomain(domain));
+
+ // {Earth} * (-INF, INF) * (-INF, INF)
+ planetSet = getUnion(Range.singleton("Earth"));
+ populateDomain(domain, planetSet, universalSet, universalSet);
+ assertTrue(shard.possibleInDomain(domain));
+
+ // (-INF, Earth) * (-INF, INF) * (-INF, INF)
+ planetSet = getUnion(Range.lessThan("Earth"));
+ populateDomain(domain, planetSet, universalSet, universalSet);
Review comment:
_Nit: Style suggestion_
I think you could just skip assigning values to the `planetSet` variable and
call `populateDomain(domain, getUnion(...), universalSet, ...)`
This would make the individual test cases concise and easier to read.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]