git commit: Move ByteBuffer functions to ByteBufferUtil and avoid duplication

2014-03-13 Thread slebresne
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 3e2c61057 - 8a52f5af4


Move ByteBuffer functions to ByteBufferUtil and avoid duplication


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

Branch: refs/heads/cassandra-2.1
Commit: 8a52f5af4f97a9a3062fca2db914ad2fe7e93162
Parents: 3e2c610
Author: Sylvain Lebresne sylv...@datastax.com
Authored: Thu Mar 13 09:11:44 2014 +0100
Committer: Sylvain Lebresne sylv...@datastax.com
Committed: Thu Mar 13 09:12:13 2014 +0100

--
 .../db/composites/AbstractComposite.java|  5 +-
 .../db/marshal/AbstractCompositeType.java   | 63 
 .../cassandra/db/marshal/CollectionType.java|  6 --
 .../cassandra/db/marshal/CompositeType.java | 12 ++--
 .../db/marshal/DynamicCompositeType.java| 14 ++---
 .../serializers/CollectionSerializer.java   |  6 --
 .../cassandra/serializers/ListSerializer.java   |  9 ++-
 .../cassandra/serializers/MapSerializer.java| 17 ++
 .../cassandra/serializers/SetSerializer.java|  9 ++-
 .../apache/cassandra/utils/ByteBufferUtil.java  | 37 
 10 files changed, 80 insertions(+), 98 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8a52f5af/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
