cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [03/10] git commit: add CqlPagingRecordReader support for ReversedType in Thrift table patch by Alex Liu; reviewed by jbellis for CASSANDRA-5718
Date Mon, 05 Aug 2013 22:00:29 GMT
add CqlPagingRecordReader support for ReversedType in Thrift table
patch by Alex Liu; reviewed by jbellis for CASSANDRA-5718


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

Branch: refs/heads/cassandra-2.0
Commit: bcfe352ea6ed3786f274b90191f988210360689d
Parents: 75d0ac9
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Mon Aug 5 16:54:03 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Mon Aug 5 16:54:03 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                       |  2 ++
 .../hadoop/cql3/CqlPagingRecordReader.java        | 18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/bcfe352e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 960a8c2..25c0217 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -10,6 +10,8 @@
    (CASSANDRA-5752)
  * add "all time blocked" to StatusLogger output (CASSANDRA-5825)
  * Future-proof inter-major-version schema migrations (CASSANDRA-5845)
+ * (Hadoop) add CqlPagingRecordReader support for ReversedType in Thrift table
+   (CASSANDRA-5718)
 
 
 1.2.8

http://git-wip-us.apache.org/repos/asf/cassandra/blob/bcfe352e/src/java/org/apache/cassandra/hadoop/cql3/CqlPagingRecordReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/cql3/CqlPagingRecordReader.java b/src/java/org/apache/cassandra/hadoop/cql3/CqlPagingRecordReader.java
index c6eb46d..d1a089f 100644
--- a/src/java/org/apache/cassandra/hadoop/cql3/CqlPagingRecordReader.java
+++ b/src/java/org/apache/cassandra/hadoop/cql3/CqlPagingRecordReader.java
@@ -35,6 +35,7 @@ import org.apache.cassandra.cql3.ColumnIdentifier;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.CompositeType;
 import org.apache.cassandra.db.marshal.LongType;
+import org.apache.cassandra.db.marshal.ReversedType;
 import org.apache.cassandra.db.marshal.TypeParser;
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.exceptions.ConfigurationException;
@@ -493,7 +494,7 @@ public class CqlPagingRecordReader extends RecordReader<Map<String,
ByteBuffer>,
         private Pair<Integer, String> whereClause(List<BoundColumn> column, int
position)
         {
             if (position == column.size() - 1 || column.get(position + 1).value == null)
-                return Pair.create(position + 2, String.format(" AND %s > ? ", quote(column.get(position).name)));
+                return Pair.create(position + 2, String.format(" AND %s %s ? ", quote(column.get(position).name),
column.get(position).reversed ? " < " : " > "));
 
             Pair<Integer, String> clause = whereClause(column, position + 1);
             return Pair.create(clause.left, String.format(" AND %s = ? %s", quote(column.get(position).name),
clause.right));
@@ -688,6 +689,20 @@ public class CqlPagingRecordReader extends RecordReader<Map<String,
ByteBuffer>,
             clusterColumns.add(new BoundColumn(key));
 
         parseKeyValidators(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.columns.get(2).getValue())));
+        
+        Column rawComparator = cqlRow.columns.get(3);
+        String comparator = ByteBufferUtil.string(ByteBuffer.wrap(rawComparator.getValue()));
+        logger.debug("comparator: {}", comparator);
+        AbstractType comparatorValidator = parseType(comparator);
+        if (comparatorValidator instanceof CompositeType)
+        {
+            for (int i = 0; i < clusterColumns.size(); i++)
+                clusterColumns.get(i).reversed = (((CompositeType) comparatorValidator).types.get(i)
instanceof ReversedType);
+        }
+        else if (comparatorValidator instanceof ReversedType)
+        {
+            clusterColumns.get(0).reversed = true;
+        }
     }
 
     /** 
@@ -778,6 +793,7 @@ public class CqlPagingRecordReader extends RecordReader<Map<String,
ByteBuffer>,
         final String name;
         ByteBuffer value;
         AbstractType<?> validator;
+        boolean reversed = false;
 
         public BoundColumn(String name)
         {


Mime
View raw message