nemo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-nemo] johnyangk commented on a change in pull request #223: [NEMO-388] Off-heap memory management (reuse ByteBuffer)
Date Tue, 23 Jul 2019 07:29:37 GMT
johnyangk commented on a change in pull request #223: [NEMO-388] Off-heap memory management
(reuse ByteBuffer)
URL: https://github.com/apache/incubator-nemo/pull/223#discussion_r306156748
 
 

 ##########
 File path: runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/DirectByteBufferOutputStream.java
 ##########
 @@ -106,24 +125,30 @@ public void write(final byte[] b) {
    * @param   len   the number of bytes to write.
    */
   @Override
-  public void write(final byte[] b, final int off, final int len) {
+  public void write(final byte[] b, final int off, final int len) throws IOException {
     int byteToWrite = len;
     int offset = off;
-    while (byteToWrite > 0) {
-      if (currentBuf.remaining() <= 0) {
-        newLastBuffer();
-        currentBuf = dataList.getLast();
-      }
-      final int bufRemaining = currentBuf.remaining();
-      if (bufRemaining < byteToWrite) {
-        currentBuf.put(b, offset, bufRemaining);
-        offset += bufRemaining;
-        byteToWrite -= bufRemaining;
-      } else {
-        currentBuf.put(b, offset, byteToWrite);
-        offset += byteToWrite;
-        byteToWrite = 0;
+    try {
+      while (byteToWrite > 0) {
+        if (currentBuf.remaining() <= 0) {
+          newLastBuffer();
+          currentBuf = dataList.getLast();
+        }
+        final int bufRemaining = currentBuf.remaining();
+        if (bufRemaining < byteToWrite) {
+          currentBuf.put(b, offset, bufRemaining);
+          offset += bufRemaining;
+          byteToWrite -= bufRemaining;
+        } else {
+          currentBuf.put(b, offset, byteToWrite);
+          offset += byteToWrite;
+          byteToWrite = 0;
+        }
       }
+    } catch (IllegalAccessException e) {
+      throw new IOException("Not allowed for non-sequential MemoryChunk");
+    } catch (MemoryAllocationException e) {
 
 Review comment:
   I believe this is never invoked, since we never actually instantiate a 'MemoryAllocationException',
at least in the current PR.
   (Same goes for other similar if/else statements) 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message