@Override public List<DataSegment> next() { if (!hasNext()) { throw new NoSuchElementException(); } final QueueEntry entry = queue.poll(); if (entry == null) { throw new NoSuchElementException(); } final List<DataSegment> resultSegments = entry.segments; Preconditions.checkState(!resultSegments.isEmpty(), "Queue entry must not be empty"); final String dataSource = resultSegments.get(0).getDataSource(); updateQueue(dataSource, compactionConfigs.get(dataSource)); return resultSegments; }
NewestSegmentFirstIterator( Map<String, DataSourceCompactionConfig> compactionConfigs, Map<String, VersionedIntervalTimeline<String, DataSegment>> dataSources, Map<String, List<Interval>> skipIntervals ) { this.compactionConfigs = compactionConfigs; this.dataSources = dataSources; this.timelineIterators = new HashMap<>(dataSources.size()); for (Entry<String, VersionedIntervalTimeline<String, DataSegment>> entry : dataSources.entrySet()) { final String dataSource = entry.getKey(); final VersionedIntervalTimeline<String, DataSegment> timeline = entry.getValue(); final DataSourceCompactionConfig config = compactionConfigs.get(dataSource); if (config != null && !timeline.isEmpty()) { final List<Interval> searchIntervals = findInitialSearchInterval(timeline, config.getSkipOffsetFromLatest(), skipIntervals.get(dataSource)); if (!searchIntervals.isEmpty()) { timelineIterators.put(dataSource, new CompactibleTimelineObjectHolderCursor(timeline, searchIntervals)); } } } for (Entry<String, DataSourceCompactionConfig> entry : compactionConfigs.entrySet()) { final String dataSourceName = entry.getKey(); final DataSourceCompactionConfig config = entry.getValue(); if (config == null) { throw new ISE("Unknown dataSource[%s]", dataSourceName); } updateQueue(dataSourceName, config); } }
@Override public List<DataSegment> next() { if (!hasNext()) { throw new NoSuchElementException(); } final QueueEntry entry = queue.poll(); if (entry == null) { throw new NoSuchElementException(); } final List<DataSegment> resultSegments = entry.segments; Preconditions.checkState(!resultSegments.isEmpty(), "Queue entry must not be empty"); final String dataSource = resultSegments.get(0).getDataSource(); updateQueue(dataSource, compactionConfigs.get(dataSource)); return resultSegments; }
NewestSegmentFirstIterator( Map<String, DataSourceCompactionConfig> compactionConfigs, Map<String, VersionedIntervalTimeline<String, DataSegment>> dataSources ) { this.compactionConfigs = compactionConfigs; this.dataSources = dataSources; this.timelineIterators = new HashMap<>(dataSources.size()); for (Entry<String, VersionedIntervalTimeline<String, DataSegment>> entry : dataSources.entrySet()) { final String dataSource = entry.getKey(); final VersionedIntervalTimeline<String, DataSegment> timeline = entry.getValue(); final DataSourceCompactionConfig config = compactionConfigs.get(dataSource); if (config != null && !timeline.isEmpty()) { final Interval searchInterval = findInitialSearchInterval(timeline, config.getSkipOffsetFromLatest()); timelineIterators.put(dataSource, new CompactibleTimelineObjectHolderCursor(timeline, searchInterval)); } } for (Entry<String, DataSourceCompactionConfig> entry : compactionConfigs.entrySet()) { final String dataSourceName = entry.getKey(); final DataSourceCompactionConfig config = entry.getValue(); if (config == null) { throw new ISE("Unknown dataSource[%s]", dataSourceName); } updateQueue(dataSourceName, config); } }