Au-Miner commented on code in PR #27099:
URL: https://github.com/apache/flink/pull/27099#discussion_r2438924988


##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -566,6 +738,49 @@ void testMeetExceptionWhenLookup() throws Exception {
                 .isEqualTo(expectedException);
     }
 
+    private void verifyCacheData(
+            DeltaJoinCache actualCache,
+            Map<RowData, Map<RowData, Object>> expectedLeftCacheData,
+            Map<RowData, Map<RowData, Object>> expectedRightCacheData,
+            long expectedLeftCacheRequestCount,
+            long expectedLeftCacheHitCount,
+            long expectedRightCacheRequestCount,
+            long expectedRightCacheHitCount) {
+        // assert left cache
+        assertThat(actualCache.getLeftCache().asMap())
+                .as("left cache data mismatch")
+                .isEqualTo(expectedLeftCacheData);
+        assertThat(actualCache.getLeftCache().size())
+                .as("left cache size mismatch")
+                .isEqualTo(expectedLeftCacheData.size());
+        assertThat(actualCache.getLeftCacheTotalSize().get())
+                .as("left cache total size mismatch")
+                
.isEqualTo(expectedLeftCacheData.values().stream().mapToInt(Map::size).sum());
+        assertThat(actualCache.getLeftRequestCount().get())
+                .as("left cache request count mismatch")
+                .isEqualTo(expectedLeftCacheRequestCount);
+        assertThat(actualCache.getLeftCacheHitCount().get())
+                .as("left cache hit count mismatch")
+                .isEqualTo(expectedLeftCacheHitCount);
+
+        // assert right cache
+        assertThat(actualCache.getRightCache().asMap())
+                .as("right cache data mismatch")
+                .isEqualTo(expectedRightCacheData);
+        assertThat(actualCache.getRightCache().size())
+                .as("left cache size mismatch")

Review Comment:
   right cache



##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -566,6 +738,49 @@ void testMeetExceptionWhenLookup() throws Exception {
                 .isEqualTo(expectedException);
     }
 
+    private void verifyCacheData(
+            DeltaJoinCache actualCache,
+            Map<RowData, Map<RowData, Object>> expectedLeftCacheData,
+            Map<RowData, Map<RowData, Object>> expectedRightCacheData,
+            long expectedLeftCacheRequestCount,
+            long expectedLeftCacheHitCount,
+            long expectedRightCacheRequestCount,
+            long expectedRightCacheHitCount) {
+        // assert left cache
+        assertThat(actualCache.getLeftCache().asMap())
+                .as("left cache data mismatch")
+                .isEqualTo(expectedLeftCacheData);
+        assertThat(actualCache.getLeftCache().size())
+                .as("left cache size mismatch")
+                .isEqualTo(expectedLeftCacheData.size());
+        assertThat(actualCache.getLeftCacheTotalSize().get())
+                .as("left cache total size mismatch")
+                
.isEqualTo(expectedLeftCacheData.values().stream().mapToInt(Map::size).sum());
+        assertThat(actualCache.getLeftRequestCount().get())
+                .as("left cache request count mismatch")
+                .isEqualTo(expectedLeftCacheRequestCount);
+        assertThat(actualCache.getLeftCacheHitCount().get())
+                .as("left cache hit count mismatch")
+                .isEqualTo(expectedLeftCacheHitCount);
+
+        // assert right cache
+        assertThat(actualCache.getRightCache().asMap())
+                .as("right cache data mismatch")
+                .isEqualTo(expectedRightCacheData);
+        assertThat(actualCache.getRightCache().size())
+                .as("left cache size mismatch")
+                .isEqualTo(expectedRightCacheData.size());
+        assertThat(actualCache.getRightCacheTotalSize().get())
+                .as("left cache total size mismatch")

Review Comment:
   ditto



##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -697,6 +948,38 @@ private static void insertTableData(StreamRecord<RowData> 
record, boolean insert
         }
     }
 
