cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [2/5] git commit: inline an infrequently-used RAR.open overload
Date Wed, 14 Nov 2012 16:24:04 GMT
inline an infrequently-used RAR.open overload


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

Branch: refs/heads/trunk
Commit: 6773383df800b8b5099b09f1fc71518619c0aa1b
Parents: c176302
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Fri Nov 9 22:33:37 2012 -0600
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Wed Nov 14 10:23:51 2012 -0600

----------------------------------------------------------------------
 .../cassandra/io/util/RandomAccessReader.java      |   20 ++++++--------
 .../io/util/BufferedRandomAccessFileTest.java      |    6 +++-
 2 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6773383d/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 ba7587f..06778d9 100644
--- a/src/java/org/apache/cassandra/io/util/RandomAccessReader.java
+++ b/src/java/org/apache/cassandra/io/util/RandomAccessReader.java
@@ -21,6 +21,8 @@ import java.io.*;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 
+import com.google.common.annotations.VisibleForTesting;
+
 import org.apache.cassandra.io.FSReadError;
 import org.apache.cassandra.utils.CLibrary;
 
@@ -94,22 +96,18 @@ public class RandomAccessReader extends RandomAccessFile implements FileDataInpu
         validBufferBytes = -1; // that will trigger reBuffer() on demand by read/seek operations
     }
 
-    public static RandomAccessReader open(File file, boolean skipIOCache)
-    {
-        return open(file, DEFAULT_BUFFER_SIZE, skipIOCache);
-    }
-
     public static RandomAccessReader open(File file)
     {
-        return open(file, DEFAULT_BUFFER_SIZE, false);
+        return open(file, false);
     }
 
-    public static RandomAccessReader open(File file, int bufferSize)
+    public static RandomAccessReader open(File file, boolean skipIOCache)
     {
-        return open(file, bufferSize, false);
+        return open(file, DEFAULT_BUFFER_SIZE, skipIOCache);
     }
 
-    public static RandomAccessReader open(File file, int bufferSize, boolean skipIOCache)
+    @VisibleForTesting
+    static RandomAccessReader open(File file, int bufferSize, boolean skipIOCache)
     {
         try
         {
@@ -121,10 +119,10 @@ public class RandomAccessReader extends RandomAccessFile implements
FileDataInpu
         }
     }
 
-    // convert open into open
+    @VisibleForTesting
     public static RandomAccessReader open(SequentialWriter writer)
     {
-        return open(new File(writer.getPath()), DEFAULT_BUFFER_SIZE);
+        return open(new File(writer.getPath()), DEFAULT_BUFFER_SIZE, false);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6773383d/test/unit/org/apache/cassandra/io/util/BufferedRandomAccessFileTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/util/BufferedRandomAccessFileTest.java b/test/unit/org/apache/cassandra/io/util/BufferedRandomAccessFileTest.java
index e38850d..e7fa8e3 100644
--- a/test/unit/org/apache/cassandra/io/util/BufferedRandomAccessFileTest.java
+++ b/test/unit/org/apache/cassandra/io/util/BufferedRandomAccessFileTest.java
@@ -337,7 +337,8 @@ public class BufferedRandomAccessFileTest
             // single too-large read
             for (final int offset : Arrays.asList(0, 8))
             {
-                final RandomAccessReader file = RandomAccessReader.open(writeTemporaryFile(new
byte[16]), bufferSize);
+                File file1 = writeTemporaryFile(new byte[16]);
+                final RandomAccessReader file = RandomAccessReader.open(file1, bufferSize,
false);
                 expectEOF(new Callable<Object>()
                 {
                     public Object call() throws IOException
@@ -351,7 +352,8 @@ public class BufferedRandomAccessFileTest
             // first read is ok but eventually EOFs
             for (final int n : Arrays.asList(1, 2, 4, 8))
             {
-                final RandomAccessReader file = RandomAccessReader.open(writeTemporaryFile(new
byte[16]), bufferSize);
+                File file1 = writeTemporaryFile(new byte[16]);
+                final RandomAccessReader file = RandomAccessReader.open(file1, bufferSize,
false);
                 expectEOF(new Callable<Object>()
                 {
                     public Object call() throws IOException


Mime
View raw message