@a2l007 I see. It sounds a good idea. 

One thing I would like to note is `TimelineLookup` (especially 
`VersionedIntervalTimeline`) is designed to represent a timeline of segments of 
a single dataSource. It is responsible for checking the overshadowing relation 
among segments and returning only _queryable_ segments. Since the overshadowing 
relation is checked by comparing the `version` of segments of the same 
`interval` and the same `dataSource`, I would say supporting multiple 
dataSources for `VersionedIntervalTimeline` might make it too complicated. 

How about doing [this 
part](https://github.com/apache/incubator-druid/blob/master/server/src/main/java/org/apache/druid/client/CachingClusteredClient.java#L256-L279)
 for all dataSources of the unionQuery in a loop and returning a single 
`LazySequence` backed by the sequences for all dataSources? For example,

```java
    Sequence<T> run(final UnaryOperator<TimelineLookup<String, ServerSelector>> 
timelineConverter)
    {
      final List<Sequence<T>> sequencesByInterval = new ArrayList<>();
      if (query.getDataSource() instanceof UnionDataSource) {
        for (String eachDataSource : ((UnionDataSource) 
dataSource).getDataSources()) {
          @Nullable
          TimelineLookup<String, ServerSelector> timeline = 
serverView.getTimeline(eachDataSource);

          // fill alreadyCachedResults and segmentsByServer
        }

        return new LazySequence<>(() -> {
          addSequencesFromCache(sequencesByInterval, alreadyCachedResults);
          addSequencesFromServer(sequencesByInterval, segmentsByServer);
          return Sequences
              .simple(sequencesByInterval)
              .flatMerge(seq -> seq, query.getResultOrdering());
        });
      } else {
        // same as it is
      }
```

[ Full content available at: 
https://github.com/apache/incubator-druid/issues/6057 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to