mirror of https://github.com/apache/druid.git
Merge pull request #556 from metamx/versioned-timeline-overshadowed-set
make timeline findOvershadowed a set
This commit is contained in:
commit
19797f56b3
|
@ -21,6 +21,7 @@ package io.druid.timeline;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import com.metamx.common.guava.Comparators;
|
import com.metamx.common.guava.Comparators;
|
||||||
import com.metamx.common.logger.Logger;
|
import com.metamx.common.logger.Logger;
|
||||||
import io.druid.timeline.partition.ImmutablePartitionHolder;
|
import io.druid.timeline.partition.ImmutablePartitionHolder;
|
||||||
|
@ -35,6 +36,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NavigableMap;
|
import java.util.NavigableMap;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
|
@ -191,11 +193,11 @@ public class VersionedIntervalTimeline<VersionType, ObjectType>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TimelineObjectHolder<VersionType, ObjectType>> findOvershadowed()
|
public Set<TimelineObjectHolder<VersionType, ObjectType>> findOvershadowed()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
lock.readLock().lock();
|
lock.readLock().lock();
|
||||||
List<TimelineObjectHolder<VersionType, ObjectType>> retVal = new ArrayList<TimelineObjectHolder<VersionType, ObjectType>>();
|
Set<TimelineObjectHolder<VersionType, ObjectType>> retVal = Sets.newHashSet();
|
||||||
|
|
||||||
Map<Interval, Map<VersionType, TimelineEntry>> overShadowed = Maps.newHashMap();
|
Map<Interval, Map<VersionType, TimelineEntry>> overShadowed = Maps.newHashMap();
|
||||||
for (Map.Entry<Interval, TreeMap<VersionType, TimelineEntry>> versionEntry : allTimelineEntries.entrySet()) {
|
for (Map.Entry<Interval, TreeMap<VersionType, TimelineEntry>> versionEntry : allTimelineEntries.entrySet()) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ package io.druid.timeline;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -351,7 +352,7 @@ public class VersionedIntervalTimelineTest
|
||||||
|
|
||||||
add("2011-10-05/2011-10-07", "6", IntegerPartitionChunk.make(20, null, 2, 62));
|
add("2011-10-05/2011-10-07", "6", IntegerPartitionChunk.make(20, null, 2, 62));
|
||||||
assertValues(
|
assertValues(
|
||||||
ImmutableList.of(
|
ImmutableSet.of(
|
||||||
createExpected("2011-10-05/2011-10-06", "5", 5)
|
createExpected("2011-10-05/2011-10-06", "5", 5)
|
||||||
),
|
),
|
||||||
timeline.findOvershadowed()
|
timeline.findOvershadowed()
|
||||||
|
@ -1114,7 +1115,7 @@ public class VersionedIntervalTimelineTest
|
||||||
createExpected("2011-01-03/2011-01-06", "1", 1),
|
createExpected("2011-01-03/2011-01-06", "1", 1),
|
||||||
createExpected("2011-01-09/2011-01-12", "1", 2)
|
createExpected("2011-01-09/2011-01-12", "1", 2)
|
||||||
),
|
),
|
||||||
Sets.newHashSet(timeline.findOvershadowed())
|
timeline.findOvershadowed()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1137,7 +1138,7 @@ public class VersionedIntervalTimelineTest
|
||||||
createExpected("2011-01-05/2011-01-10", "2", 2),
|
createExpected("2011-01-05/2011-01-10", "2", 2),
|
||||||
createExpected("2011-01-01/2011-01-10", "1", 3)
|
createExpected("2011-01-01/2011-01-10", "1", 3)
|
||||||
),
|
),
|
||||||
Sets.newHashSet(timeline.findOvershadowed())
|
timeline.findOvershadowed()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1159,7 +1160,7 @@ public class VersionedIntervalTimelineTest
|
||||||
createExpected("2011-01-03/2011-01-12", "1", 3),
|
createExpected("2011-01-03/2011-01-12", "1", 3),
|
||||||
createExpected("2011-01-01/2011-01-05", "2", 1)
|
createExpected("2011-01-01/2011-01-05", "2", 1)
|
||||||
),
|
),
|
||||||
Sets.newHashSet(timeline.findOvershadowed())
|
timeline.findOvershadowed()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1308,7 +1309,7 @@ public class VersionedIntervalTimelineTest
|
||||||
add("2011-04-01/2011-04-09", "2", 1);
|
add("2011-04-01/2011-04-09", "2", 1);
|
||||||
|
|
||||||
assertValues(
|
assertValues(
|
||||||
Arrays.asList(
|
ImmutableSet.of(
|
||||||
createExpected("2011-04-01/2011-04-03", "1", 2),
|
createExpected("2011-04-01/2011-04-03", "1", 2),
|
||||||
createExpected("2011-04-03/2011-04-06", "1", 3),
|
createExpected("2011-04-03/2011-04-06", "1", 3),
|
||||||
createExpected("2011-04-06/2011-04-09", "1", 4)
|
createExpected("2011-04-06/2011-04-09", "1", 4)
|
||||||
|
@ -1328,7 +1329,7 @@ public class VersionedIntervalTimelineTest
|
||||||
add("2011-04-06/2011-04-09", "2", 4);
|
add("2011-04-06/2011-04-09", "2", 4);
|
||||||
|
|
||||||
assertValues(
|
assertValues(
|
||||||
Arrays.asList(
|
ImmutableSet.of(
|
||||||
createExpected("2011-04-01/2011-04-09", "1", 1)
|
createExpected("2011-04-01/2011-04-09", "1", 1)
|
||||||
),
|
),
|
||||||
timeline.findOvershadowed()
|
timeline.findOvershadowed()
|
||||||
|
@ -1351,7 +1352,7 @@ public class VersionedIntervalTimelineTest
|
||||||
createExpected("2011-04-03/2011-04-06", "1", 3),
|
createExpected("2011-04-03/2011-04-06", "1", 3),
|
||||||
createExpected("2011-04-09/2011-04-12", "1", 4)
|
createExpected("2011-04-09/2011-04-12", "1", 4)
|
||||||
),
|
),
|
||||||
Sets.newHashSet(timeline.findOvershadowed())
|
timeline.findOvershadowed()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1365,7 +1366,7 @@ public class VersionedIntervalTimelineTest
|
||||||
add("2011-04-01/2011-04-09", "2", 1);
|
add("2011-04-01/2011-04-09", "2", 1);
|
||||||
|
|
||||||
assertValues(
|
assertValues(
|
||||||
Arrays.asList(
|
ImmutableSet.of(
|
||||||
createExpected("2011-04-03/2011-04-06", "1", 3),
|
createExpected("2011-04-03/2011-04-06", "1", 3),
|
||||||
createExpected("2011-04-06/2011-04-09", "1", 4)
|
createExpected("2011-04-06/2011-04-09", "1", 4)
|
||||||
),
|
),
|
||||||
|
@ -1383,7 +1384,7 @@ public class VersionedIntervalTimelineTest
|
||||||
add("2011-04-06/2011-04-09", "2", 4);
|
add("2011-04-06/2011-04-09", "2", 4);
|
||||||
|
|
||||||
assertValues(
|
assertValues(
|
||||||
Arrays.<Pair<Interval, Pair<String, PartitionHolder<Integer>>>>asList(),
|
ImmutableSet.<Pair<Interval, Pair<String, PartitionHolder<Integer>>>>of(),
|
||||||
timeline.findOvershadowed()
|
timeline.findOvershadowed()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1398,7 +1399,7 @@ public class VersionedIntervalTimelineTest
|
||||||
add("2011-04-06/2011-04-09", "2", 4);
|
add("2011-04-06/2011-04-09", "2", 4);
|
||||||
|
|
||||||
assertValues(
|
assertValues(
|
||||||
Arrays.<Pair<Interval, Pair<String, PartitionHolder<Integer>>>>asList(),
|
ImmutableSet.<Pair<Interval, Pair<String, PartitionHolder<Integer>>>>of(),
|
||||||
timeline.findOvershadowed()
|
timeline.findOvershadowed()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1413,7 +1414,7 @@ public class VersionedIntervalTimelineTest
|
||||||
add("2011-04-03/2011-04-06", "2", 3);
|
add("2011-04-03/2011-04-06", "2", 3);
|
||||||
|
|
||||||
assertValues(
|
assertValues(
|
||||||
Arrays.<Pair<Interval, Pair<String, PartitionHolder<Integer>>>>asList(),
|
ImmutableSet.<Pair<Interval, Pair<String, PartitionHolder<Integer>>>>of(),
|
||||||
timeline.findOvershadowed()
|
timeline.findOvershadowed()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1429,7 +1430,7 @@ public class VersionedIntervalTimelineTest
|
||||||
add("2011-04-03/2011-04-06", "1", 3);
|
add("2011-04-03/2011-04-06", "1", 3);
|
||||||
|
|
||||||
assertValues(
|
assertValues(
|
||||||
Arrays.asList(
|
ImmutableSet.of(
|
||||||
createExpected("2011-04-03/2011-04-06", "1", 3)
|
createExpected("2011-04-03/2011-04-06", "1", 3)
|
||||||
),
|
),
|
||||||
timeline.findOvershadowed()
|
timeline.findOvershadowed()
|
||||||
|
@ -1452,7 +1453,7 @@ public class VersionedIntervalTimelineTest
|
||||||
createExpected("2011-04-03/2011-04-06", "1", 3),
|
createExpected("2011-04-03/2011-04-06", "1", 3),
|
||||||
createExpected("2011-04-09/2011-04-12", "1", 3)
|
createExpected("2011-04-09/2011-04-12", "1", 3)
|
||||||
),
|
),
|
||||||
Sets.newHashSet(timeline.findOvershadowed())
|
timeline.findOvershadowed()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1470,7 +1471,7 @@ public class VersionedIntervalTimelineTest
|
||||||
createExpected("2011-04-01/2011-04-09", "2", 3),
|
createExpected("2011-04-01/2011-04-09", "2", 3),
|
||||||
createExpected("2011-04-01/2011-04-09", "1", 1)
|
createExpected("2011-04-01/2011-04-09", "1", 1)
|
||||||
),
|
),
|
||||||
Sets.newHashSet(timeline.findOvershadowed())
|
timeline.findOvershadowed()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1489,7 +1490,7 @@ public class VersionedIntervalTimelineTest
|
||||||
createExpected("2011-04-01/2011-04-09", "2", 3),
|
createExpected("2011-04-01/2011-04-09", "2", 3),
|
||||||
createExpected("2011-04-01/2011-04-09", "1", 1)
|
createExpected("2011-04-01/2011-04-09", "1", 1)
|
||||||
),
|
),
|
||||||
Sets.newHashSet(timeline.findOvershadowed())
|
timeline.findOvershadowed()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue