cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject git commit: rename away misleading Next from comparator method names; add docstrings
Date Wed, 02 May 2012 22:06:43 GMT
Updated Branches:
  refs/heads/trunk 087f902d6 -> bfe2dfb50


rename away misleading Next from comparator method names; add docstrings


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

Branch: refs/heads/trunk
Commit: bfe2dfb50d5b8f1f322a7b3380df3f74f24ab960
Parents: 087f902
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Wed Apr 18 17:07:15 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Wed May 2 17:03:25 2012 -0500

----------------------------------------------------------------------
 .../db/marshal/AbstractCompositeType.java          |   43 +++++++++++----
 .../apache/cassandra/db/marshal/CompositeType.java |   10 ++--
 .../cassandra/db/marshal/DynamicCompositeType.java |   10 ++--
 3 files changed, 42 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/bfe2dfb5/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 eab1548..d319037 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
@@ -70,7 +70,7 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
 
         while (bb1.remaining() > 0 && bb2.remaining() > 0)
         {
-            AbstractType<?> comparator = getNextComparator(i, bb1, bb2);
+            AbstractType<?> comparator = getComparator(i, bb1, bb2);
 
             ByteBuffer value1 = getWithShortLength(bb1);
             ByteBuffer value2 = getWithShortLength(bb2);
@@ -117,7 +117,7 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
         int i = 0;
         while (bb.remaining() > 0)
         {
-            getNextComparator(i++, bb);
+            getComparator(i++, bb);
             l.add(getWithShortLength(bb));
             bb.get(); // skip end-of-component
         }
@@ -135,7 +135,7 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
             if (bb.remaining() != bytes.remaining())
                 sb.append(":");
 
-            AbstractType<?> comparator = getAndAppendNextComparator(i, bb, sb);
+            AbstractType<?> comparator = getAndAppendComparator(i, bb, sb);
             ByteBuffer value = getWithShortLength(bb);
 
             sb.append(comparator.getString(value));
@@ -172,7 +172,7 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
 
         while (bb.remaining() > 0)
         {
-            AbstractType comparator = getNextComparator(i, bb);
+            AbstractType comparator = getComparator(i, bb);
             ByteBuffer value = getWithShortLength(bb);
 
             list.add( new CompositeComponent(comparator,value) );
@@ -205,7 +205,7 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
                 break;
             }
 
-            ParsedComparator p = parseNextComparator(i, part);
+            ParsedComparator p = parseComparator(i, part);
             AbstractType<?> type = p.getAbstractType();
             part = p.getRemainingPart();
 
@@ -240,7 +240,7 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
         int i = 0;
         while (bb.remaining() > 0)
         {
-            AbstractType<?> comparator = validateNextComparator(i, bb);
+            AbstractType<?> comparator = validateComparator(i, bb);
 
             if (bb.remaining() < 2)
                 throw new MarshalException("Not enough bytes to read value size of component
" + i);
@@ -271,11 +271,32 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
         return value;
     }
 
-    abstract protected AbstractType<?> getNextComparator(int i, ByteBuffer bb);
-    abstract protected AbstractType<?> getNextComparator(int i, ByteBuffer bb1, ByteBuffer
bb2);
-    abstract protected AbstractType<?> getAndAppendNextComparator(int i, ByteBuffer
bb, StringBuilder sb);
-    abstract protected ParsedComparator parseNextComparator(int i, String part);
-    abstract protected AbstractType<?> validateNextComparator(int i, ByteBuffer bb)
throws MarshalException;
+    /**
+     * @return the comparator for the given component. static CompositeType will consult
+     * @param i; DynamicCompositeType will read the type information from @param bb
+     */
+    abstract protected AbstractType<?> getComparator(int i, ByteBuffer bb);
+
+    /**
+     * Adds DynamicCompositeType type information from @param bb1 to @param bb2.
+     * @param i is ignored.
+     */
+    abstract protected AbstractType<?> getComparator(int i, ByteBuffer bb1, ByteBuffer
bb2);
+
+    /**
+     * Adds type information from @param bb to @param sb.  @param i is ignored.
+     */
+    abstract protected AbstractType<?> getAndAppendComparator(int i, ByteBuffer bb,
StringBuilder sb);
+
+    /**
+     * Like getComparator, but validates that @param i does not exceed the defined range
+     */
+    abstract protected AbstractType<?> validateComparator(int i, ByteBuffer bb) throws
MarshalException;
+
+    /**
+     * Used by fromString
+     */
+    abstract protected ParsedComparator parseComparator(int i, String part);
 
     protected static interface ParsedComparator
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/bfe2dfb5/src/java/org/apache/cassandra/db/marshal/CompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/CompositeType.java b/src/java/org/apache/cassandra/db/marshal/CompositeType.java
index 2e32725..1b59ae9 100644
--- a/src/java/org/apache/cassandra/db/marshal/CompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/CompositeType.java
@@ -80,27 +80,27 @@ public class CompositeType extends AbstractCompositeType
         this.types = types;
     }
 
-    protected AbstractType<?> getNextComparator(int i, ByteBuffer bb)
+    protected AbstractType<?> getComparator(int i, ByteBuffer bb)
     {
         return types.get(i);
     }
 
-    protected AbstractType<?> getNextComparator(int i, ByteBuffer bb1, ByteBuffer bb2)
+    protected AbstractType<?> getComparator(int i, ByteBuffer bb1, ByteBuffer bb2)
     {
         return types.get(i);
     }
 
-    protected AbstractType<?> getAndAppendNextComparator(int i, ByteBuffer bb, StringBuilder
sb)
+    protected AbstractType<?> getAndAppendComparator(int i, ByteBuffer bb, StringBuilder
sb)
     {
         return types.get(i);
     }
 
-    protected ParsedComparator parseNextComparator(int i, String part)
+    protected ParsedComparator parseComparator(int i, String part)
     {
         return new StaticParsedComparator(types.get(i), part);
     }
 
-    protected AbstractType<?> validateNextComparator(int i, ByteBuffer bb) throws MarshalException
+    protected AbstractType<?> validateComparator(int i, ByteBuffer bb) throws MarshalException
     {
         if (i >= types.size())
             throw new MarshalException("Too many bytes for comparator");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/bfe2dfb5/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java b/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
index 89116f2..e3f4839 100644
--- a/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
@@ -102,12 +102,12 @@ public class DynamicCompositeType extends AbstractCompositeType
         }
     }
 
