cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1060855 - in /cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra: io/sstable/IndexHelper.java utils/ByteBufferUtil.java utils/FBUtilities.java
Date Wed, 19 Jan 2011 16:38:43 GMT
Author: jbellis
Date: Wed Jan 19 16:38:43 2011
New Revision: 1060855

URL: http://svn.apache.org/viewvc?rev=1060855&view=rev
Log:
move FBU.inputStream to BBU
patch by slebresne; reviewed by jbellis for CASSANDRA-2009

Modified:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/IndexHelper.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/IndexHelper.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/IndexHelper.java?rev=1060855&r1=1060854&r2=1060855&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/IndexHelper.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/IndexHelper.java
Wed Jan 19 16:38:43 2011
@@ -103,7 +103,7 @@ public class IndexHelper
         int size = file.readInt();
         ByteBuffer bytes = file.readBytes(size);
 
-        DataInputStream stream = new DataInputStream(FBUtilities.inputStream(bytes));
+        DataInputStream stream = new DataInputStream(ByteBufferUtil.inputStream(bytes));
 
         return useOldBuffer
                 ? LegacyBloomFilter.serializer().deserialize(stream)

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java?rev=1060855&r1=1060854&r2=1060855&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
Wed Jan 19 16:38:43 2011
@@ -22,6 +22,7 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.EOFException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
@@ -355,4 +356,28 @@ public class ByteBufferUtil
         return ByteBuffer.allocate(8).putLong(0, n);
     }
 
+    public static InputStream inputStream(ByteBuffer bytes)
+    {
+        final ByteBuffer copy = bytes.duplicate();
+
+        return new InputStream()
+        {
+            public int read() throws IOException
+            {
+                if (!copy.hasRemaining())
+                    return -1;
+
+                return copy.get();
+            }
+
+            public int read(byte[] bytes, int off, int len) throws IOException
+            {
+                len = Math.min(len, copy.remaining());
+                copy.get(bytes, off, len);
+
+                return len;
+            }
+        };
+    }
+
 }

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=1060855&r1=1060854&r2=1060855&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
Wed Jan 19 16:38:43 2011
@@ -590,28 +590,4 @@ public class FBUtilities
 
         return field;
     }
-
-    public static InputStream inputStream(ByteBuffer bytes)
-    {
-        final ByteBuffer copy = ByteBufferUtil.clone(bytes);
-
-        return new InputStream()
-        {
-            public int read() throws IOException
-            {
-                if (!copy.hasRemaining())
-                    return -1;
-
-                return copy.get();
-            }
-
-            public int read(byte[] bytes, int off, int len) throws IOException
-            {
-                len = Math.min(len, copy.remaining());
-                copy.get(bytes, off, len);
-
-                return len;
-            }
-        };
-    }
 }



Mime
View raw message