cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject cassandra git commit: For CASSANDRA-9499, update to OHC 0.4 that allow deserialization directly from ByteBuffers
Date Wed, 15 Jul 2015 13:25:34 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 4cea221f9 -> 177e0dcbe


For CASSANDRA-9499, update to OHC 0.4 that allow deserialization directly from ByteBuffers


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

Branch: refs/heads/trunk
Commit: 177e0dcbe43f494f458e11adf0fd3ec413627772
Parents: 4cea221
Author: Ariel Weisberg <ariel@weisberg.ws>
Authored: Tue Jul 7 17:25:54 2015 -0400
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Wed Jul 15 14:24:35 2015 +0100

----------------------------------------------------------------------
 build.xml                                       |   6 +-
 lib/ohc-core-0.3.4.jar                          | Bin 145954 -> 0 bytes
 lib/ohc-core-0.4.jar                            | Bin 0 -> 127890 bytes
 lib/ohc-core-j8-0.3.4.jar                       | Bin 5081 -> 0 bytes
 lib/ohc-core-j8-0.4.jar                         | Bin 0 -> 4989 bytes
 .../org/apache/cassandra/cache/OHCProvider.java |  75 +++++++------
 .../apache/cassandra/io/util/DataInputPlus.java | 108 -------------------
 .../cassandra/io/util/DataOutputPlus.java       | 108 -------------------
 8 files changed, 49 insertions(+), 248 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/177e0dcb/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 88c2e94..0362eb4 100644
--- a/build.xml
+++ b/build.xml
@@ -406,7 +406,8 @@
           <dependency groupId="com.datastax.cassandra" artifactId="cassandra-driver-core"
version="2.1.5" classifier="shaded" />
           -->
           <dependency groupId="org.eclipse.jdt.core.compiler" artifactId="ecj" version="4.4.2"
/>
-          <dependency groupId="org.caffinitas.ohc" artifactId="ohc-core" version="0.3.4"
/>
+          <dependency groupId="org.caffinitas.ohc" artifactId="ohc-core" version="0.4"
/>
+          <dependency groupId="org.caffinitas.ohc" artifactId="ohc-core-j8" version="0.4"
/>
           <dependency groupId="net.ju-n.compile-command-annotations" artifactId="compile-command-annotations"
version="1.2.0" />
           <dependency groupId="org.fusesource" artifactId="sigar" version="1.6.4">
           	<exclusion groupId="log4j" artifactId="log4j"/>
@@ -460,7 +461,8 @@
         <dependency groupId="com.datastax.cassandra" artifactId="cassandra-driver-core"
classifier="shaded"/>
         -->
         <dependency groupId="org.eclipse.jdt.core.compiler" artifactId="ecj"/>
-        <dependency groupId="org.caffinitas.ohc" artifactId="ohc-core"/>
+        <dependency groupId="org.caffinitas.ohc" artifactId="ohc-core" version="0.4" />
+        <dependency groupId="org.caffinitas.ohc" artifactId="ohc-core-j8" version="0.4"
/>
         <dependency groupId="org.openjdk.jmh" artifactId="jmh-core"/>
         <dependency groupId="org.openjdk.jmh" artifactId="jmh-generator-annprocess"/>
         <dependency groupId="net.ju-n.compile-command-annotations" artifactId="compile-command-annotations"/>

