Search in sources :

Example 1 with OvershadowableInteger

use of org.apache.druid.timeline.partition.OvershadowableInteger in project druid by druid-io.

the class VersionedIntervalTimelineSpecificDataTest method testPartialPartitionNotReturned.

@Test
public void testPartialPartitionNotReturned() {
    testRemove();
    add("2011-10-06/2011-10-07", "6", IntegerPartitionChunk.make(null, 10, 0, new OvershadowableInteger("6", 0, 60)));
    assertValues(ImmutableList.of(createExpected("2011-10-05/2011-10-06", "5", 5)), timeline.lookup(Intervals.of("2011-10-05/2011-10-07")));
    Assert.assertTrue("Expected no overshadowed entries", timeline.findFullyOvershadowed().isEmpty());
    add("2011-10-06/2011-10-07", "6", IntegerPartitionChunk.make(10, 20, 1, new OvershadowableInteger("6", 1, 61)));
    assertValues(ImmutableList.of(createExpected("2011-10-05/2011-10-06", "5", 5)), timeline.lookup(Intervals.of("2011-10-05/2011-10-07")));
    Assert.assertTrue("Expected no overshadowed entries", timeline.findFullyOvershadowed().isEmpty());
    add("2011-10-06/2011-10-07", "6", IntegerPartitionChunk.make(20, null, 2, new OvershadowableInteger("6", 2, 62)));
    assertValues(ImmutableList.of(createExpected("2011-10-05/2011-10-06", "5", 5), createExpected("2011-10-06/2011-10-07", "6", Arrays.asList(IntegerPartitionChunk.make(null, 10, 0, new OvershadowableInteger("6", 0, 60)), IntegerPartitionChunk.make(10, 20, 1, new OvershadowableInteger("6", 1, 61)), IntegerPartitionChunk.make(20, null, 2, new OvershadowableInteger("6", 2, 62))))), timeline.lookup(Intervals.of("2011-10-05/2011-10-07")));
    Assert.assertTrue("Expected no overshadowed entries", timeline.findFullyOvershadowed().isEmpty());
}
Also used : OvershadowableInteger(org.apache.druid.timeline.partition.OvershadowableInteger) Test(org.junit.Test)

Example 2 with OvershadowableInteger

use of org.apache.druid.timeline.partition.OvershadowableInteger in project druid by druid-io.

the class VersionedIntervalTimelineSpecificDataTest method testFindChunk.

@Test
public void testFindChunk() {
    assertSingleElementChunks(makeSingle("1", 1), timeline.findChunk(Intervals.of("2011-10-01/2011-10-02"), "1", 0));
    assertSingleElementChunks(makeSingle("1", 1), timeline.findChunk(Intervals.of("2011-10-01/2011-10-01T10"), "1", 0));
    assertSingleElementChunks(makeSingle("1", 1), timeline.findChunk(Intervals.of("2011-10-01T02/2011-10-02"), "1", 0));
    assertSingleElementChunks(makeSingle("1", 1), timeline.findChunk(Intervals.of("2011-10-01T04/2011-10-01T17"), "1", 0));
    IntegerPartitionChunk<OvershadowableInteger> expected = IntegerPartitionChunk.make(10, null, 1, new OvershadowableInteger("3", 1, 21));
    IntegerPartitionChunk<OvershadowableInteger> actual = (IntegerPartitionChunk<OvershadowableInteger>) timeline.findChunk(Intervals.of("2011-10-02/2011-10-03"), "3", 1);
    Assert.assertEquals(expected, actual);
    Assert.assertEquals(expected.getObject(), actual.getObject());
    Assert.assertEquals(null, timeline.findChunk(Intervals.of("2011-10-01T04/2011-10-01T17"), "1", 1));
    Assert.assertEquals(null, timeline.findChunk(Intervals.of("2011-10-01T04/2011-10-01T17"), "2", 0));
    Assert.assertEquals(null, timeline.findChunk(Intervals.of("2011-10-01T04/2011-10-02T17"), "1", 0));
    Assert.assertEquals(null, timeline.findChunk(Intervals.of("2011-10-01T04/2011-10-02T17"), "1", 0));
}
Also used : IntegerPartitionChunk(org.apache.druid.timeline.partition.IntegerPartitionChunk) OvershadowableInteger(org.apache.druid.timeline.partition.OvershadowableInteger) Test(org.junit.Test)

Example 3 with OvershadowableInteger

use of org.apache.druid.timeline.partition.OvershadowableInteger in project druid by druid-io.

the class VersionedIntervalTimelineSpecificDataTest method testRemovePartitionMakesIncomplete.

@Test
public void testRemovePartitionMakesIncomplete() {
    testIncompletePartitionDoesNotOvershadow();
    final IntegerPartitionChunk<OvershadowableInteger> chunk = IntegerPartitionChunk.make(null, 10, 0, new OvershadowableInteger("6", 0, 60));
    Assert.assertEquals(chunk, timeline.remove(Intervals.of("2011-10-05/2011-10-07"), "6", chunk));
    assertValues(ImmutableList.of(createExpected("2011-10-05/2011-10-06", "5", 5)), timeline.lookup(Intervals.of("2011-10-05/2011-10-07")));
    Assert.assertTrue("Expected no overshadowed entries", timeline.findFullyOvershadowed().isEmpty());
}
Also used : OvershadowableInteger(org.apache.druid.timeline.partition.OvershadowableInteger) Test(org.junit.Test)

Example 4 with OvershadowableInteger

use of org.apache.druid.timeline.partition.OvershadowableInteger in project druid by druid-io.

the class VersionedIntervalTimelineTestBase method assertValues.

