You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "reswqa (via GitHub)" <gi...@apache.org> on 2023/06/01 08:52:43 UTC

[GitHub] [flink] reswqa commented on a diff in pull request #22675: [FLINK-32213][core] Add get off heap buffer in segment

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


##########
flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java:
##########
@@ -279,6 +279,21 @@ public byte[] getArray() {
         }
     }
 
+    /**
+     * Returns the off heap buffer for the segment. It may be used by sink to create writer buffer
+     * for data lake such as iceberg and paimon.
+     *
+     * @return underlying byte buffer

Review Comment:
   ```suggestion
        * @return underlying off-heap buffer
   ```



##########
flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java:
##########
@@ -279,6 +279,21 @@ public byte[] getArray() {
         }
     }
 
+    /**
+     * Returns the off heap buffer for the segment. It may be used by sink to create writer buffer
+     * for data lake such as iceberg and paimon.
+     *
+     * @return underlying byte buffer
+     * @throws IllegalStateException if the memory segment does not represent off-heap buffer
+     */
+    public ByteBuffer getOffHeapBuffer() {
+        if (offHeapBuffer != null) {
+            return offHeapBuffer;
+        } else {
+            throw new IllegalStateException("Memory segment does not represent off heap buffer");

Review Comment:
   ```suggestion
               throw new IllegalStateException("Memory segment does not represent off-heap buffer");
   ```



##########
flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java:
##########
@@ -279,6 +279,21 @@ public byte[] getArray() {
         }
     }
 
+    /**
+     * Returns the off heap buffer for the segment. It may be used by sink to create writer buffer
+     * for data lake such as iceberg and paimon.

Review Comment:
   I tend not to emphasize that this method is used by sink for data lake. Because `MemorySegment` is a very basic class, providing method like this itself is intuitive enough.



##########
flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java:
##########
@@ -279,6 +279,21 @@ public byte[] getArray() {
         }
     }
 
+    /**
+     * Returns the off heap buffer for the segment. It may be used by sink to create writer buffer
+     * for data lake such as iceberg and paimon.
+     *
+     * @return underlying byte buffer
+     * @throws IllegalStateException if the memory segment does not represent off-heap buffer
+     */
+    public ByteBuffer getOffHeapBuffer() {

Review Comment:
   We should introduce test case for this method.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org