cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Fix Subcolumn slice ends not respected
Date Mon, 22 Oct 2012 07:20:16 GMT
Updated Branches:
  refs/heads/trunk 81209f1c8 -> f02928f88


Fix Subcolumn slice ends not respected

patch by vijay; reviewed by thobbs & slebresne for CASSANDRA-4826


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

Branch: refs/heads/trunk
Commit: f02928f887ce58e317b87341a837c61068510bae
Parents: 81209f1
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Mon Oct 22 09:19:06 2012 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Mon Oct 22 09:19:06 2012 +0200

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../cassandra/db/filter/SliceQueryFilter.java      |   30 +++++++++-----
 2 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f02928f8/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9fbccb0..e14ffa7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -31,6 +31,7 @@
  * Fix potential NPE during CFS reload (CASSANDRA-4786)
  * Composite indexes may miss results (CASSANDRA-4796)
  * Move consistency level to the protocol level (CASSANDRA-4734, 4824)
+ * Fix Subcolumn slice ends not respected (CASSANDRA-4826)
 Merged from 1.1:
  * fix indexing empty column values (CASSANDRA-4832)
  * allow JdbcDate to compose null Date objects (CASSANDRA-4830)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f02928f8/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java b/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
index 2de284a..af63fa0 100644
--- a/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
+++ b/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
@@ -25,6 +25,7 @@ import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 
+import com.google.common.collect.AbstractIterator;
 import com.google.common.collect.Iterators;
 import com.google.common.collect.Lists;
 import org.slf4j.Logger;
@@ -104,7 +105,7 @@ public class SliceQueryFilter implements IFilter
         // we clone shallow, then add, under the theory that generally we're interested in
a relatively small number of subcolumns.
         // this may be a poor assumption.
         SuperColumn scFiltered = superColumn.cloneMeShallow();
-        Iterator<IColumn> subcolumns;
+        final Iterator<IColumn> subcolumns;
         if (reversed)
         {
             List<IColumn> columnsAsList = new ArrayList<IColumn>(superColumn.getSubColumns());
@@ -114,20 +115,27 @@ public class SliceQueryFilter implements IFilter
         {
             subcolumns = superColumn.getSubColumns().iterator();
         }
-
-        // iterate until we get to the "real" start column
-        Comparator<ByteBuffer> comparator = reversed ? superColumn.getComparator().reverseComparator
: superColumn.getComparator();
-        while (subcolumns.hasNext())
+        final Comparator<ByteBuffer> comparator = reversed ? superColumn.getComparator().reverseComparator
: superColumn.getComparator();
+        Iterator<IColumn> results = new AbstractIterator<IColumn>()
         {
-            IColumn column = subcolumns.next();
-            if (comparator.compare(column.name(), start()) >= 0)
+            protected IColumn computeNext()
             {
-                subcolumns = Iterators.concat(Iterators.singletonIterator(column), subcolumns);
-                break;
+                while (subcolumns.hasNext())
+                {
+                    IColumn subcolumn = subcolumns.next();
+                    // iterate until we get to the "real" start column
+                    if (comparator.compare(subcolumn.name(), start()) < 0)
+                        continue;
+                    // exit loop when columns are out of the range.
+                    if (finish().remaining() > 0 && comparator.compare(subcolumn.name(),
finish()) > 0)
+                        break;
+                    return subcolumn;
+                }
+                return endOfData();
             }
-        }
+        };
         // subcolumns is either empty now, or has been redefined in the loop above. either
is ok.
-        collectReducedColumns(scFiltered, subcolumns, gcBefore);
+        collectReducedColumns(scFiltered, results, gcBefore);
         return scFiltered;
     }
 


Mime
View raw message