--
diff --git a/src/java/org/apache/cassandra/db/composites/AbstractComposite.java 
b/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
index fbff930..9741767 100644
--- a/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
+++ b/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
@@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
 import org.apache.cassandra.db.filter.ColumnSlice;
 import org.apache.cassandra.db.marshal.AbstractCompositeType;
 import org.apache.cassandra.db.marshal.CompositeType;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 public abstract class AbstractComposite implements Composite
 {
@@ -75,12 +76,12 @@ public abstract class AbstractComposite implements Composite
 // See org.apache.cassandra.db.marshal.CompositeType for details.
 ByteBuffer result = ByteBuffer.allocate(dataSize() + 3 * size() + 
(isStatic() ? 2 : 0));
 if (isStatic())
-AbstractCompositeType.putShortLength(result, 
CompositeType.STATIC_MARKER);
+ByteBufferUtil.writeShortLength(result, 
CompositeType.STATIC_MARKER);
 
 for (int i = 0; i  size(); i++)
 {
 ByteBuffer bb = get(i);
-AbstractCompositeType.putShortLength(result, bb.remaining());
+ByteBufferUtil.writeShortLength(result, bb.remaining());
 result.put(bb.duplicate());
 result.put((byte)0);
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8a52f5af/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
--
diff --git 
a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java 
b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
index 236abc7..8f3aec4 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
@@ -17,15 +17,16 @@
  */
 package org.apache.cassandra.db.marshal;
 
-import org.apache.cassandra.serializers.TypeSerializer;
-import org.apache.cassandra.serializers.BytesSerializer;
-import org.apache.cassandra.serializers.MarshalException;
-
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.cassandra.serializers.TypeSerializer;
+import org.apache.cassandra.serializers.BytesSerializer;
+import org.apache.cassandra.serializers.MarshalException;
+import org.apache.cassandra.utils.ByteBufferUtil;
+
 /**
  * A class avoiding class duplication between CompositeType and
  * DynamicCompositeType.
@@ -34,44 +35,6 @@ import java.util.List;
  */
 public abstract class AbstractCompositeType extends AbstractTypeByteBuffer
 {
-
-// changes bb position
-public static int getShortLength(ByteBuffer bb)
-{
-int length = (bb.get()  0xFF)  8;
-return length | (bb.get()  0xFF);
-}
-
-// Doesn't change bb position
-protected static int getShortLength(ByteBuffer bb, int position)
-{
-int length = (bb.get(position)  0xFF)  8;
-return length | (bb.get(position + 1)  0xFF);
-}
-
-// changes bb position
-public static void putShortLength(ByteBuffer bb, int 

[03/15] git commit: Move ByteBuffer functions to ByteBufferUtil and avoid duplication

2014-03-13 Thread xedin
Move ByteBuffer functions to ByteBufferUtil and avoid duplication


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

Branch: refs/heads/trunk
Commit: 8a52f5af4f97a9a3062fca2db914ad2fe7e93162
Parents: 3e2c610
Author: Sylvain Lebresne sylv...@datastax.com
Authored: Thu Mar 13 09:11:44 2014 +0100
Committer: Sylvain Lebresne sylv...@datastax.com
Committed: Thu Mar 13 09:12:13 2014 +0100

--
 .../db/composites/AbstractComposite.java|  5 +-
 .../db/marshal/AbstractCompositeType.java   | 63 
 .../cassandra/db/marshal/CollectionType.java|  6 --
 .../cassandra/db/marshal/CompositeType.java | 12 ++--
 .../db/marshal/DynamicCompositeType.java| 14 ++---
 .../serializers/CollectionSerializer.java   |  6 --
 .../cassandra/serializers/ListSerializer.java   |  9 ++-
 .../cassandra/serializers/MapSerializer.java| 17 ++
 .../cassandra/serializers/SetSerializer.java|  9 ++-
 .../apache/cassandra/utils/ByteBufferUtil.java  | 37 
 10 files changed, 80 insertions(+), 98 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8a52f5af/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
--
diff --git a/src/java/org/apache/cassandra/db/composites/AbstractComposite.java 
b/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
index fbff930..9741767 100644
--- a/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
+++ b/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
@@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
 import org.apache.cassandra.db.filter.ColumnSlice;
 import org.apache.cassandra.db.marshal.AbstractCompositeType;
 import org.apache.cassandra.db.marshal.CompositeType;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 public abstract class AbstractComposite implements Composite
 {
@@ -75,12 +76,12 @@ public abstract class AbstractComposite implements Composite
 // See org.apache.cassandra.db.marshal.CompositeType for details.
 ByteBuffer result = ByteBuffer.allocate(dataSize() + 3 * size() + 
(isStatic() ? 2 : 0));
 if (isStatic())
-AbstractCompositeType.putShortLength(result, 
CompositeType.STATIC_MARKER);
+ByteBufferUtil.writeShortLength(result, 
CompositeType.STATIC_MARKER);
 
 for (int i = 0; i  size(); i++)
 {
 ByteBuffer bb = get(i);
-AbstractCompositeType.putShortLength(result, bb.remaining());
+ByteBufferUtil.writeShortLength(result, bb.remaining());
 result.put(bb.duplicate());
 result.put((byte)0);
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8a52f5af/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
--
diff --git 
a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java 
b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
index 236abc7..8f3aec4 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
@@ -17,15 +17,16 @@
  */
 package org.apache.cassandra.db.marshal;
 
-import org.apache.cassandra.serializers.TypeSerializer;
-import org.apache.cassandra.serializers.BytesSerializer;
-import org.apache.cassandra.serializers.MarshalException;
-
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.cassandra.serializers.TypeSerializer;
+import org.apache.cassandra.serializers.BytesSerializer;
+import org.apache.cassandra.serializers.MarshalException;
+import org.apache.cassandra.utils.ByteBufferUtil;
+
 /**
  * A class avoiding class duplication between CompositeType and
  * DynamicCompositeType.
@@ -34,44 +35,6 @@ import java.util.List;
  */
 public abstract class AbstractCompositeType extends AbstractTypeByteBuffer
 {
-
-// changes bb position
-public static int getShortLength(ByteBuffer bb)
-{
-int length = (bb.get()  0xFF)  8;
-return length | (bb.get()  0xFF);
-}
-
-// Doesn't change bb position
-protected static int getShortLength(ByteBuffer bb, int position)
-{
-int length = (bb.get(position)  0xFF)  8;
-return length | (bb.get(position + 1)  0xFF);
-}
-
-// changes bb position
-public static void putShortLength(ByteBuffer bb, int length)
-{
-bb.put((byte) ((length  8)  0xFF));
-bb.put((byte) (length  0xFF));
-