Author: goffinet
Date: Sat Dec  5 01:44:41 2009
New Revision: 887481

URL: http://svn.apache.org/viewvc?rev=887481&view=rev
Log:
Change convertFromDiskFormat to use substring splitting vs using split 
operation (slow). patch by goffinet; reviewed by stuhood for CASSANDRA-581

Modified:
    
incubator/cassandra/trunk/src/java/org/apache/cassandra/dht/RandomPartitioner.java

Modified: 
incubator/cassandra/trunk/src/java/org/apache/cassandra/dht/RandomPartitioner.java
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/dht/RandomPartitioner.java?rev=887481&r1=887480&r2=887481&view=diff
==============================================================================
--- 
incubator/cassandra/trunk/src/java/org/apache/cassandra/dht/RandomPartitioner.java
 (original)
+++ 
incubator/cassandra/trunk/src/java/org/apache/cassandra/dht/RandomPartitioner.java
 Sat Dec  5 01:44:41 2009
@@ -39,9 +39,6 @@
 
     private static final String DELIMITER = ":";
     
-    //to avoid having to create the pattern on every String.split
-    private Pattern diskDelimiter = Pattern.compile(DELIMITER);
-
     private static final Comparator<DecoratedKey<BigIntegerToken>> comparator =
         new Comparator<DecoratedKey<BigIntegerToken>>() {
         public int compare(DecoratedKey<BigIntegerToken> o1, 
DecoratedKey<BigIntegerToken> o2)
@@ -64,9 +61,11 @@
     
     public DecoratedKey<BigIntegerToken> convertFromDiskFormat(String key)
     {
-        String[] parts = diskDelimiter.split(key, 2);
-        assert parts.length == 2;
-        return new DecoratedKey<BigIntegerToken>(new 
BigIntegerToken(parts[0]), parts[1]);
+        int splitPoint = key.indexOf(DELIMITER);
+        String first = key.substring(0, splitPoint);
+        String second = key.substring(splitPoint+1);
+
+        return new DecoratedKey<BigIntegerToken>(new BigIntegerToken(first), 
second);
     }
 
     public String convertToDiskFormat(DecoratedKey<BigIntegerToken> key)


Reply via email to