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


##########
server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java:
##########
@@ -1801,16 +1845,73 @@
     );
   }
 
+  private boolean isSchemaPresent(SegmentSchemaMapping segmentSchemaMapping)
+  {
+    return publishSchema()
+           && segmentSchemaMapping != null
+           && segmentSchemaMapping.isNonEmpty();
+  }
+
+  private void persistSchema(
+      final Handle handle,
+      final Set<DataSegment> segments,
+      final SegmentSchemaMapping segmentSchemaMapping
+  ) throws JsonProcessingException
+  {
+    if (segmentSchemaMapping.getSchemaVersion() != 
CentralizedDatasourceSchemaConfig.SCHEMA_VERSION) {
+      log.error(
+          "Schema version [%d] doesn't match the current version [%d], 
dropping the schema [%s].",
+          segmentSchemaMapping.getSchemaVersion(),
+          CentralizedDatasourceSchemaConfig.SCHEMA_VERSION,
+          segmentSchemaMapping
+      );
+      return;
+    }
+    String dataSource = segments.stream().iterator().next().getDataSource();
+
+    log.info("Persisting segment schema: [%s].", segmentSchemaMapping);
+
+    segmentSchemaManager.persistSegmentSchema(
+        handle,
+        dataSource,
+        segmentSchemaMapping.getSchemaVersion(),
+        segmentSchemaMapping.getSchemaFingerprintToPayloadMap()
+    );
+  }
+
+  private Pair<String, Long> getSegmentSchemaInformation(
+      SegmentSchemaMapping segmentSchemaMapping,
+      String segmentId
+  )
+  {
+    String fingerprint = null;
+    Long numRows = null;
+    SegmentMetadata segmentMetadata = 
segmentSchemaMapping.getSegmentIdToMetadataMap().get(segmentId);
+    if (segmentMetadata != null) {
+      numRows = segmentMetadata.getNumRows();
+      fingerprint = segmentMetadata.getSchemaFingerprint();
+    }
+    return Pair.of(fingerprint, numRows);
+  }
+
   private Set<DataSegment> announceHistoricalSegmentBatch(
       final Handle handle,
       final Set<DataSegment> segments,
-      final Set<DataSegment> usedSegments
+      final Set<DataSegment> usedSegments,
+      @Nullable final SegmentSchemaMapping segmentSchemaMapping
   ) throws IOException
   {
     final Set<DataSegment> toInsertSegments = new HashSet<>();
+    Map<String, Long> fingerprintSchemaIdMap = null;

Review Comment:
   ## Unread local variable
   
   Variable 'Map<String,Long> fingerprintSchemaIdMap' is never read.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/7296)



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