deniskuzZ commented on code in PR #5254:
URL: https://github.com/apache/hive/pull/5254#discussion_r1680571551
##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergAcidUtil.java:
##########
@@ -196,6 +213,32 @@ public static long computePartitionHash(Record rec) {
return computeHash(part);
}
+ public static PartitionKey parsePartitionKey(Record rec) {
+ String serializedStr = rec.get(SERDE_META_COLS.get(PARTITION_PROJECTION),
String.class);
+ return SerializationUtil.deserializeFromBase64(serializedStr);
+ }
+
+ public static String getSerializedPartitionKey(Record rec, PartitionSpec
partitionSpec) {
+ GenericRecord current = GenericRecord.create(partitionSpec.schema());
+ for (int index = 0; index < rec.size(); index++) {
+ current.set(index, rec.get(index));
+ }
+ StructLike structLike = new
InternalRecordWrapper(partitionSpec.schema().asStruct()).wrap(current);
+ PartitionKey partitionKey = new PartitionKey(partitionSpec,
partitionSpec.schema());
+ partitionKey.partition(structLike);
+ return SerializationUtil.serializeToBase64(partitionKey);
+ }
+
+ public static String getSerializedPartitionKey(StructLike structLike,
PartitionSpec partitionSpec) {
+ PartitionKey partitionKey = new PartitionKey(partitionSpec,
partitionSpec.schema());
+ if (structLike != null) {
Review Comment:
can't we do `partitionKey.partition(structLike)` instead of the loop?
if yes, we could reuse that method in
````
public static String getSerializedPartitionKey(Record rec, PartitionSpec
partitionSpec) {
GenericRecord current = GenericRecord.create(partitionSpec.schema());
for (int index = 0; index < rec.size(); index++) {
current.set(index, rec.get(index));
}
StructLike structLike = new
InternalRecordWrapper(partitionSpec.schema().asStruct()).wrap(current);
return getSerializedPartitionKey(structLike, partitionSpec)
}
````
--
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]