neuyilan commented on code in PR #4423:
URL: https://github.com/apache/paimon/pull/4423#discussion_r1827286753


##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/lookup/PrimaryKeyPartialLookupTable.java:
##########
@@ -108,25 +109,31 @@ public void open() throws Exception {
 
     @Override
     public List<InternalRow> get(InternalRow key) throws IOException {
+        Triple<BinaryRow, Integer, InternalRow> partitionAndBucket = 
extractPartitionAndBucket(key);
+        InternalRow kv =
+                queryExecutor.lookup(
+                        partitionAndBucket.f0, partitionAndBucket.f1, 
partitionAndBucket.f2);
+        if (kv == null) {
+            return Collections.emptyList();
+        } else {
+            return Collections.singletonList(kv);
+        }
+    }
+
+    private synchronized Triple<BinaryRow, Integer, InternalRow> 
extractPartitionAndBucket(
+            InternalRow key) {
         InternalRow adjustedKey = key;
         if (keyRearrange != null) {
             adjustedKey = keyRearrange.replaceRow(adjustedKey);

Review Comment:
   I have encapsulated these as a separate function called 
extractPartartitionAndBucket. And it has been declared as synchronized, so 
there will be no thread safety issues.



##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/lookup/PrimaryKeyPartialLookupTable.java:
##########
@@ -108,25 +109,31 @@ public void open() throws Exception {
 
     @Override
     public List<InternalRow> get(InternalRow key) throws IOException {
+        Triple<BinaryRow, Integer, InternalRow> partitionAndBucket = 
extractPartitionAndBucket(key);
+        InternalRow kv =
+                queryExecutor.lookup(
+                        partitionAndBucket.f0, partitionAndBucket.f1, 
partitionAndBucket.f2);
+        if (kv == null) {
+            return Collections.emptyList();
+        } else {
+            return Collections.singletonList(kv);
+        }
+    }
+
+    private synchronized Triple<BinaryRow, Integer, InternalRow> 
extractPartitionAndBucket(
+            InternalRow key) {
         InternalRow adjustedKey = key;
         if (keyRearrange != null) {
             adjustedKey = keyRearrange.replaceRow(adjustedKey);
         }
         extractor.setRecord(adjustedKey);
         int bucket = extractor.bucket();
         BinaryRow partition = extractor.partition();

Review Comment:
   the same as above



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