reswqa commented on code in PR #22982:
URL: https://github.com/apache/flink/pull/22982#discussion_r1266273255


##########
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/hybrid/HybridShuffleTestUtils.java:
##########
@@ -73,37 +80,96 @@ public static HsOutputMetrics createTestingOutputMetrics() {
         return new HsOutputMetrics(new TestCounter(), new TestCounter());
     }
 
-    public static InternalRegion createSingleUnreleasedRegion(
+    public static TestingFileDataIndexRegion createSingleTestRegion(
             int firstBufferIndex, long firstBufferOffset, int 
numBuffersPerRegion) {
-        return new InternalRegion(
-                firstBufferIndex,
-                firstBufferOffset,
-                numBuffersPerRegion,
-                new boolean[numBuffersPerRegion]);
+        return new TestingFileDataIndexRegion.Builder()
+                .setGetSizeSupplier(() -> 
TestingFileDataIndexRegion.REGION_SIZE)
+                .setContainBufferFunction(
+                        bufferIndex ->
+                                containBufferFunction(
+                                        bufferIndex, firstBufferIndex, 
numBuffersPerRegion))
+                .setGetFirstBufferIndexSupplier(() -> firstBufferIndex)
+                .setGetRegionFileOffsetSupplier(() -> firstBufferOffset)
+                .setGetNumBuffersSupplier(() -> numBuffersPerRegion)
+                .build();
     }
 
-    public static List<InternalRegion> createAllUnreleasedRegions(
+    public static List<TestingFileDataIndexRegion> createTestRegions(
             int firstBufferIndex, long firstBufferOffset, int 
numBuffersPerRegion, int numRegions) {
-        List<InternalRegion> regions = new ArrayList<>();
+        List<TestingFileDataIndexRegion> regions = new ArrayList<>();
         int bufferIndex = firstBufferIndex;
         long bufferOffset = firstBufferOffset;
+        int numRegionSize = TestingFileDataIndexRegion.REGION_SIZE;
         for (int i = 0; i < numRegions; i++) {
+            final int currentBufferIndex = bufferIndex;
+            final long currentBufferOffset = bufferOffset;
             regions.add(
-                    new InternalRegion(
-                            bufferIndex,
-                            bufferOffset,
-                            numBuffersPerRegion,
-                            new boolean[numBuffersPerRegion]));
+                    new TestingFileDataIndexRegion.Builder()
+                            .setGetSizeSupplier(() -> numRegionSize)
+                            .setGetFirstBufferIndexSupplier(() -> 
currentBufferIndex)
+                            .setGetRegionFileOffsetSupplier(() -> 
currentBufferOffset)
+                            .setGetNumBuffersSupplier(() -> 
numBuffersPerRegion)
+                            .setContainBufferFunction(
+                                    index ->
+                                            containBufferFunction(
+                                                    index, firstBufferIndex, 
numBuffersPerRegion))
+                            .build());
             bufferIndex += numBuffersPerRegion;
             bufferOffset += bufferOffset;
         }
         return regions;
     }
 
-    public static void assertRegionEquals(InternalRegion expected, 
InternalRegion region) {
+    public static FileDataIndexRegionHelper.Region createSingleFixedSizeRegion(
+            int firstBufferIndex, long firstBufferOffset, int 
numBuffersPerRegion) {
+        return new ProducerMergedPartitionFileIndex.FixedSizeRegion(
+                firstBufferIndex, firstBufferOffset, numBuffersPerRegion);
+    }
+
+    public static TestingFileDataIndexRegion readRegionFromFile(

Review Comment:
   Maybe we can put these two method to `TestingFileDataIndexRegion.class`.



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