beryllw commented on code in PR #3630:
URL: https://github.com/apache/fluss/pull/3630#discussion_r3609704039


##########
fluss-server/src/main/java/org/apache/fluss/server/utils/ServerRpcMessageUtils.java:
##########
@@ -1138,6 +1139,41 @@ public static Map<TableBucket, List<byte[]>> 
toLookupData(LookupRequest lookupRe
         return lookupEntryData;
     }
 
+    /**
+     * Converts lookup bucket requests for historical partition lookup.
+     *
+     * <p>Unlike normal lookup data, historical lookup must keep the original 
partition name carried
+     * by each bucket request. The name is later used to resolve the original 
partition in lake
+     * storage, while the {@link TableBucket} points to the historical system 
partition.
+     */
+    public static Map<TableBucket, LookupDataForBucket> toHistoricalLookupData(
+            LookupRequest lookupRequest) {
+        long tableId = lookupRequest.getTableId();
+        Map<TableBucket, LookupDataForBucket> lookupEntryData = new 
HashMap<>();
+        for (PbLookupReqForBucket lookupReqForBucket : 
lookupRequest.getBucketsReqsList()) {
+            TableBucket tb =
+                    new TableBucket(
+                            tableId,
+                            lookupReqForBucket.hasPartitionId()
+                                    ? lookupReqForBucket.getPartitionId()
+                                    : null,
+                            lookupReqForBucket.getBucketId());
+            List<byte[]> keys = new 
ArrayList<>(lookupReqForBucket.getKeysCount());
+            for (int i = 0; i < lookupReqForBucket.getKeysCount(); i++) {
+                keys.add(lookupReqForBucket.getKeyAt(i));
+            }
+            lookupEntryData.put(

Review Comment:
   nit: in toHistoricalLookupData, two buckets with the same TableBucket but 
different originalPartitionName silently overwrite each other. Might be safer 
to fail fast on a duplicate here — the Java client already splits these, so 
this would just guard against other clients.



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

Reply via email to