http://git-wip-us.apache.org/repos/asf/cassandra/blob/177e0dcb/lib/ohc-core-0.3.4.jar
----------------------------------------------------------------------
diff --git a/lib/ohc-core-0.3.4.jar b/lib/ohc-core-0.3.4.jar
deleted file mode 100644
index 0773e78..0000000
Binary files a/lib/ohc-core-0.3.4.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/177e0dcb/lib/ohc-core-0.4.jar
----------------------------------------------------------------------
diff --git a/lib/ohc-core-0.4.jar b/lib/ohc-core-0.4.jar
new file mode 100644
index 0000000..1b1b939
Binary files /dev/null and b/lib/ohc-core-0.4.jar differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/177e0dcb/lib/ohc-core-j8-0.3.4.jar
----------------------------------------------------------------------
diff --git a/lib/ohc-core-j8-0.3.4.jar b/lib/ohc-core-j8-0.3.4.jar
deleted file mode 100644
index faa102f..0000000
Binary files a/lib/ohc-core-j8-0.3.4.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/177e0dcb/lib/ohc-core-j8-0.4.jar
----------------------------------------------------------------------
diff --git a/lib/ohc-core-j8-0.4.jar b/lib/ohc-core-j8-0.4.jar
new file mode 100644
index 0000000..f97ddf5
Binary files /dev/null and b/lib/ohc-core-j8-0.4.jar differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/177e0dcb/src/java/org/apache/cassandra/cache/OHCProvider.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cache/OHCProvider.java b/src/java/org/apache/cassandra/cache/OHCProvider.java
index 46cbb8b..21fc7c7 100644
--- a/src/java/org/apache/cassandra/cache/OHCProvider.java
+++ b/src/java/org/apache/cassandra/cache/OHCProvider.java
@@ -17,18 +17,16 @@
  */
 package org.apache.cassandra.cache;
 
-import java.io.DataInput;
-import java.io.DataOutput;
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.util.Iterator;
 import java.util.UUID;
 
-
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.TypeSizes;
 import org.apache.cassandra.db.partitions.CachedPartition;
-import org.apache.cassandra.io.util.DataInputPlus.DataInputPlusAdapter;
-import org.apache.cassandra.io.util.DataOutputPlus;
+import org.apache.cassandra.io.util.DataOutputBufferFixed;
+import org.apache.cassandra.io.util.NIODataInputStream;
 import org.caffinitas.ohc.OHCache;
 import org.caffinitas.ohc.OHCacheBuilder;
 
