cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Fix requests with skipMetadata=false returning no metadata
Date Thu, 09 Oct 2014 18:43:45 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 708adca7d -> 0249363e8


Fix requests with skipMetadata=false returning no metadata

patch by slebresne; reviewed by thobbs for CASSANDRA-8054


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

Branch: refs/heads/cassandra-2.1
Commit: 0249363e89e4b860c9486816445cea360380f2ea
Parents: 708adca
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Thu Oct 9 20:41:32 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Thu Oct 9 20:41:32 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../org/apache/cassandra/cql3/ResultSet.java    | 30 ++++++++------------
 .../cql3/statements/SelectStatement.java        |  5 +++-
 .../cassandra/cql3/statements/Selection.java    |  2 +-
 .../transport/messages/ResultMessage.java       |  5 ----
 5 files changed, 19 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0249363e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 417e8c1..688dc32 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.1.1
+ * Fix EXECUTE request with skipMetadata=false returning no metadata
+   (CASSANDRA-8054)
  * Allow concurrent use of CQLBulkOutputFormat (CASSANDRA-7776)
  * Shutdown JVM on OOM (CASSANDRA-7507)
  * Upgrade netty version and enable epoll event loop (CASSANDRA-7761)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0249363e/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 25635fa..3928060 100644
--- a/src/java/org/apache/cassandra/cql3/ResultSet.java
+++ b/src/java/org/apache/cassandra/cql3/ResultSet.java
@@ -92,16 +92,6 @@ public class ResultSet
         }
     }
 
-    public ResultSet withPagingState(PagingState state)
-    {
-        if (state == null)
-            return this;
-
-        // The metadata is shared by all execution of a given statement. So if there is a
paging state
-        // we need to copy the metadata
-        return new ResultSet(metadata.withPagingState(state), rows);
-    }
-
     public ResultSet makeCountResult(ColumnIdentifier alias)
     {
         assert metadata.names != null;
@@ -250,14 +240,14 @@ public class ResultSet
 
         public static final Metadata EMPTY = new Metadata(EnumSet.of(Flag.NO_METADATA), null,
0, null);
 
-        public final EnumSet<Flag> flags;
+        private final EnumSet<Flag> flags;
         // Please note that columnCount can actually be smaller than names, even if names
is not null. This is
         // used to include columns in the resultSet that we need to do post-query re-orderings
         // (SelectStatement.orderResults) but that shouldn't be sent to the user as they
haven't been requested
         // (CASSANDRA-4911). So the serialization code will exclude any columns in name whose
index is >= columnCount.
         public final List<ColumnSpecification> names;
-        public final int columnCount;
-        public final PagingState pagingState;
+        private final int columnCount;
+        private PagingState pagingState;
 
         public Metadata(List<ColumnSpecification> names)
         {
@@ -274,6 +264,11 @@ public class ResultSet
             this.pagingState = pagingState;
         }
 
+        public Metadata copy()
+        {
+            return new Metadata(flags, names, columnCount, pagingState);
+        }
+
         // The maximum number of values that the ResultSet can hold. This can be bigger than
columnCount due to CASSANDRA-4911
         public int valueCount()
         {
@@ -305,14 +300,13 @@ public class ResultSet
             return true;
         }
 
-        public Metadata withPagingState(PagingState pagingState)
+        public void setHasMorePages(PagingState pagingState)
         {
             if (pagingState == null)
-                return this;
+                return;
 
-            EnumSet<Flag> newFlags = EnumSet.copyOf(flags);
-            newFlags.add(Flag.HAS_MORE_PAGES);
-            return new Metadata(newFlags, names, columnCount, pagingState);
+            flags.add(Flag.HAS_MORE_PAGES);
+            this.pagingState = pagingState;
         }
 
         public void setSkipMetadata()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0249363e/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 ccda356..a8c9d44 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -226,7 +226,10 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
             List<Row> page = pager.fetchPage(pageSize);
             ResultMessage.Rows msg = processResults(page, options, limit, now);
 
-            return pager.isExhausted() ? msg : msg.withPagingState(pager.state());
+            if (!pager.isExhausted())
+                msg.result.metadata.setHasMorePages(pager.state());
+
+            return msg;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0249363e/src/java/org/apache/cassandra/cql3/statements/Selection.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/Selection.java b/src/java/org/apache/cassandra/cql3/statements/Selection.java
index 0f0cb62..7893b4d 100644
--- a/src/java/org/apache/cassandra/cql3/statements/Selection.java
+++ b/src/java/org/apache/cassandra/cql3/statements/Selection.java
@@ -287,7 +287,7 @@ public abstract class Selection
 
         private ResultSetBuilder(long now)
         {
-            this.resultSet = new ResultSet(getResultMetadata(), new ArrayList<List<ByteBuffer>>());
+            this.resultSet = new ResultSet(getResultMetadata().copy(), new ArrayList<List<ByteBuffer>>());
             this.timestamps = collectTimestamps ? new long[columns.size()] : null;
             this.ttls = collectTTLs ? new int[columns.size()] : null;
             this.now = now;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0249363e/src/java/org/apache/cassandra/transport/messages/ResultMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/messages/ResultMessage.java b/src/java/org/apache/cassandra/transport/messages/ResultMessage.java
index 935a139..723beed 100644
--- a/src/java/org/apache/cassandra/transport/messages/ResultMessage.java
+++ b/src/java/org/apache/cassandra/transport/messages/ResultMessage.java
@@ -220,11 +220,6 @@ public abstract class ResultMessage extends Message.Response
             this.result = result;
         }
 
-        public Rows withPagingState(PagingState state)
-        {
-            return new Rows(result.withPagingState(state));
-        }
-
         public CqlResult toThriftResult()
         {
             return result.toThriftResult();


Mime
View raw message