cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefa...@apache.org
Subject [3/6] cassandra git commit: RandomAccessReader: call isEOF() only when rebuffering, not for every read operation
Date Tue, 21 Jun 2016 06:41:18 GMT
RandomAccessReader: call isEOF() only when rebuffering, not for every read operation

patch by Dikang Gu; reviewed by Stefania Alborghetti for CASSANDRA-12013


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/68398ada
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/68398ada
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/68398ada

Branch: refs/heads/trunk
Commit: 68398ada7e35cccc5f3818bb47b741ee25243e08
Parents: 142f358
Author: Dikang Gu <dikang85@gmail.com>
Authored: Mon Jun 20 11:49:57 2016 +0200
Committer: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Committed: Tue Jun 21 08:36:00 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/io/util/RandomAccessReader.java   | 23 +++++++++++++-------
 2 files changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/68398ada/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 76e601c..ef993fe 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.7
+ * RandomAccessReader: call isEOF() only when rebuffering, not for every read operation (CASSANDRA-12013)
  * Don't send erroneous NEW_NODE notifications on restart (CASSANDRA-11038)
  * StorageService shutdown hook should use a volatile variable (CASSANDRA-11984)
  * Persist local metadata earlier in startup sequence (CASSANDRA-11742)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/68398ada/src/java/org/apache/cassandra/io/util/RandomAccessReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/util/RandomAccessReader.java b/src/java/org/apache/cassandra/io/util/RandomAccessReader.java
index 751269b..0265be5 100644
--- a/src/java/org/apache/cassandra/io/util/RandomAccessReader.java
+++ b/src/java/org/apache/cassandra/io/util/RandomAccessReader.java
@@ -295,11 +295,13 @@ public class RandomAccessReader extends AbstractDataInput implements
FileDataInp
         if (buffer == null)
             throw new AssertionError("Attempted to read from closed RAR");
 
-        if (isEOF())
-            return -1; // required by RandomAccessFile
-
         if (!buffer.hasRemaining())
+        {
+            if (isEOF())
+                return -1; // required by RandomAccessFile
+
             reBuffer();
+        }
 
         return (int)buffer.get() & 0xff;
     }
@@ -321,11 +323,13 @@ public class RandomAccessReader extends AbstractDataInput implements
FileDataInp
         if (length == 0)
             return 0;
 
-        if (isEOF())
-            return -1;
-
         if (!buffer.hasRemaining())
+        {
+            if (isEOF())
+                return -1;
+
             reBuffer();
+        }
 
         int toCopy = Math.min(length, buffer.remaining());
         buffer.get(buff, offset, toCopy);
@@ -340,10 +344,13 @@ public class RandomAccessReader extends AbstractDataInput implements
FileDataInp
             ByteBuffer result = ByteBuffer.allocate(length);
             while (result.hasRemaining())
             {
-                if (isEOF())
-                    throw new EOFException();
                 if (!buffer.hasRemaining())
+                {
+                    if (isEOF())
+                        throw new EOFException();
+
                     reBuffer();
+                }
                 ByteBufferUtil.put(buffer, result);
             }
             result.flip();


Mime
View raw message