@@ -123,20 +121,20 @@ public class OHCProvider implements CacheProvider<RowCacheKey, IRowCacheEntry>
     private static class KeySerializer implements org.caffinitas.ohc.CacheSerializer<RowCacheKey>
     {
         private static KeySerializer instance = new KeySerializer();
-        public void serialize(RowCacheKey rowCacheKey, DataOutput dataOutput) throws IOException
+        public void serialize(RowCacheKey rowCacheKey, ByteBuffer buf)
         {
-            dataOutput.writeLong(rowCacheKey.cfId.getMostSignificantBits());
-            dataOutput.writeLong(rowCacheKey.cfId.getLeastSignificantBits());
-            dataOutput.writeInt(rowCacheKey.key.length);
-            dataOutput.write(rowCacheKey.key);
+            buf.putLong(rowCacheKey.cfId.getMostSignificantBits());
+            buf.putLong(rowCacheKey.cfId.getLeastSignificantBits());
+            buf.putInt(rowCacheKey.key.length);
+            buf.put(rowCacheKey.key);
         }
 
-        public RowCacheKey deserialize(DataInput dataInput) throws IOException
+        public RowCacheKey deserialize(ByteBuffer buf)
         {
-            long msb = dataInput.readLong();
-            long lsb = dataInput.readLong();
-            byte[] key = new byte[dataInput.readInt()];
-            dataInput.readFully(key);
+            long msb = buf.getLong();
+            long lsb = buf.getLong();
+            byte[] key = new byte[buf.getInt()];
+            buf.get(key);
             return new RowCacheKey(new UUID(msb, lsb), key);
         }
 
@@ -149,23 +147,40 @@ public class OHCProvider implements CacheProvider<RowCacheKey, IRowCacheEntry>
     private static class ValueSerializer implements org.caffinitas.ohc.CacheSerializer<IRowCacheEntry>
     {
         private static ValueSerializer instance = new ValueSerializer();
-        public void serialize(IRowCacheEntry entry, DataOutput out) throws IOException
+        public void serialize(IRowCacheEntry entry, ByteBuffer buf)
         {
             assert entry != null; // unlike CFS we don't support nulls, since there is no
need for that in the cache
-            boolean isSentinel = entry instanceof RowCacheSentinel;
-            out.writeBoolean(isSentinel);
-            if (isSentinel)
-                out.writeLong(((RowCacheSentinel) entry).sentinelId);
-            else
-                CachedPartition.cacheSerializer.serialize((CachedPartition)entry, new DataOutputPlus.DataOutputPlusAdapter(out));
-        }
-
-        public IRowCacheEntry deserialize(DataInput in) throws IOException
-        {
-            boolean isSentinel = in.readBoolean();
-            if (isSentinel)
-                return new RowCacheSentinel(in.readLong());
-            return CachedPartition.cacheSerializer.deserialize(new DataInputPlusAdapter(in));
+            DataOutputBufferFixed out = new DataOutputBufferFixed(buf);
+            try
+            {
+                boolean isSentinel = entry instanceof RowCacheSentinel;
+                out.writeBoolean(isSentinel);
+                if (isSentinel)
+                    out.writeLong(((RowCacheSentinel) entry).sentinelId);
+                else
+                    CachedPartition.cacheSerializer.serialize((CachedPartition)entry, out);
+            }
+            catch (IOException e)
+            {
+                throw new RuntimeException(e);
+            }
+        }
+
+        @SuppressWarnings("resource")
+        public IRowCacheEntry deserialize(ByteBuffer buf)
+        {
+            try
+            {
+                NIODataInputStream in = new NIODataInputStream(buf, false);
+                boolean isSentinel = in.readBoolean();
+                if (isSentinel)
+                    return new RowCacheSentinel(in.readLong());
+                return CachedPartition.cacheSerializer.deserialize(in);
+            }
+            catch (IOException e)
+            {
+                throw new RuntimeException(e);
+            }
         }
 
         public int serializedSize(IRowCacheEntry entry)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/177e0dcb/src/java/org/apache/cassandra/io/util/DataInputPlus.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/util/DataInputPlus.java b/src/java/org/apache/cassandra/io/util/DataInputPlus.java
index d4e25d6..a029427 100644
--- a/src/java/org/apache/cassandra/io/util/DataInputPlus.java
+++ b/src/java/org/apache/cassandra/io/util/DataInputPlus.java
@@ -47,114 +47,6 @@ public interface DataInputPlus extends DataInput
         return VIntCoding.readUnsignedVInt(this);
     }
 
-    public static class ForwardingDataInput implements DataInput
-    {
-        protected final DataInput in;
-
-        public ForwardingDataInput(DataInput in)
-        {
-            this.in = in;
-        }
-
-        @Override
-        public void readFully(byte[] b) throws IOException
-        {
-            in.readFully(b);
-        }
-
-        @Override
-        public void readFully(byte[] b, int off, int len) throws IOException
-        {
-            in.readFully(b, off, len);
-        }
-
-        @Override
-        public int skipBytes(int n) throws IOException
-        {
-            return in.skipBytes(n);
-        }
-
-        @Override
-        public boolean readBoolean() throws IOException
-        {
-            return in.readBoolean();
-        }
-
-        @Override
-        public byte readByte() throws IOException
-        {
-            return in.readByte();
-        }
-
-        @Override
-        public int readUnsignedByte() throws IOException
-        {
-            return in.readUnsignedByte();
-        }
-
-        @Override
-        public short readShort() throws IOException
-        {
-            return in.readShort();
-        }
-
-        @Override
-        public int readUnsignedShort() throws IOException
-        {
-            return in.readUnsignedShort();
-        }
-
-        @Override
-        public char readChar() throws IOException
-        {
-            return in.readChar();
-        }
-
-        @Override
-        public int readInt() throws IOException
-        {
-            return in.readInt();
-        }
-
-        @Override
-        public long readLong() throws IOException
-        {
-            return in.readLong();
-        }
-
-        @Override
-        public float readFloat() throws IOException
-        {
-            return in.readFloat();
-        }
-
-        @Override
-        public double readDouble() throws IOException
-        {
-            return in.readDouble();
-        }
-
-        @Override
-        public String readLine() throws IOException
-        {
-            return in.readLine();
-        }
-
-        @Override
-        public String readUTF() throws IOException
-        {
-            return in.readUTF();
-        }
-    }
-
-    public static class DataInputPlusAdapter extends ForwardingDataInput implements DataInputPlus
-    {
-        public DataInputPlusAdapter(DataInput in)
-        {
-            super(in);
-        }
-    }
-
     /**
      * Wrapper around an InputStream that provides no buffering but can decode varints
      */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/177e0dcb/src/java/org/apache/cassandra/io/util/DataOutputPlus.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/util/DataOutputPlus.java b/src/java/org/apache/cassandra/io/util/DataOutputPlus.java
index b46d23a..5f3f384 100644
--- a/src/java/org/apache/cassandra/io/util/DataOutputPlus.java
+++ b/src/java/org/apache/cassandra/io/util/DataOutputPlus.java
@@ -60,112 +60,4 @@ public interface DataOutputPlus extends DataOutput
         VIntCoding.writeUnsignedVInt(i, this);
     }
 