static void assertValues(List<Pair<Interval, Pair<String, PartitionHolder<OvershadowableInteger>>>> expected, List<TimelineObjectHolder<String, OvershadowableInteger>> actual) {
    Assert.assertEquals("Sizes did not match.", expected.size(), actual.size());
    Iterator<Pair<Interval, Pair<String, PartitionHolder<OvershadowableInteger>>>> expectedIter = expected.iterator();
    Iterator<TimelineObjectHolder<String, OvershadowableInteger>> actualIter = actual.iterator();
    while (expectedIter.hasNext()) {
        Pair<Interval, Pair<String, PartitionHolder<OvershadowableInteger>>> pair = expectedIter.next();
        TimelineObjectHolder<String, OvershadowableInteger> holder = actualIter.next();
        Assert.assertEquals(pair.lhs, holder.getInterval());
        Assert.assertEquals(pair.rhs.lhs, holder.getVersion());
        final List<PartitionChunk<OvershadowableInteger>> expectedChunks = Lists.newArrayList(pair.rhs.rhs);
        final List<PartitionChunk<OvershadowableInteger>> actualChunks = Lists.newArrayList(holder.getObject());
        Assert.assertEquals(expectedChunks.size(), actualChunks.size());
        for (int i = 0; i < expectedChunks.size(); i++) {
            // Check partitionNumber first
            Assert.assertEquals(expectedChunks.get(i), actualChunks.get(i));
            final OvershadowableInteger expectedInteger = expectedChunks.get(i).getObject();
            final OvershadowableInteger actualInteger = actualChunks.get(i).getObject();
            Assert.assertEquals(expectedInteger, actualInteger);
        }
    }
}
Also used : PartitionHolder(org.apache.druid.timeline.partition.PartitionHolder) OvershadowableInteger(org.apache.druid.timeline.partition.OvershadowableInteger) NumberedPartitionChunk(org.apache.druid.timeline.partition.NumberedPartitionChunk) SingleElementPartitionChunk(org.apache.druid.timeline.partition.SingleElementPartitionChunk) PartitionChunk(org.apache.druid.timeline.partition.PartitionChunk) NumberedOverwritingPartitionChunk(org.apache.druid.timeline.partition.NumberedOverwritingPartitionChunk) Pair(org.apache.druid.java.util.common.Pair) Interval(org.joda.time.Interval)

Example 5 with OvershadowableInteger

use of org.apache.druid.timeline.partition.OvershadowableInteger in project druid by druid-io.

the class VersionedIntervalTimelineTest method testRemoveIncompleteKeepsComplete.

/**
 * https://github.com/apache/druid/issues/3010
 */
@Test
public void testRemoveIncompleteKeepsComplete() {
    add("2011-04-01/2011-04-02", "1", IntegerPartitionChunk.make(null, 1, 0, new OvershadowableInteger("1", 0, 77)));
    add("2011-04-01/2011-04-02", "1", IntegerPartitionChunk.make(1, null, 1, new OvershadowableInteger("1", 1, 88)));
    add("2011-04-01/2011-04-02", "2", IntegerPartitionChunk.make(null, 1, 0, new OvershadowableInteger("2", 0, 99)));
    assertValues(ImmutableList.of(createExpected("2011-04-01/2011-04-02", "1", Arrays.asList(IntegerPartitionChunk.make(null, 1, 0, new OvershadowableInteger("1", 0, 77)), IntegerPartitionChunk.make(1, null, 1, new OvershadowableInteger("1", 1, 88))))), timeline.lookup(Intervals.of("2011-04-01/2011-04-02")));
    add("2011-04-01/2011-04-02", "3", IntegerPartitionChunk.make(null, 1, 0, new OvershadowableInteger("3", 0, 110)));
    assertValues(ImmutableList.of(createExpected("2011-04-01/2011-04-02", "1", Arrays.asList(IntegerPartitionChunk.make(null, 1, 0, new OvershadowableInteger("1", 0, 77)), IntegerPartitionChunk.make(1, null, 1, new OvershadowableInteger("1", 1, 88))))), timeline.lookup(Intervals.of("2011-04-01/2011-04-02")));
    assertValues(Sets.newHashSet(createExpected("2011-04-01/2011-04-02", "2", Collections.singletonList(IntegerPartitionChunk.make(null, 1, 0, new OvershadowableInteger("2", 0, 99))))), timeline.findFullyOvershadowed());
    checkRemove();
    assertValues(ImmutableList.of(createExpected("2011-04-01/2011-04-02", "1", Arrays.asList(IntegerPartitionChunk.make(null, 1, 0, new OvershadowableInteger("1", 0, 77)), IntegerPartitionChunk.make(1, null, 1, new OvershadowableInteger("1", 1, 88))))), timeline.lookup(Intervals.of("2011-04-01/2011-04-02")));
}
Also used : OvershadowableInteger(org.apache.druid.timeline.partition.OvershadowableInteger) Test(org.junit.Test)

Aggregations

OvershadowableInteger (org.apache.druid.timeline.partition.OvershadowableInteger)5 Test (org.junit.Test)4 Pair (org.apache.druid.java.util.common.Pair)1 IntegerPartitionChunk (org.apache.druid.timeline.partition.IntegerPartitionChunk)1 NumberedOverwritingPartitionChunk (org.apache.druid.timeline.partition.NumberedOverwritingPartitionChunk)1 NumberedPartitionChunk (org.apache.druid.timeline.partition.NumberedPartitionChunk)1 PartitionChunk (org.apache.druid.timeline.partition.PartitionChunk)1 PartitionHolder (org.apache.druid.timeline.partition.PartitionHolder)1 SingleElementPartitionChunk (org.apache.druid.timeline.partition.SingleElementPartitionChunk)1 Interval (org.joda.time.Interval)1