cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdusba...@apache.org
Subject svn commit: r981648 - /cassandra/trunk/src/java/org/apache/cassandra/io/SerDeUtils.java
Date Mon, 02 Aug 2010 18:19:10 GMT
Author: gdusbabek
Date: Mon Aug  2 18:19:10 2010
New Revision: 981648

URL: http://svn.apache.org/viewvc?rev=981648&view=rev
Log:
util to wrap DataInputStream around a ByteBuffer. patch by stuhood, reviewed by gdusbabek.
CASSANDRA-1308

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/io/SerDeUtils.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/SerDeUtils.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/SerDeUtils.java?rev=981648&r1=981647&r2=981648&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/SerDeUtils.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/SerDeUtils.java Mon Aug  2 18:19:10 2010
@@ -18,16 +18,17 @@
 
 package org.apache.cassandra.io;
 
-import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.Collections;
 
 import org.apache.avro.Schema;
 import org.apache.avro.io.BinaryDecoder;
 import org.apache.avro.io.BinaryEncoder;
 import org.apache.avro.io.Decoder;
 import org.apache.avro.io.DecoderFactory;
+import org.apache.avro.ipc.ByteBufferInputStream;
 import org.apache.avro.generic.GenericArray;
 import org.apache.avro.generic.GenericData;
 import org.apache.avro.specific.SpecificDatumReader;
@@ -100,6 +101,15 @@ public final class SerDeUtils
     }
 
     /**
+     * @return a DataInputStream wrapping the given buffer.
+     */
+    public static DataInputStream createDataInputStream(ByteBuffer buff)
+    {
+        ByteBufferInputStream bbis = new ByteBufferInputStream(Collections.singletonList(buff));
+        return new DataInputStream(bbis);
+    }
+
+    /**
      * Create a generic array of the given type and size. Mostly to minimize imports.
      */
     public static <T> GenericArray<T> createArray(int size, Schema schema)



Mime
View raw message