From notifications-return-613-archive-asf-public=cust-asf.ponee.io@nemo.apache.org Fri Jun 21 04:15:17 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 7C09F180670 for ; Fri, 21 Jun 2019 06:15:17 +0200 (CEST) Received: (qmail 29497 invoked by uid 500); 21 Jun 2019 04:15:17 -0000 Mailing-List: contact notifications-help@nemo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nemo.apache.org Delivered-To: mailing list notifications@nemo.apache.org Received: (qmail 29488 invoked by uid 99); 21 Jun 2019 04:15:16 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jun 2019 04:15:16 +0000 From: GitBox To: notifications@nemo.apache.org Subject: [GitHub] [incubator-nemo] hy00nc commented on a change in pull request #222: [NEMO-350] Implement Off-heap SerializedMemoryStore & [NEMO-384] Implement DirectByteBufferInputStream for Off-heap SerializedMemoryStore Message-ID: <156109051682.6907.14633349435228707951.gitbox@gitbox.apache.org> Date: Fri, 21 Jun 2019 04:15:16 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit hy00nc commented on a change in pull request #222: [NEMO-350] Implement Off-heap SerializedMemoryStore & [NEMO-384] Implement DirectByteBufferInputStream for Off-heap SerializedMemoryStore URL: https://github.com/apache/incubator-nemo/pull/222#discussion_r296090466 ########## File path: common/src/main/java/org/apache/nemo/common/DirectByteBufferOutputStream.java ########## @@ -140,38 +140,45 @@ public void write(final byte[] b, final int off, final int len) { final int arraySize = pageSize * (dataList.size() - 1) + lastBuf.position(); final byte[] byteArray = new byte[arraySize]; int start = 0; - int byteToWrite; - for (final ByteBuffer temp : dataList) { + for (final ByteBuffer buffer : dataList) { // ByteBuffer has to be shifted to read mode by calling ByteBuffer.flip(), // which sets limit to the current position and sets the position to 0. // Note that capacity remains unchanged. - temp.flip(); - byteToWrite = temp.remaining(); - temp.get(byteArray, start, byteToWrite); + final ByteBuffer dupBuffer = buffer.duplicate(); + dupBuffer.flip(); + final int byteToWrite = dupBuffer.remaining(); + dupBuffer.get(byteArray, start, byteToWrite); start += byteToWrite; } - // The limit of the last buffer has to be set to the capacity for additional write. - lastBuf.limit(lastBuf.capacity()); Review comment: We changed it to read from duplicated buffer so the original one maintains its limit. ---------------------------------------------------------------- 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