chaokunyang commented on code in PR #1451:
URL: https://github.com/apache/incubator-fury/pull/1451#discussion_r1555453677


##########
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##########
@@ -100,24 +105,30 @@ public final class MemoryBuffer {
    * @param length buffer size
    */
   private MemoryBuffer(byte[] buffer, int offset, int length) {
-    Preconditions.checkArgument(offset >= 0 && length >= 0);
+    this(buffer, offset, length, null);
+  }
+
+  /**
+   * Creates a new memory buffer that represents the memory of the byte array.
+   *
+   * @param buffer The byte array whose memory is represented by this memory 
buffer.
+   * @param offset The offset of the sub array to be used; must be 
non-negative and no larger than
+   *     <tt>array.length</tt>.
+   * @param length buffer size
+   * @param streamReader a reader for reading from a stream.
+   */
+  private MemoryBuffer(byte[] buffer, int offset, int length, FuryStreamReader 
streamReader) {
+    checkArgument(offset >= 0 && length >= 0);
     if (offset + length > buffer.length) {
       throw new IllegalArgumentException(
           String.format("%d exceeds buffer size %d", offset + length, 
buffer.length));
     }
     initHeapBuffer(buffer, offset, length);
-  }
-
-  private void initHeapBuffer(byte[] buffer, int offset, int length) {
-    if (buffer == null) {
-      throw new NullPointerException("buffer");
+    if (streamReader != null) {
+      this.streamReader = streamReader;
+    } else {
+      this.streamReader = new BoundChecker();

Review Comment:
   Could you elaborate more how `MemoryBuffer` read from the 
`InputStream`/`Channel`? There still a interface for such cases.



-- 
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: commits-unsubscr...@fury.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org

Reply via email to