cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [6/7] git commit: merge from 1.2
Date Sun, 01 Sep 2013 02:36:21 GMT
merge from 1.2


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

Branch: refs/heads/cassandra-2.0
Commit: 7375c03aa6b6b8c97b9485e8a94b26a9ca1ee465
Parents: bd1a703
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Sat Aug 31 21:36:03 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Sat Aug 31 21:36:03 2013 -0500

----------------------------------------------------------------------
 .../db/columniterator/SSTableNamesIterator.java | 35 ++++++++++++++++----
 1 file changed, 28 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7375c03a/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java b/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
index 3467244..3e8c0a0 100644
--- a/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
+++ b/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
@@ -141,7 +141,7 @@ public class SSTableNamesIterator extends AbstractIterator<OnDiskAtom>
implement
         if (indexList.isEmpty())
         {
             int columnCount = sstable.descriptor.version.hasRowSizeAndColumnCount ? file.readInt()
: Integer.MAX_VALUE;
-            readSimpleColumns(file, columns, result, columnCount);
+            readSimpleColumns(sstable.metadata, file, columns, result, columnCount);
         }
         else
         {
@@ -152,26 +152,35 @@ public class SSTableNamesIterator extends AbstractIterator<OnDiskAtom>
implement
         iter = result.iterator();
     }
 
-    private void readSimpleColumns(FileDataInput file, SortedSet<ByteBuffer> columnNames,
List<OnDiskAtom> result, int columnCount)
+    private void readSimpleColumns(CFMetaData metadata,
+                                   FileDataInput file,
+                                   SortedSet<ByteBuffer> columnNames,
+                                   List<OnDiskAtom> result,
+                                   int columnCount)
+    throws IOException
     {
+        AbstractType<?> comparator = metadata.comparator;
         Iterator<OnDiskAtom> atomIterator = cf.metadata().getOnDiskIterator(file, columnCount,
sstable.descriptor.version);
-        int n = 0;
+        ByteBuffer maximalColumnName = columnNames.last();
         while (atomIterator.hasNext())
         {
             OnDiskAtom column = atomIterator.next();
+            ByteBuffer columnName = column.name();
             if (column instanceof Column)
             {
-                if (columnNames.contains(column.name()))
+                if (columnNames.contains(columnName))
                 {
                     result.add(column);
-                    if (++n >= columns.size())
-                        break;
                 }
             }
             else
             {
                 result.add(column);
             }
+
+            // Already consumed all of this block that's going to have columns that apply
to this query.
+            if (comparator.compare(columnName, maximalColumnName) >= 0)
+                break;
         }
     }
 
@@ -207,6 +216,12 @@ public class SSTableNamesIterator extends AbstractIterator<OnDiskAtom>
implement
         {
             long positionToSeek = basePosition + indexInfo.offset;
 
+            // SortedSet.subSet() is end-exclusive, so we special-case that
+            // if it's one of the columns we're looking for
+            ByteBuffer maximalColumnName = columnNames.contains(indexInfo.lastName)
+                                         ? indexInfo.lastName
+                                         : columnNames.subSet(indexInfo.firstName, indexInfo.lastName).last();
+
             // With new promoted indexes, our first seek in the data file will happen at
that point.
             if (file == null)
                 file = createFileDataInput(positionToSeek);
@@ -215,13 +230,19 @@ public class SSTableNamesIterator extends AbstractIterator<OnDiskAtom>
implement
             Iterator<OnDiskAtom> atomIterator = cf.metadata().getOnDiskIterator(file,
Integer.MAX_VALUE, sstable.descriptor.version);
             file.seek(positionToSeek);
             FileMark mark = file.mark();
+
             // TODO only completely deserialize columns we are interested in
             while (file.bytesPastMark(mark) < indexInfo.width)
             {
                 OnDiskAtom column = atomIterator.next();
+                ByteBuffer columnName = column.name();
                 // we check vs the original Set, not the filtered List, for efficiency
-                if (!(column instanceof Column) || columnNames.contains(column.name()))
+                if (!(column instanceof Column) || columnNames.contains(columnName))
                     result.add(column);
+
+                // Already consumed all of this block that's going to have columns that apply
to this query.
+                if (comparator.compare(columnName, maximalColumnName) >= 0)
+                    break;
             }
         }
     }


Mime
View raw message