cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1082807 - in /cassandra/branches/cassandra-0.7: CHANGES.txt src/java/org/apache/cassandra/db/ColumnFamilyStore.java test/system/__init__.py test/system/test_thrift_server.py
Date Fri, 18 Mar 2011 02:55:21 GMT
Author: jbellis
Date: Fri Mar 18 02:55:21 2011
New Revision: 1082807

URL: http://svn.apache.org/viewvc?rev=1082807&view=rev
Log:
fix comparator used for non-indexed secondary expressions inindex scan
patch by Roland Gude and jbellis for CASSANDRA-2347

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/branches/cassandra-0.7/test/system/__init__.py
    cassandra/branches/cassandra-0.7/test/system/test_thrift_server.py

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1082807&r1=1082806&r2=1082807&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Fri Mar 18 02:55:21 2011
@@ -8,6 +8,8 @@
  * queue secondary indexes for flush before the parent (CASSANDRA-2330)
  * shut down server for OOM on a Thrift thread (CASSANDRA-2269)
  * reduce contention on Table.flusherLock (CASSANDRA-1954)
+ * fix comparator used for non-indexed secondary expressions in index scan
+   (CASSANDRA-2347)
 
 
 0.7.4

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1082807&r1=1082806&r2=1082807&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Fri Mar 18 02:55:21 2011
@@ -1654,7 +1654,7 @@ public class ColumnFamilyStore implement
             IColumn column = data.getColumn(expression.column_name);
             if (column == null)
                 return false;
-            int v = data.getComparator().compare(column.value(), expression.value);
+            int v = data.metadata().getValueValidator(expression.column_name).compare(column.value(),
expression.value);
             if (!satisfies(v, expression.op))
                 return false;
         }

Modified: cassandra/branches/cassandra-0.7/test/system/__init__.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/system/__init__.py?rev=1082807&r1=1082806&r2=1082807&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/system/__init__.py (original)
+++ cassandra/branches/cassandra-0.7/test/system/__init__.py Fri Mar 18 02:55:21 2011
@@ -170,8 +170,9 @@ class ThriftTester(BaseTester):
             Cassandra.CfDef('Keyspace1', 'Super2', column_type='Super', subcomparator_type='LongType'),

             Cassandra.CfDef('Keyspace1', 'Super3', column_type='Super', subcomparator_type='LongType'),

             Cassandra.CfDef('Keyspace1', 'Super4', column_type='Super', subcomparator_type='UTF8Type'),
-            Cassandra.CfDef('Keyspace1', 'Indexed1', column_metadata=[Cassandra.ColumnDef('birthdate',
'LongType', Cassandra.IndexType.KEYS, 'birthdate')]),
-            Cassandra.CfDef('Keyspace1', 'Indexed2', comparator_type='TimeUUIDType', column_metadata=[Cassandra.ColumnDef(uuid.UUID('00000000-0000-1000-0000-000000000000').bytes,
'LongType', Cassandra.IndexType.KEYS, 'birthdate')]),
+            Cassandra.CfDef('Keyspace1', 'Indexed1', column_metadata=[Cassandra.ColumnDef('birthdate',
'LongType', Cassandra.IndexType.KEYS, 'birthdate_index')]),
+            Cassandra.CfDef('Keyspace1', 'Indexed2', comparator_type='TimeUUIDType', column_metadata=[Cassandra.ColumnDef(uuid.UUID('00000000-0000-1000-0000-000000000000').bytes,
'LongType', Cassandra.IndexType.KEYS)]),
+            Cassandra.CfDef('Keyspace1', 'Indexed3', comparator_type='TimeUUIDType', column_metadata=[Cassandra.ColumnDef(uuid.UUID('00000000-0000-1000-0000-000000000000').bytes,
'UTF8Type', Cassandra.IndexType.KEYS)]),
 
         ])
 

Modified: cassandra/branches/cassandra-0.7/test/system/test_thrift_server.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/system/test_thrift_server.py?rev=1082807&r1=1082806&r2=1082807&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/system/test_thrift_server.py (original)
+++ cassandra/branches/cassandra-0.7/test/system/test_thrift_server.py Fri Mar 18 02:55:21
2011
@@ -1518,7 +1518,22 @@ class TestMutations(ThriftTester):
         assert result[0].key == 'key3'
         assert len(result[0].columns) == 2, result[0].columns
         
-        cp = ColumnParent('Indexed2')
+    def test_index_scan_uuid_names(self):
+        _set_keyspace('Keyspace1')
+        sp = SlicePredicate(slice_range=SliceRange('', ''))
+        cp = ColumnParent('Indexed3') # timeuuid name, utf8 values
+        u = uuid.UUID('00000000-0000-1000-0000-000000000000').bytes
+        u2 = uuid.UUID('00000000-0000-1000-0000-000000000001').bytes
+        client.insert('key1', ColumnParent('Indexed3'), Column(u, 'a', 0), ConsistencyLevel.ONE)
+        client.insert('key1', ColumnParent('Indexed3'), Column(u2, 'b', 0), ConsistencyLevel.ONE)
+        # name comparator + data validator of incompatible types -- see CASSANDRA-2347
+        clause = IndexClause([IndexExpression(u, IndexOperator.EQ, 'a'),
+                              IndexExpression(u2, IndexOperator.EQ, 'b')], '')
+        result = client.get_indexed_slices(cp, clause, sp, ConsistencyLevel.ONE)
+        assert len(result) == 1, result
+
+        cp = ColumnParent('Indexed2') # timeuuid name, long values
+
         # name must be valid (TimeUUID)
         clause = IndexClause([IndexExpression('foo', IndexOperator.EQ, uuid.UUID('00000000-0000-1000-0000-000000000000').bytes)],
'')
         _expect_exception(lambda: client.get_indexed_slices(cp, clause, sp, ConsistencyLevel.ONE),
InvalidRequestException)



Mime
View raw message