+    private <T> Map<RowData, T> newHashMap(RowData key, T value) {
+        return newHashMap(Collections.singletonList(key), 
Collections.singletonList(value));
+    }
+
+    private <T> Map<RowData, T> newHashMap(RowData key1, T value1, RowData 
key2, T value2) {
+        return newHashMap(Arrays.asList(key1, key2), Arrays.asList(value1, 
value2));
+    }
+
+    private <T> Map<RowData, T> newHashMap(
+            RowData key1, T value1, RowData key2, T value2, RowData key3, T 
value3) {
+        return newHashMap(Arrays.asList(key1, key2, key3), 
Arrays.asList(value1, value2, value3));
+    }

Review Comment:
   Should we replace these three functions with functions using Object... rest



##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/deltajoin/DeltaJoinCache.java:
##########
@@ -0,0 +1,243 @@
+/*
+ * 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.flink.table.runtime.operators.join.deltajoin;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.metrics.Gauge;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.util.Preconditions;
+
+import org.apache.flink.shaded.guava33.com.google.common.cache.Cache;
+import org.apache.flink.shaded.guava33.com.google.common.cache.CacheBuilder;
+import org.apache.flink.shaded.guava33.com.google.common.cache.RemovalListener;
+import 
org.apache.flink.shaded.guava33.com.google.common.cache.RemovalNotification;
+
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.NotThreadSafe;
+
+import java.util.LinkedHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Cache for both sides in delta join.
+ *
+ * <p>Note: this cache is not thread-safe although its inner {@link Cache} is 
thread-safe.

Review Comment:
   Note: This cache is not thread-safe although its inner {@link Cache} is 
thread-safe.



##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -566,6 +738,49 @@ void testMeetExceptionWhenLookup() throws Exception {
                 .isEqualTo(expectedException);
     }
 
+    private void verifyCacheData(
+            DeltaJoinCache actualCache,
+            Map<RowData, Map<RowData, Object>> expectedLeftCacheData,
+            Map<RowData, Map<RowData, Object>> expectedRightCacheData,
+            long expectedLeftCacheRequestCount,
+            long expectedLeftCacheHitCount,
+            long expectedRightCacheRequestCount,
+            long expectedRightCacheHitCount) {
+        // assert left cache
+        assertThat(actualCache.getLeftCache().asMap())
+                .as("left cache data mismatch")
+                .isEqualTo(expectedLeftCacheData);
+        assertThat(actualCache.getLeftCache().size())
+                .as("left cache size mismatch")
+                .isEqualTo(expectedLeftCacheData.size());
+        assertThat(actualCache.getLeftCacheTotalSize().get())
+                .as("left cache total size mismatch")
+                
.isEqualTo(expectedLeftCacheData.values().stream().mapToInt(Map::size).sum());
+        assertThat(actualCache.getLeftRequestCount().get())
+                .as("left cache request count mismatch")
+                .isEqualTo(expectedLeftCacheRequestCount);
+        assertThat(actualCache.getLeftCacheHitCount().get())
+                .as("left cache hit count mismatch")
+                .isEqualTo(expectedLeftCacheHitCount);
+
+        // assert right cache
+        assertThat(actualCache.getRightCache().asMap())
+                .as("right cache data mismatch")
+                .isEqualTo(expectedRightCacheData);
+        assertThat(actualCache.getRightCache().size())
+                .as("left cache size mismatch")
+                .isEqualTo(expectedRightCacheData.size());
+        assertThat(actualCache.getRightCacheTotalSize().get())
+                .as("left cache total size mismatch")
+                
.isEqualTo(expectedRightCacheData.values().stream().mapToInt(Map::size).sum());
+        assertThat(actualCache.getRightRequestCount().get())
+                .as("left cache request count mismatch")
+                .isEqualTo(expectedRightCacheRequestCount);
+        assertThat(actualCache.getRightCacheHitCount().get())
+                .as("left cache hit count mismatch")
+                .isEqualTo(expectedRightCacheHitCount);

Review Comment:
   Can the same function be called for both 'left' and 'right' respectively



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