pirvtech commented on code in PR #19138:
URL: https://github.com/apache/druid/pull/19138#discussion_r3075350442
##########
processing/src/main/java/org/apache/druid/timeline/VersionedIntervalTimeline.java:
##########
@@ -74,28 +75,77 @@
public class VersionedIntervalTimeline<VersionType, ObjectType extends
Overshadowable<ObjectType>>
implements TimelineLookup<VersionType, ObjectType>
{
+ private static final Logger logger = new
Logger(VersionedIntervalTimeline.class);
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
// Below timelines stores only *visible* timelineEntries
// adjusted interval -> timelineEntry
- private final NavigableMap<Interval, TimelineEntry>
completePartitionsTimeline = new TreeMap<>(
- Comparators.intervalsByStartThenEnd()
- );
+ private final NavigableMap<Interval, TimelineEntry>
completePartitionsTimeline;
// IncompletePartitionsTimeline also includes completePartitionsTimeline
// adjusted interval -> timelineEntry
@VisibleForTesting
- final NavigableMap<Interval, TimelineEntry> incompletePartitionsTimeline =
new TreeMap<>(
- Comparators.intervalsByStartThenEnd()
- );
+ final NavigableMap<Interval, TimelineEntry> incompletePartitionsTimeline;
// true interval -> version -> timelineEntry
private final Map<Interval, TreeMap<VersionType, TimelineEntry>>
allTimelineEntries = new HashMap<>();
+ private final IntervalTree<TreeMap<VersionType, TimelineEntry>>
allTimeIntervals = new IntervalTree<>(Comparators.intervalsByStart(),
Comparators.intervalsByEnd());
private final AtomicInteger numObjects = new AtomicInteger();
private final Comparator<? super VersionType> versionComparator;
// Set this to true if the client needs to skip tombstones upon lookup (like
the broker)
private final boolean skipObjectsWithNoData;
+ // 0 Legacy functionality
+ // 1 Use IntervalTree only for basic segment timeline
+ // 2 Use IntervalTree for querying segments as well
+ private enum IntervalTreeMatchMode
+ {
+ NONE,
+ ENTRIES_ONLY(Capability.ENTRIES),
+ ALL(Capability.ENTRIES, Capability.QUERY);
+
+ private enum Capability
+ {
+ ENTRIES, QUERY
+ }
+
+ final Set<Capability> capabilities;
+
+ IntervalTreeMatchMode(Capability... capabilities)
+ {
+ this.capabilities = Set.of(capabilities);
+ }
+
+ public boolean isEnabled(Capability capability)
+ {
+ return capabilities.contains(capability);
+ }
+ }
+
+ private static IntervalTreeMatchMode intervalTreeMatchMode =
IntervalTreeMatchMode.NONE;
+
+ static {
+ String mode =
System.getProperty("experimental.timeline.intervalTreeMatchMode");
Review Comment:
Agree. The mode was more for easing in this feature into the production
deployment with ability to fall back in case things didn't work out as planned.
A single binary feature flag maybe sufficient and coming from a configuration
like you suggested. I will make the change.
--
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]