cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r806342 - in /incubator/cassandra/trunk: src/java/org/apache/cassandra/db/marshal/LongType.java test/system/test_server.py
Date Thu, 20 Aug 2009 20:37:45 GMT
Author: jbellis
Date: Thu Aug 20 20:37:45 2009
New Revision: 806342

URL: http://svn.apache.org/viewvc?rev=806342&view=rev
Log:
change LongType to read longs in big endian order to be consistent with network order and
the UUID types.
patch by jbellis and Evan Weaver; reviewed by Michael Greene for CASSANDRA-384

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java
    incubator/cassandra/trunk/test/system/test_server.py

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java?rev=806342&r1=806341&r2=806342&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java Thu Aug
20 20:37:45 2009
@@ -37,8 +37,8 @@
             return 1;
         }
 
-        long L1 = ByteBuffer.wrap(o1).order(ByteOrder.LITTLE_ENDIAN).getLong();
-        long L2 = ByteBuffer.wrap(o2).order(ByteOrder.LITTLE_ENDIAN).getLong();
+        long L1 = ByteBuffer.wrap(o1).getLong();
+        long L2 = ByteBuffer.wrap(o2).getLong();
         return Long.valueOf(L1).compareTo(Long.valueOf(L2));
     }
 

Modified: incubator/cassandra/trunk/test/system/test_server.py
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/system/test_server.py?rev=806342&r1=806341&r2=806342&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/system/test_server.py (original)
+++ incubator/cassandra/trunk/test/system/test_server.py Thu Aug 20 20:37:45 2009
@@ -26,7 +26,7 @@
 
 
 def _i64(n):
-    return struct.pack('<q', n) # little endian, to match cassandra.db.marshal.LongType
+    return struct.pack('>q', n) # big endian = network order
 
 _SIMPLE_COLUMNS = [Column('c1', 'value1', 0),
                    Column('c2', 'value2', 0)]
@@ -179,6 +179,20 @@
                  for result in client.get_slice('Keyspace1', 'key1', column_parent, p, ConsistencyLevel.ONE)]
         assert slice == [Column(_i64(6), 'value6', 0)], slice
         
+    def test_long_order(self):
+        def long_xrange(start, stop, step):
+            i = start
+            while i < stop:
+                yield i
+                i += step
+        L = []
+        for i in long_xrange(0, 104294967296, 429496729):
+            name = _i64(i)
+            client.insert('Keyspace1', 'key1', ColumnPath('StandardLong1', column=name),
'v', 0, ConsistencyLevel.ONE)
+            L.append(name)
+        slice = [result.column.name for result in _big_slice('Keyspace1', 'key1', ColumnParent('StandardLong1'))]
+        assert slice == L, slice
+        
     def test_time_uuid(self):
         import uuid
         L = []



Mime
View raw message