cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r893835 - in /incubator/cassandra/branches/cassandra-0.5: CHANGES.txt src/java/org/apache/cassandra/service/CassandraServer.java test/system/test_server.py
Date Fri, 25 Dec 2009 03:00:55 GMT
Author: jbellis
Date: Fri Dec 25 03:00:55 2009
New Revision: 893835

URL: http://svn.apache.org/viewvc?rev=893835&view=rev
Log:
call thriftifyColumns for get_range_slice, fixing bugs w/ deletions and reversed.  patch by
jbellis; reviewed by goffinet for CASSANDRA-647

Modified:
    incubator/cassandra/branches/cassandra-0.5/CHANGES.txt
    incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/CassandraServer.java
    incubator/cassandra/branches/cassandra-0.5/test/system/test_server.py

Modified: incubator/cassandra/branches/cassandra-0.5/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.5/CHANGES.txt?rev=893835&r1=893834&r2=893835&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.5/CHANGES.txt (original)
+++ incubator/cassandra/branches/cassandra-0.5/CHANGES.txt Fri Dec 25 03:00:55 2009
@@ -1,3 +1,7 @@
+0.5.0 RC2
+ * fix bugs in converting get_slice_range results to Thrift (CASSANDRA-647)
+
+
 0.5.0 RC1
  * Fix potential NPE in get_range_slice (CASSANDRA-623)
  * add CRC32 to commitlog entries (CASSANDRA-605)

Modified: incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/CassandraServer.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/CassandraServer.java?rev=893835&r1=893834&r2=893835&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/CassandraServer.java
(original)
+++ incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/CassandraServer.java
Fri Dec 25 03:00:55 2009
@@ -140,6 +140,7 @@
 
         // we have to do the reversing here, since internally we pass results around in ColumnFamily
         // objects, which always sort their columns in the "natural" order
+        // TODO this is inconvenient for direct users of StorageProxy
         if (reverseOrder)
             Collections.reverse(thriftColumns);
         return thriftColumns;
@@ -579,24 +580,16 @@
         }
 
         List<KeySlice> keySlices = new ArrayList<KeySlice>(rows.size());
+        boolean reversed = predicate.slice_range != null && predicate.slice_range.reversed;
         for (Pair<String, Collection<IColumn>> row : rows)
         {
             Collection<IColumn> columns = row.right;
-            List<ColumnOrSuperColumn> svcList = new ArrayList<ColumnOrSuperColumn>(columns.size());
-            for (org.apache.cassandra.db.IColumn col : columns)
-            {
-                if (col instanceof org.apache.cassandra.db.Column)
-                    svcList.add(new ColumnOrSuperColumn(new org.apache.cassandra.service.Column(col.name(),
col.value(), col.timestamp()), null));
-                else if (col instanceof org.apache.cassandra.db.SuperColumn)
-                {
-                    Collection<IColumn> subICols = col.getSubColumns();
-                    List<org.apache.cassandra.service.Column> subCols = new ArrayList<org.apache.cassandra.service.Column>(subICols.size());
-                    for (IColumn subCol : subICols)
-                        subCols.add(new org.apache.cassandra.service.Column(subCol.name(),
subCol.value(), subCol.timestamp()));
-                    svcList.add(new ColumnOrSuperColumn(null, new org.apache.cassandra.service.SuperColumn(col.name(),
subCols)));
-                }
-            }
-            keySlices.add(new KeySlice(row.left, svcList));
+            List<ColumnOrSuperColumn> thriftifiedColumns;
+            if (DatabaseDescriptor.getColumnFamilyType(keyspace, column_parent.column_family).equals("Standard"))
+                thriftifiedColumns = thriftifyColumns(columns, reversed);
+            else
+                thriftifiedColumns = thriftifySuperColumns(columns, reversed);
+            keySlices.add(new KeySlice(row.left, thriftifiedColumns));
         }
 
         return keySlices;

Modified: incubator/cassandra/branches/cassandra-0.5/test/system/test_server.py
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.5/test/system/test_server.py?rev=893835&r1=893834&r2=893835&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.5/test/system/test_server.py (original)
+++ incubator/cassandra/branches/cassandra-0.5/test/system/test_server.py Fri Dec 25 03:00:55
2009
@@ -582,12 +582,20 @@
 
         # and reversed 
         result = client.get_range_slice('Keyspace1', cp, SlicePredicate(slice_range=SliceRange(start='col4',
finish='col2', reversed=True, count=5)), 'key1', 'key2', 5, ConsistencyLevel.ONE)
-        assert result[0].columns[0].column.name == 'col2'
-        assert result[0].columns[2].column.name == 'col4'
+        assert result[0].columns[0].column.name == 'col4'
+        assert result[0].columns[2].column.name == 'col2'
 
         # row limiting via count
         result = client.get_range_slice('Keyspace1', cp, SlicePredicate(slice_range=SliceRange(start='col2',
finish='col4', reversed=False, count=5)), 'key1', 'key2', 1, ConsistencyLevel.ONE)
         assert len(result) == 1
+
+        # removed data
+        client.remove('Keyspace1', 'key1', ColumnPath('Standard1', column='col1'), 1, ConsistencyLevel.ONE)
+        result = client.get_range_slice('Keyspace1', cp, SlicePredicate(slice_range=SliceRange('',
'')), 'key1', 'key2', 5, ConsistencyLevel.ONE)
+        assert len(result) == 2, result
+        assert result[0].columns[0].column.name == 'col2', result[0].columns[0].column.name
+        assert result[1].columns[0].column.name == 'col1'
+        
     
     def test_get_slice_by_names(self):
         _insert_range()
@@ -647,5 +655,3 @@
         ks1 = client.describe_keyspace("Keyspace1")
         assert set(ks1.keys()) == set(['Super1', 'Standard1', 'Standard2', 'StandardLong1',
'StandardLong2', 'Super3', 'Super2', 'Super4'])
         sysks = client.describe_keyspace("system")
-
-



Mime
View raw message