cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r802078 - in /incubator/cassandra/trunk: src/java/org/apache/cassandra/db/filter/ src/java/org/apache/cassandra/io/ test/unit/org/apache/cassandra/db/
Date Fri, 07 Aug 2009 16:24:54 GMT
Author: jbellis
Date: Fri Aug  7 16:24:54 2009
New Revision: 802078

URL: http://svn.apache.org/viewvc?rev=802078&view=rev
Log:
tests + fix for bsearch returning not-found-to-the-right
patch by jbellis; reviewed by Jun Rao for CASSANDRA-351

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java?rev=802078&r1=802077&r2=802078&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java
Fri Aug  7 16:24:54 2009
@@ -49,7 +49,13 @@
             SortedSet<IndexHelper.IndexInfo> ranges = new TreeSet<IndexHelper.IndexInfo>(IndexHelper.getComparator(comparator));
             for (byte[] name : columns)
             {
-                ranges.add(indexList.get(IndexHelper.indexFor(name, indexList, comparator,
false)));
+                int index = IndexHelper.indexFor(name, indexList, comparator, false);
+                if (index == indexList.size())
+                    continue;
+                IndexHelper.IndexInfo indexInfo = indexList.get(index);
+                if (comparator.compare(name, indexInfo.firstName) < 0)
+                   continue;
+                ranges.add(indexInfo);
             }
 
             /* seek to the correct offset to the data */

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java?rev=802078&r1=802077&r2=802078&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
Fri Aug  7 16:24:54 2009
@@ -101,6 +101,8 @@
 
             columnStartPosition = file.getFilePointer();
             curRangeIndex = IndexHelper.indexFor(startColumn, indexes, comparator, isAscending);
+            if (!isAscending && curRangeIndex == indexes.size())
+                curRangeIndex--;
         }
 
         public ColumnFamily getEmptyColumnFamily()

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java?rev=802078&r1=802077&r2=802078&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java Fri Aug  7
16:24:54 2009
@@ -120,6 +120,10 @@
         return BloomFilter.serializer().deserialize(bufIn);
     }
 
+    /**
+     * the index of the IndexInfo in which @name will be found.
+     * If the index is @indexList.size(), the @name appears nowhere.
+     */
     public static int indexFor(byte[] name, List<IndexInfo> indexList, AbstractType
comparator, boolean ascending)
     {
         if (name.length == 0 && !ascending)

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java?rev=802078&r1=802077&r2=802078&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java Fri Aug  7
16:24:54 2009
@@ -84,6 +84,9 @@
 
                 cf = cfStore.getColumnFamily(new SliceQueryFilter(TEST_KEY, new QueryPath("Standard3"),
ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 0));
                 assertColumns(cf);
+
+                cf = cfStore.getColumnFamily(new NamesQueryFilter(TEST_KEY, new QueryPath("Standard3"),
"col99".getBytes()));
+                assertColumns(cf);
             }
         };
         reTest(table.getColumnFamilyStore("Standard3"), verify);
@@ -352,6 +355,12 @@
         assertEquals(new String(cf.getColumn("col1999".getBytes()).value()), "v1999");
         assertEquals(new String(cf.getColumn("col1998".getBytes()).value()), "v1998");
         assertEquals(new String(cf.getColumn("col1997".getBytes()).value()), "v1997");
+
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col9000".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 3);
+        assertColumns(cf, "col1997", "col1998", "col1999");
+
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col9000".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
+        assertColumns(cf);
     }
 
     @Test



Mime
View raw message