cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Send correct metadata on SELECT COUNT
Date Tue, 24 Sep 2013 13:58:22 GMT
Updated Branches:
  refs/heads/cassandra-2.0 7c6e5525a -> 38ae1beef


Send correct metadata on SELECT COUNT

patch by slebresne; reviewed by iamaleksey for CASSANDRA-6080


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

Branch: refs/heads/cassandra-2.0
Commit: 38ae1beef6cbe42447bfc0c113e0f39b1442ca73
Parents: 7c6e552
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue Sep 24 15:57:40 2013 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue Sep 24 15:57:40 2013 +0200

----------------------------------------------------------------------
 CHANGES.txt                                              |  1 +
 src/java/org/apache/cassandra/cql3/ResultSet.java        | 11 +++++++----
 .../cassandra/cql3/statements/SelectStatement.java       |  4 +++-
 3 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ae1bee/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1bdb6a8..de51837 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,7 @@
  * Improve memory usage of metadata min/max column names (CASSANDRA-6077)
  * Fix thrift validation refusing row markers on CQL3 tables (CASSANDRA-6081)
  * Fix insertion of collections with CAS (CASSANDRA-6069)
+ * Correctly send metadata on SELECT COUNT (CASSANDRA-6080)
 Merged from 1.2:
  * Allow where clause conditions to be in parenthesis (CASSANDRA-6037)
  * Do not open non-ssl storage port if encryption option is all (CASSANDRA-3916)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ae1bee/src/java/org/apache/cassandra/cql3/ResultSet.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ResultSet.java b/src/java/org/apache/cassandra/cql3/ResultSet.java
index d15c7d0..e4f27f9 100644
--- a/src/java/org/apache/cassandra/cql3/ResultSet.java
+++ b/src/java/org/apache/cassandra/cql3/ResultSet.java
@@ -102,13 +102,16 @@ public class ResultSet
         return makeCountResult(ksName, cfName, count, alias);
     }
 
-    public static ResultSet makeCountResult(String ksName, String cfName, long count, ColumnIdentifier
alias)
+    public static ResultSet.Metadata makeCountMetadata(String ksName, String cfName, ColumnIdentifier
alias)
     {
         ColumnSpecification spec = new ColumnSpecification(ksName, cfName, alias == null
? COUNT_COLUMN : alias, LongType.instance);
-        Metadata newMetadata = new Metadata(Collections.singletonList(spec));
-        List<List<ByteBuffer>> newRows = Collections.singletonList(Collections.singletonList(ByteBufferUtil.bytes(count)));
+        return new Metadata(Collections.singletonList(spec));
+    }
 
-        return new ResultSet(newMetadata, newRows);
+    public static ResultSet makeCountResult(String ksName, String cfName, long count, ColumnIdentifier
alias)
+    {
+        List<List<ByteBuffer>> newRows = Collections.singletonList(Collections.singletonList(ByteBufferUtil.bytes(count)));
+        return new ResultSet(makeCountMetadata(ksName, cfName, alias), newRows);
     }
 
     public CqlResult toThriftResult()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ae1bee/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index ff6d4d3..85e9cbc 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -104,7 +104,9 @@ public class SelectStatement implements CQLStatement
 
     public ResultSet.Metadata getResultMetadata()
     {
-        return selection.getResultMetadata();
+        return parameters.isCount
+             ? ResultSet.makeCountMetadata(keyspace(), columnFamily(), parameters.countAlias)
+             : selection.getResultMetadata();
     }
 
     public int getBoundsTerms()


Mime
View raw message