abdullah alamoudi has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/581

Change subject: Stop Network Output Channel Sending Extra Bytes
......................................................................

Stop Network Output Channel Sending Extra Bytes

This change re-introduce an optimization to the output channel
which ensures sending of data bytes only. This optimization
was broken when the big object change was introduced.

Change-Id: I896daf80deb23bcae5d5e934565cf5493ed828ba
---
M 
hyracks/hyracks-comm/src/main/java/org/apache/hyracks/comm/channels/NetworkOutputChannel.java
1 file changed, 13 insertions(+), 14 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/hyracks refs/changes/81/581/1

diff --git 
a/hyracks/hyracks-comm/src/main/java/org/apache/hyracks/comm/channels/NetworkOutputChannel.java
 
b/hyracks/hyracks-comm/src/main/java/org/apache/hyracks/comm/channels/NetworkOutputChannel.java
index 84307c2..601f442 100644
--- 
a/hyracks/hyracks-comm/src/main/java/org/apache/hyracks/comm/channels/NetworkOutputChannel.java
+++ 
b/hyracks/hyracks-comm/src/main/java/org/apache/hyracks/comm/channels/NetworkOutputChannel.java
@@ -1,18 +1,16 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -58,8 +56,7 @@
     @Override
     public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
         ByteBuffer destBuffer = null;
-        int startPos = 0;
-        do {
+        while (buffer.hasRemaining()) {
             synchronized (this) {
                 while (true) {
                     if (aborted) {
@@ -80,14 +77,16 @@
                     }
                 }
             }
-            buffer.position(startPos);
-            startPos = Math.min(startPos + destBuffer.capacity(), 
buffer.capacity());
-            buffer.limit(startPos);
             destBuffer.clear();
-            destBuffer.put(buffer);
+            if (destBuffer.capacity() < buffer.remaining()) {
+                destBuffer.put(buffer.array(), buffer.position(), 
destBuffer.capacity());
+                buffer.position(buffer.position() + destBuffer.capacity());
+            } else {
+                destBuffer.put(buffer);
+            }
             destBuffer.flip();
             ccb.getWriteInterface().getFullBufferAcceptor().accept(destBuffer);
-        } while (startPos < buffer.capacity());
+        }
     }
 
     @Override

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/581
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I896daf80deb23bcae5d5e934565cf5493ed828ba
Gerrit-PatchSet: 1
Gerrit-Project: hyracks
Gerrit-Branch: master
Gerrit-Owner: abdullah alamoudi <[email protected]>

Reply via email to