manojpec commented on a change in pull request #4352:
URL: https://github.com/apache/hudi/pull/4352#discussion_r781003611



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieMetadataPayload.java
##########
@@ -234,13 +379,65 @@ public HoodieMetadataPayload 
preCombine(HoodieMetadataPayload previousRecord) {
     return combinedFileInfo;
   }
 
+  public static Stream<HoodieRecord> createColumnStatsRecords(
+      Collection<HoodieColumnStatsMetadata<Comparable>> columnRangeInfo) {
+    return columnRangeInfo.stream().map(columnStatsMetadata -> {
+      HoodieKey key = new 
HoodieKey(getColumnStatsRecordKey(columnStatsMetadata),
+          MetadataPartitionType.COLUMN_STATS.partitionPath());
+
+      HoodieMetadataPayload payload = new 
HoodieMetadataPayload(key.getRecordKey(), METADATA_TYPE_COLUMN_STATS,
+          HoodieColumnStats.newBuilder()
+              .setMinValue(columnStatsMetadata.getMinValue() == null ? null :
+                  new String(((Binary) 
columnStatsMetadata.getMinValue()).getBytes()))
+              .setMaxValue(columnStatsMetadata.getMaxValue() == null ? null :
+                  new String(((Binary) 
columnStatsMetadata.getMaxValue()).getBytes()))
+              .setNullCount(columnStatsMetadata.getNullCount())
+              .setIsDeleted(false)
+              .setReserved(ByteBuffer.allocate(0))
+              .build());
+
+      return new HoodieRecord<>(key, payload);
+    });
+  }
+
+  // get record key from column stats metadata
+  public static String 
getColumnStatsRecordKey(HoodieColumnStatsMetadata<Comparable> 
columnStatsMetadata) {
+    final ColumnIndexID columnID = new 
ColumnIndexID(columnStatsMetadata.getColumnName());
+    final PartitionIndexID partitionID = new 
PartitionIndexID(columnStatsMetadata.getPartitionPath());
+    final FileIndexID fileID = new FileIndexID(FSUtils.getFileId(new 
Path(columnStatsMetadata.getFilePath()).getName()));
+    return columnID.asBase64EncodedString()
+        .concat(partitionID.asBase64EncodedString())
+        .concat(fileID.asBase64EncodedString());
+  }
+
+  // parse attribute in record key. TODO: find better way to get this 
attribute instaed of parsing key
+  public static String getAttributeFromRecordKey(String recordKey, String 
attribute) {
+    final String columnIDBase64EncodedString = recordKey.substring(0, 
ColumnIndexID.ID_COLUMN_HASH_SIZE.bits());
+
+    return "";

Review comment:
       No more used. Removed the method. 




-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to