cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1177766 - in /cassandra/branches/cassandra-1.0: CHANGES.txt src/java/org/apache/cassandra/utils/ByteBufferUtil.java src/java/org/apache/cassandra/utils/FBUtilities.java
Date Fri, 30 Sep 2011 18:20:28 GMT
Author: jake
Date: Fri Sep 30 18:20:28 2011
New Revision: 1177766

URL: http://svn.apache.org/viewvc?rev=1177766&view=rev
Log:
Performance improvement for ByteBufferUtil.compareUnsigned
Patch by tjake; reviewed by jbellis for CASSANDRA-3286


Modified:
    cassandra/branches/cassandra-1.0/CHANGES.txt
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/utils/FBUtilities.java

Modified: cassandra/branches/cassandra-1.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/CHANGES.txt?rev=1177766&r1=1177765&r2=1177766&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-1.0/CHANGES.txt Fri Sep 30 18:20:28 2011
@@ -1,6 +1,7 @@
 1.0.1
  * describe_ring should include datacenter/topology information (CASSANDRA-2882)
  * Thrift sockets are not properly buffered (CASSANDRA-3261)
+ * performance improvement for bytebufferutil compare function (CASSANDRA-3286)
 
 
 1.0.0-final

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/utils/ByteBufferUtil.java?rev=1177766&r1=1177765&r2=1177766&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
Fri Sep 30 18:20:28 2011
@@ -83,6 +83,12 @@ public class ByteBufferUtil
         assert o1 != null;
         assert o2 != null;
 
+        if (o1.hasArray() && o2.hasArray())
+        {         
+            return FBUtilities.compareUnsigned(o1.array(), o2.array(), o1.position() + o1.arrayOffset(),
+                    o2.position() + o2.arrayOffset(), o1.remaining(), o2.remaining());
+        }
+        
         int minLength = Math.min(o1.remaining(), o2.remaining());
         for (int x = 0, i = o1.position(), j = o2.position(); x < minLength; x++, i++,
j++)
         {

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/utils/FBUtilities.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=1177766&r1=1177765&r2=1177766&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/utils/FBUtilities.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/utils/FBUtilities.java
Fri Sep 30 18:20:28 2011
@@ -348,7 +348,7 @@ public class FBUtilities
         }
         if (bytes2 == null) return 1;
 
-        int minLength = Math.min(len1 - offset1, len2 - offset2);
+        int minLength = Math.min(len1, len2);
         for (int x = 0, i = offset1, j = offset2; x < minLength; x++, i++, j++)
         {
             if (bytes1[i] == bytes2[j])
@@ -356,8 +356,8 @@ public class FBUtilities
             // compare non-equal bytes as unsigned
             return (bytes1[i] & 0xFF) < (bytes2[j] & 0xFF) ? -1 : 1;
         }
-        if ((len1 - offset1) == (len2 - offset2)) return 0;
-        else return ((len1 - offset1) < (len2 - offset2)) ? -1 : 1;
+        if (len1 == len2) return 0;
+        else return (len1 < len2) ? -1 : 1;
     }
   
     /**



Mime
View raw message