abhishekagarwal87 commented on code in PR #14985:
URL: https://github.com/apache/druid/pull/14985#discussion_r1332609473


##########
server/src/main/java/org/apache/druid/client/QueryableCoordinatorServerView.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.client;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import org.apache.druid.client.selector.ServerSelector;
+import org.apache.druid.client.selector.TierSelectorStrategy;
+import org.apache.druid.guice.ManageLifecycle;
+import org.apache.druid.guice.annotations.EscalatedClient;
+import org.apache.druid.guice.annotations.Smile;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.http.client.HttpClient;
+import org.apache.druid.query.DataSource;
+import org.apache.druid.query.QueryToolChestWarehouse;
+import org.apache.druid.query.QueryWatcher;
+import org.apache.druid.timeline.DataSegment;
+import org.apache.druid.timeline.SegmentId;
+import org.apache.druid.timeline.VersionedIntervalTimeline;
+import org.apache.druid.utils.CollectionUtils;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Map;
+
+/**
+ * ServerView of coordinator for the state of segments being loaded in the 
cluster.
+ *
+ * <p>This class extends {@link BrokerServerView} and implements {@link 
CoordinatorTimeline}.
+ * The main distinction between this class and {@link CoordinatorServerView} 
is the maintenance of a timeline
+ * of {@link ServerSelector} objects, while the other class stores {@link 
SegmentLoadInfo} object in its timeline.</p>
+ *
+ * <p>A new timeline class (implementing {@link TimelineServerView}) is 
required for
+ * {@link org.apache.druid.segment.metadata.CoordinatorSegmentMetadataCache}, 
which will run on the Coordinator.</p>
+ */
+@ManageLifecycle
+public class QueryableCoordinatorServerView extends BrokerServerView 
implements CoordinatorTimeline
+{
+  private final FilteredServerInventoryView baseView;
+
+  @Inject
+  public QueryableCoordinatorServerView(
+      final QueryToolChestWarehouse warehouse,
+      final QueryWatcher queryWatcher,
+      final @Smile ObjectMapper smileMapper,
+      final @EscalatedClient HttpClient httpClient,
+      FilteredServerInventoryView baseView,
+      TierSelectorStrategy tierSelectorStrategy,
+      ServiceEmitter emitter,
+      CoordinatorSegmentWatcherConfig segmentWatcherConfig
+  )
+  {
+    super(warehouse, queryWatcher, smileMapper, httpClient, baseView, 
tierSelectorStrategy, emitter, new BrokerSegmentWatcherConfig() {
+      @Override
+      public boolean isAwaitInitializationOnStart()
+      {
+        return segmentWatcherConfig.isAwaitInitializationOnStart();
+      }
+    });
+    this.baseView = baseView;
+  }
+
+  /**
+   * Since this class maintains a timeline of {@link ServerSelector} objects,
+   * this method converts and returns a new timeline of the object {@link 
SegmentLoadInfo}.
+   *
+   * @param dataSource dataSoruce
+   * @return timeline for the given dataSource
+   */
+  @Override
+  public VersionedIntervalTimeline<String, SegmentLoadInfo> 
getTimeline(DataSource dataSource)
+  {
+    String table = Iterables.getOnlyElement(dataSource.getTableNames());
+    VersionedIntervalTimeline<String, ServerSelector> timeline;
+
+    synchronized (lock) {
+      timeline = timelines.get(table);
+    }
+
+    VersionedIntervalTimeline<String, SegmentLoadInfo> newTimeline =
+        new VersionedIntervalTimeline<>(Comparator.naturalOrder());
+    newTimeline.addAll(
+        timeline.iterateAllObjects().stream()
+                .map(serverSelector -> new 
VersionedIntervalTimeline.PartitionChunkEntry<>(
+                    serverSelector.getSegment().getInterval(),
+                    serverSelector.getSegment().getVersion(),
+                    
serverSelector.getSegment().getShardSpec().createChunk(serverSelector.toSegmentLoadInfo())
+                )).iterator());

Review Comment:
   How frequently is getTimeline called? Timeline can be big. Copying it is 
expensive and it takes extra memory too. 



##########
server/src/main/java/org/apache/druid/client/CoordinatorTimeline.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.client;
+
+import org.apache.druid.query.DataSource;
+import org.apache.druid.timeline.SegmentId;
+import org.apache.druid.timeline.VersionedIntervalTimeline;
+
+import java.util.Map;
+
+/**
+ * Segment timeline maintained in the coordinator.

Review Comment:
   can you add a note why one would write different implementations of this 
interface? 



##########
extensions-core/druid-bloom-filter/src/test/java/org/apache/druid/query/aggregation/bloom/sql/BloomFilterSqlAggregatorTest.java:
##########
@@ -47,10 +47,10 @@
 import org.apache.druid.segment.join.JoinableFactoryWrapper;
 import org.apache.druid.segment.virtual.ExpressionVirtualColumn;
 import 
org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory;
+import org.apache.druid.server.SpecificSegmentsQuerySegmentWalker;
 import org.apache.druid.sql.calcite.BaseCalciteQueryTest;
 import org.apache.druid.sql.calcite.filtration.Filtration;
 import org.apache.druid.sql.calcite.util.CalciteTests;
-import org.apache.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker;

Review Comment:
   what was the reason to move this class? 



##########
server/src/main/java/org/apache/druid/client/QueryableCoordinatorServerView.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.client;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import org.apache.druid.client.selector.ServerSelector;
+import org.apache.druid.client.selector.TierSelectorStrategy;
+import org.apache.druid.guice.ManageLifecycle;
+import org.apache.druid.guice.annotations.EscalatedClient;
+import org.apache.druid.guice.annotations.Smile;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.http.client.HttpClient;
+import org.apache.druid.query.DataSource;
+import org.apache.druid.query.QueryToolChestWarehouse;
+import org.apache.druid.query.QueryWatcher;
+import org.apache.druid.timeline.DataSegment;
+import org.apache.druid.timeline.SegmentId;
+import org.apache.druid.timeline.VersionedIntervalTimeline;
+import org.apache.druid.utils.CollectionUtils;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Map;
+
+/**
+ * ServerView of coordinator for the state of segments being loaded in the 
cluster.
+ *
+ * <p>This class extends {@link BrokerServerView} and implements {@link 
CoordinatorTimeline}.
+ * The main distinction between this class and {@link CoordinatorServerView} 
is the maintenance of a timeline
+ * of {@link ServerSelector} objects, while the other class stores {@link 
SegmentLoadInfo} object in its timeline.</p>
+ *
+ * <p>A new timeline class (implementing {@link TimelineServerView}) is 
required for
+ * {@link org.apache.druid.segment.metadata.CoordinatorSegmentMetadataCache}, 
which will run on the Coordinator.</p>
+ */
+@ManageLifecycle
+public class QueryableCoordinatorServerView extends BrokerServerView 
implements CoordinatorTimeline
+{
+  private final FilteredServerInventoryView baseView;
+
+  @Inject
+  public QueryableCoordinatorServerView(
+      final QueryToolChestWarehouse warehouse,

Review Comment:
   why are some parameters final and some are not? 



##########
server/src/main/java/org/apache/druid/segment/metadata/DataSourceInformation.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.metadata;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.segment.column.RowSignature;
+
+import java.util.Objects;
+
+/**
+ * Encapsulates information about a datasource, such as its schema.
+ */
+public class DataSourceInformation

Review Comment:
   how about DataSourceSchema? Is that too specific? 



##########
server/src/main/java/org/apache/druid/segment/metadata/CoordinatorSegmentMetadataCache.java:
##########
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.metadata;
+
+import com.google.common.collect.Sets;
+import com.google.inject.Inject;
+import org.apache.druid.client.InternalQueryConfig;
+import org.apache.druid.client.TimelineServerView;
+import org.apache.druid.guice.ManageLifecycle;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.segment.column.RowSignature;
+import org.apache.druid.server.QueryLifecycleFactory;
+import org.apache.druid.server.security.Escalator;
+import org.apache.druid.timeline.SegmentId;
+
+import java.io.IOException;
+import java.util.Set;
+
+/**
+ * Coordinator-side cache of segment metadata that combines segments to 
identify

Review Comment:
   what does identifying datasource mean? 



-- 
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]

Reply via email to