use of org.apache.druid.data.input.StringTuple in project druid by druid-io.
the class RangePartitionCachingLocalSegmentAllocatorTest method testAllocate.
@SuppressWarnings("SameParameterValue")
private void testAllocate(InputRow row, Interval interval, int bucketId) {
StringTuple partitionEnd = getPartitionEnd(interval, bucketId);
testAllocate(row, interval, bucketId, partitionEnd);
}
use of org.apache.druid.data.input.StringTuple in project druid by druid-io.
the class RangePartitionMultiPhaseParallelIndexingTest method assertValuesInRange.
private static void assertValuesInRange(List<StringTuple> values, DataSegment segment) {
DimensionRangeShardSpec shardSpec = (DimensionRangeShardSpec) segment.getShardSpec();
StringTuple start = shardSpec.getStartTuple();
StringTuple end = shardSpec.getEndTuple();
Assert.assertTrue(shardSpec.toString(), start != null || end != null);
for (StringTuple value : values) {
if (start != null) {
Assert.assertThat(value.compareTo(start), Matchers.greaterThanOrEqualTo(0));
}
if (end != null) {
if (value == null) {
Assert.assertNull("null values should be in first partition", start);
} else {
Assert.assertThat(value.compareTo(end), Matchers.lessThan(0));
}
}
}
}
use of org.apache.druid.data.input.StringTuple in project druid by druid-io.
the class StringSketchMergerTest method mergesCorrectly.
@Test
public void mergesCorrectly() {
StringTuple string1 = StringTuple.create("a");
StringSketch sketch1 = new StringSketch();
sketch1.put(string1);
StringTuple string2 = StringTuple.create("mn");
StringSketch sketch2 = new StringSketch();
sketch2.put(string2);
StringTuple string3 = StringTuple.create("z");
StringSketch sketch3 = new StringSketch();
sketch3.put(string3);
target.merge(sketch2);
target.merge(sketch1);
target.merge(sketch3);
StringDistribution merged = target.getResult();
PartitionBoundaries partitions = merged.getEvenPartitionsByMaxSize(1);
Assert.assertEquals(3, partitions.size());
Assert.assertNull(partitions.get(0));
Assert.assertEquals(string2, partitions.get(1));
Assert.assertNull(partitions.get(2));
}
use of org.apache.druid.data.input.StringTuple in project druid by druid-io.
the class DimensionRangeShardSpecTest method testPossibleInDomain_withNullValues.
@Test
public void testPossibleInDomain_withNullValues() {
setDimensions("planet", "country", "city");
final StringTuple start = StringTuple.create("Earth", "India", "Delhi");
// null in end translates to INF
final StringTuple end = StringTuple.create("Krypton", null, "Kryptonopolis");
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<>();
// (-INF, INF) * (-INF, INF) * (-INF, INF)
populateDomain(domain, universalSet, // EffectiveDomain[:1].size > 1 -> ACCEPT
universalSet, universalSet);
assertTrue(shard.possibleInDomain(domain));
// {Earth} * (-INF, INF) * (-INF, INF)
populateDomain(domain, getRangeSet(Range.singleton("Earth")), // EffectiveDomain[:1] == {start[:1]}
universalSet, // EffectiveDomain[:2].size > 1 -> ACCEPT
universalSet);
assertTrue(shard.possibleInDomain(domain));
// (-INF, Earth) U (Krypton, INF) * (-INF, INF) * (-INF, INF)
populateDomain(domain, getUnion(getRangeSet(Range.lessThan("Earth")), getRangeSet(Range.greaterThan("Krypton"))), // EffectiveDomain[:1] = {} -> PRUNE
universalSet, universalSet);
assertFalse(shard.possibleInDomain(domain));
// (-INF, INF) * (-INF, France) * (-INF, INF)
populateDomain(domain, universalSet, // EffectiveDomain[:1].size > 2 -> ACCEPT
getRangeSet(Range.lessThan("France")), universalSet);
assertTrue(shard.possibleInDomain(domain));
// {Jupiter} * (Foo) * {Bar}
populateDomain(domain, getRangeSet(Range.singleton("Jupiter")), // EffectiveDomain[:1] != {} OR {start[:1]} OR {end[:1]} -> ACCEPT
getRangeSet(Range.singleton("Foo")), getRangeSet(Range.singleton("Bar")));
assertTrue(shard.possibleInDomain(domain));
// {Krypton} * (-INF, France] * {Paris}
populateDomain(domain, getRangeSet(Range.singleton("Krypton")), // EffectiveDomain[:1] == {end[:1]}
getRangeSet(Range.atMost("France")), // EffectiveDomain[:2].size > 1 -> ACCEPT
universalSet);
assertTrue(shard.possibleInDomain(domain));
}
use of org.apache.druid.data.input.StringTuple in project druid by druid-io.
the class DimensionRangeShardSpecTest method testPossibleInDomain_nonNullValues_acceptanceScenarios.
@Test
public void testPossibleInDomain_nonNullValues_acceptanceScenarios() {
setDimensions("planet", "country", "city");
final StringTuple start = StringTuple.create("Earth", "France", "Paris");
final StringTuple end = StringTuple.create("Earth", "USA", "New York");
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<>();
// (-INF, INF) * (-INF, INF) * (-INF, INF)
populateDomain(domain, universalSet, // EffectiveDomain[:1] == {Earth} == {start[:1]} == {end[:1]}
universalSet, // EffectiveDomain[:2].size > 1 -> ACCEPT
universalSet);
assertTrue(shard.possibleInDomain(domain));
// {Earth} * (-INF, INF) * (-INF, INF)
populateDomain(domain, getRangeSet(Range.singleton("Earth")), // EffectiveDomain[:1] == {Earth} == {start[:1]} == {end[:1]}
universalSet, // EffectiveDomain[:2].size > 1 -> ACCEPT
universalSet);
assertTrue(shard.possibleInDomain(domain));
// (-INF, INF) * [USA, INF) * {New York}
populateDomain(domain, universalSet, // EffectiveDomain[:1] == {Earth} == {start[:1]} == {end[:1]}
getRangeSet(Range.atLeast("USA")), // EffectiveDomain[:2] == {end[:2]}
getRangeSet(Range.singleton("New York")));
// EffectiveDomain[:].size > 0 -> ACCEPT
assertTrue(shard.possibleInDomain(domain));
// (-INF, INF) * (-INF, "France"] * (Paris, INF)
populateDomain(domain, universalSet, // EffectiveDomain[:1] == {Earth} == {start[:1]} == {end[:1]}
getRangeSet(Range.atMost("France")), // EffectiveDomain[:2] == {<Earth, France>} == {start[:2]}
getRangeSet(Range.greaterThan("Paris")));
assertTrue(shard.possibleInDomain(domain));
// {Earth} * {India} * Any Non-empty set
populateDomain(domain, getRangeSet(Range.singleton("Earth")), // EffectiveDomain[:1] == {Earth} == {start[:1]} == {end[:1]}
getRangeSet(Range.singleton("India")), // EffectiveDomain[:2] == {<Earth, India>} != {start[:2]} OR {end[:2]}
getRangeSet(Range.greaterThan("New York")));
assertTrue(shard.possibleInDomain(domain));
}
Aggregations