-
-    public static class ForwardingDataOutput implements DataOutput
-    {
-        protected final DataOutput out;
-
-        public ForwardingDataOutput(DataOutput out)
-        {
-            this.out = out;
-        }
-
-        public void write(byte[] b) throws IOException
-        {
-            out.write(b);
-        }
-
-        public void write(byte[] b, int off, int len) throws IOException
-        {
-            out.write(b, off, len);
-        }
-
-        public void write(int b) throws IOException
-        {
-            out.write(b);
-        }
-
-        public void writeBoolean(boolean v) throws IOException
-        {
-            out.writeBoolean(v);
-        }
-
-        public void writeByte(int v) throws IOException
-        {
-            out.writeByte(v);
-        }
-
-        public void writeBytes(String s) throws IOException
-        {
-            out.writeBytes(s);
-        }
-
-        public void writeChar(int v) throws IOException
-        {
-            out.writeChar(v);
-        }
-
-        public void writeChars(String s) throws IOException
-        {
-            out.writeChars(s);
-        }
-
-        public void writeDouble(double v) throws IOException
-        {
-            out.writeDouble(v);
-        }
-
-        public void writeFloat(float v) throws IOException
-        {
-            out.writeFloat(v);
-        }
-
-        public void writeInt(int v) throws IOException
-        {
-            out.writeInt(v);
-        }
-
-        public void writeLong(long v) throws IOException
-        {
-            out.writeLong(v);
-        }
-
-        public void writeShort(int v) throws IOException
-        {
-            out.writeShort(v);
-        }
-
-        public void writeUTF(String s) throws IOException
-        {
-            out.writeUTF(s);
-        }
-
-    }
-
-    public static class DataOutputPlusAdapter extends ForwardingDataOutput implements DataOutputPlus
-    {
-
-        public DataOutputPlusAdapter(DataOutput out)
-        {
-            super(out);
-        }
-
-        public void write(ByteBuffer buffer) throws IOException
-        {
-            if (buffer.hasArray())
-                out.write(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
-            else
-                throw new UnsupportedOperationException("IMPLEMENT ME");
-        }
-
-        public void write(Memory memory, long offset, long length) throws IOException
-        {
-            throw new UnsupportedOperationException("IMPLEMENT ME");
-        }
-
-        public <R> R applyToChannel(Function<WritableByteChannel, R> c) throws
IOException
-        {
-            throw new UnsupportedOperationException("IMPLEMENT ME");
-        }
-    }
 }


Mime
View raw message