github-advanced-security[bot] commented on code in PR #18892:
URL: https://github.com/apache/druid/pull/18892#discussion_r2670876105


##########
sql/src/main/java/org/apache/druid/sql/calcite/schema/SystemSchema.java:
##########
@@ -332,22 +332,29 @@
             final AvailableSegmentMetadata availableSegmentMetadata =
                 
availableMetadataCache.getAvailableSegmentMetadata(segment.getDataSource(), 
segment.getId());
             segmentsAlreadySeen.add(segment.getId());
-            long numReplicas = 0L, numRows = 0L, isRealtime, isAvailable = 0L;
 
+            long numReplicas = 0L, isAvailable = 0L;
             if (availableSegmentMetadata != null) {
               numReplicas = availableSegmentMetadata.getNumReplicas();
               isAvailable = availableSegmentMetadata.getNumReplicas() > 0 ? 
IS_AVAILABLE_TRUE : IS_ACTIVE_FALSE;
-              numRows = availableSegmentMetadata.getNumRows();
             }
 
-            // If druid.centralizedDatasourceSchema.enabled is set on the 
Coordinator, SegmentMetadataCache on the
-            // broker might have outdated or no information regarding numRows 
and rowSignature for a segment.
-            // In that case, we should use {@code numRows} from the segment 
polled from the coordinator.
-            if (null != val.getNumRows()) {
+            final long numRows;
+            if (segment.getNumRows() != null) {
+              // the recent version of DataSegment stores numRows
+              numRows = segment.getNumRows().longValue();
+            } else if (val.getNumRows() != null) {
+              // If druid.centralizedDatasourceSchema.enabled is set on the 
Coordinator, SegmentMetadataCache on the
+              // broker might have outdated or no information regarding 
numRows and rowSignature for a segment.
+              // In that case, we should use {@code numRows} from the segment 
polled from the coordinator.
               numRows = val.getNumRows();
+            } else if (availableSegmentMetadata != null) {
+              numRows = availableSegmentMetadata.getNumRows();

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [AvailableSegmentMetadata.getNumRows](1) should be avoided because 
it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10657)



##########
sql/src/main/java/org/apache/druid/sql/calcite/schema/SystemSchema.java:
##########
@@ -401,7 +408,7 @@
                 segment.getVersion(),
                 (long) segment.getShardSpec().getPartitionNum(),
                 val.getNumReplicas(),
-                val.getNumRows(),
+                segment.getNumRows() != null ? segment.getNumRows() : 
val.getNumRows(),

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [AvailableSegmentMetadata.getNumRows](1) should be avoided because 
it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10658)



##########
server/src/main/java/org/apache/druid/server/http/MetadataResource.java:
##########
@@ -227,15 +227,19 @@
           Integer replicationFactor = isOvershadowed ? (Integer) 0
                                                      : 
coordinator.getReplicationFactor(segment.getId());
 
-          Long numRows = null;
-          if (coordinatorSegmentMetadataCache != null) {
+          final Long numRows;
+          if (segment.getNumRows() != null) {
+            // the recent version of DataSegment stores numRows
+            numRows = segment.getNumRows().longValue();
+          } else if (coordinatorSegmentMetadataCache != null) {
+            // if centralized schema is enabled, SchemaPayloadPlus stores 
numRows
             AvailableSegmentMetadata availableSegmentMetadata = 
coordinatorSegmentMetadataCache.getAvailableSegmentMetadata(
                 segment.getDataSource(),
                 segment.getId()
             );
-            if (null != availableSegmentMetadata) {
-              numRows = availableSegmentMetadata.getNumRows();
-            }
+            numRows = availableSegmentMetadata == null ? null : 
availableSegmentMetadata.getNumRows();

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [AvailableSegmentMetadata.getNumRows](1) should be avoided because 
it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10656)



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