-    protected AbstractType<?> getNextComparator(int i, ByteBuffer bb)
+    protected AbstractType<?> getComparator(int i, ByteBuffer bb)
     {
         return getComparator(bb);
     }
 
-    protected AbstractType<?> getNextComparator(int i, ByteBuffer bb1, ByteBuffer bb2)
+    protected AbstractType<?> getComparator(int i, ByteBuffer bb1, ByteBuffer bb2)
     {
         AbstractType<?> comp1 = getComparator(bb1);
         AbstractType<?> comp2 = getComparator(bb2);
@@ -135,7 +135,7 @@ public class DynamicCompositeType extends AbstractCompositeType
         return comp1;
     }
 
-    protected AbstractType<?> getAndAppendNextComparator(int i, ByteBuffer bb, StringBuilder
sb)
+    protected AbstractType<?> getAndAppendComparator(int i, ByteBuffer bb, StringBuilder
sb)
     {
         try
         {
@@ -162,12 +162,12 @@ public class DynamicCompositeType extends AbstractCompositeType
         }
     }
 
-    protected ParsedComparator parseNextComparator(int i, String part)
+    protected ParsedComparator parseComparator(int i, String part)
     {
         return new DynamicParsedComparator(part);
     }
 
-    protected AbstractType<?> validateNextComparator(int i, ByteBuffer bb) throws MarshalException
+    protected AbstractType<?> validateComparator(int i, ByteBuffer bb) throws MarshalException
     {
         AbstractType<?> comparator = null;
         if (bb.remaining() < 2)


Mime
View raw message