findingrish commented on code in PR #15817:
URL: https://github.com/apache/druid/pull/15817#discussion_r1568441856


##########
processing/src/main/java/org/apache/druid/segment/MinimalSegmentSchemas.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Compact representation of segment schema for multiple segments.
+ */
+public class MinimalSegmentSchemas
+{
+  // Mapping of segmentId to segment level information like schema fingerprint 
and numRows.
+  private final Map<String, SegmentStats> segmentIdToMetadataMap;
+
+  // Mapping of schema fingerprint to payload.
+  private final Map<String, SchemaPayload> schemaFingerprintToPayloadMap;
+
+  private final String schemaVersion;
+
+  @JsonCreator
+  public MinimalSegmentSchemas(
+      @JsonProperty("segmentIdToMetadataMap") Map<String, SegmentStats> 
segmentIdToMetadataMap,
+      @JsonProperty("schemaFingerprintToPayloadMap") Map<String, 
SchemaPayload> schemaFingerprintToPayloadMap,
+      @JsonProperty("schemaVersion") String schemaVersion
+  )
+  {
+    this.segmentIdToMetadataMap = segmentIdToMetadataMap;
+    this.schemaFingerprintToPayloadMap = schemaFingerprintToPayloadMap;
+    this.schemaVersion = schemaVersion;
+  }
+
+  public MinimalSegmentSchemas(String schemaVersion)
+  {
+    this.segmentIdToMetadataMap = new HashMap<>();
+    this.schemaFingerprintToPayloadMap = new HashMap<>();
+    this.schemaVersion = schemaVersion;
+  }
+
+  @JsonProperty
+  public Map<String, SegmentStats> getSegmentIdToMetadataMap()
+  {
+    return segmentIdToMetadataMap;
+  }
+
+  @JsonProperty
+  public Map<String, SchemaPayload> getSchemaFingerprintToPayloadMap()
+  {
+    return schemaFingerprintToPayloadMap;
+  }
+
+  @JsonProperty
+  public String getSchemaVersion()
+  {
+    return schemaVersion;
+  }
+
+  public boolean isNonEmpty()
+  {
+    return segmentIdToMetadataMap.size() > 0;
+  }
+
+  /**
+   * Add schema information for the segment.
+   */
+  public void addSchema(
+      String segmentId,
+      String fingerprint,
+      long numRows,
+      SchemaPayload schemaPayload
+  )
+  {
+    segmentIdToMetadataMap.put(segmentId, new SegmentStats(numRows, 
fingerprint));
+    schemaFingerprintToPayloadMap.put(fingerprint, schemaPayload);
+  }
+
+  /**
+   * Merge with another instance.
+   */
+  public void merge(MinimalSegmentSchemas other)
+  {
+    this.segmentIdToMetadataMap.putAll(other.getSegmentIdToMetadataMap());
+    
this.schemaFingerprintToPayloadMap.putAll(other.getSchemaFingerprintToPayloadMap());
+  }
+
+  public int size()
+  {
+    return schemaFingerprintToPayloadMap.size();

Review Comment:
   Renamed the `size` method to `getSchemaCount`. 



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