jihoonson commented on a change in pull request #6094: Introduce SystemSchema 
tables (#5989)
URL: https://github.com/apache/incubator-druid/pull/6094#discussion_r223203041
 
 

 ##########
 File path: 
sql/src/main/java/org/apache/druid/sql/calcite/schema/DruidSchema.java
 ##########
 @@ -320,25 +322,32 @@ public void awaitInitialization() throws 
InterruptedException
   private void addSegment(final DruidServerMetadata server, final DataSegment 
segment)
   {
     synchronized (lock) {
-      final Map<DataSegment, RowSignature> knownSegments = 
segmentSignatures.get(segment.getDataSource());
+      final Map<DataSegment, SegmentMetadataHolder> knownSegments = 
segmentMetadataInfo.get(segment.getDataSource());
       if (knownSegments == null || !knownSegments.containsKey(segment)) {
+        final long isRealtime = server.segmentReplicatable() ? 0 : 1;
+        final long isPublished = 
server.getType().toString().equals(ServerType.HISTORICAL.toString()) ? 1 : 0;
+        SegmentMetadataHolder holder = new SegmentMetadataHolder(null, 
isPublished, 1, isRealtime, 1, null);
         // Unknown segment.
-        setSegmentSignature(segment, null);
+        setSegmentSignature(segment, holder);
         segmentsNeedingRefresh.add(segment);
-
         if (!server.segmentReplicatable()) {
           log.debug("Added new mutable segment[%s].", segment.getIdentifier());
           mutableSegments.add(segment);
         } else {
           log.debug("Added new immutable segment[%s].", 
segment.getIdentifier());
         }
-      } else if (server.segmentReplicatable()) {
-        // If a segment shows up on a replicatable (historical) server at any 
point, then it must be immutable,
-        // even if it's also available on non-replicatable (realtime) servers.
-        mutableSegments.remove(segment);
-        log.debug("Segment[%s] has become immutable.", 
segment.getIdentifier());
+      } else {
+        if (knownSegments != null && knownSegments.containsKey(segment)) {
 
 Review comment:
   Oh sorry, I haven't noticed that `ConcurrentSkipListMap.computeIfAbsent ()` 
is not an atomic operation when the key doesn't exist.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to