cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject cassandra git commit: Avoid stack overflow on large clustering IN values
Date Fri, 12 Dec 2014 17:41:45 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 3f3d0edba -> 9dc9185f5


Avoid stack overflow on large clustering IN values

Patch by Tyler Hobbs; reviewed by Benjamin Lerer for CASSANDRA-8410


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

Branch: refs/heads/cassandra-2.0
Commit: 9dc9185f5c7172915485f713dbbb6b78b22d0f66
Parents: 3f3d0ed
Author: Tyler Hobbs <tyler@datastax.com>
Authored: Fri Dec 12 11:41:06 2014 -0600
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Fri Dec 12 11:41:06 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +
 .../apache/cassandra/db/filter/ColumnSlice.java | 48 ++++++++++----------
 2 files changed, 26 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9dc9185f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index cc426bb..6cecf99 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.12:
+ * Avoid StackOverflowError when a large list of IN values
+   is used for a clustering column (CASSANDRA-8410)
  * Fix NPE when writetime() or ttl() calls are wrapped by
    another function call (CASSANDRA-8451)
  * Fix NPE after dropping a keyspace (CASSANDRA-8332)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9dc9185f/src/java/org/apache/cassandra/db/filter/ColumnSlice.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/filter/ColumnSlice.java b/src/java/org/apache/cassandra/db/filter/ColumnSlice.java
index 9eff12a..6a9efbb 100644
--- a/src/java/org/apache/cassandra/db/filter/ColumnSlice.java
+++ b/src/java/org/apache/cassandra/db/filter/ColumnSlice.java
@@ -130,36 +130,36 @@ public class ColumnSlice
 
         protected Column computeNext()
         {
-            if (currentSlice == null)
+            while (currentSlice != null || idx < slices.length)
             {
-                if (idx >= slices.length)
-                    return endOfData();
-
-                ColumnSlice slice = slices[idx++];
-                // Note: we specialize the case of start == "" and finish = "" because it
is slightly more efficient, but also they have a specific
-                // meaning (namely, they always extend to the beginning/end of the range).
-                if (slice.start.remaining() == 0)
+                if (currentSlice == null)
                 {
-                    if (slice.finish.remaining() == 0)
-                        currentSlice = map.values().iterator();
+                    ColumnSlice slice = slices[idx++];
+                    // Note: we specialize the case of start == "" and finish = "" because
it is slightly more efficient, but also they have a specific
+                    // meaning (namely, they always extend to the beginning/end of the range).
+                    if (slice.start.remaining() == 0)
+                    {
+                        if (slice.finish.remaining() == 0)
+                            currentSlice = map.values().iterator();
+                        else
+                            currentSlice = map.headMap(slice.finish, true).values().iterator();
+                    }
+                    else if (slice.finish.remaining() == 0)
+                    {
+                        currentSlice = map.tailMap(slice.start, true).values().iterator();
+                    }
                     else
-                        currentSlice = map.headMap(slice.finish, true).values().iterator();
-                }
-                else if (slice.finish.remaining() == 0)
-                {
-                    currentSlice = map.tailMap(slice.start, true).values().iterator();
+                    {
+                        currentSlice = map.subMap(slice.start, true, slice.finish, true).values().iterator();
+                    }
                 }
-                else
-                {
-                    currentSlice = map.subMap(slice.start, true, slice.finish, true).values().iterator();
-                }
-            }
 
-            if (currentSlice.hasNext())
-                return currentSlice.next();
+                if (currentSlice.hasNext())
+                    return currentSlice.next();
 
-            currentSlice = null;
-            return computeNext();
+                currentSlice = null;
+            }
+            return endOfData();
         }
     }
 }


Mime
View raw message