hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1530060 - /hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RegexStringComparator.java
Date Mon, 07 Oct 2013 20:57:29 GMT
Author: larsh
Date: Mon Oct  7 20:57:28 2013
New Revision: 1530060

URL: http://svn.apache.org/r1530060
Log:
HBASE-9711 Improve HBASE-9428 - avoid copying bytes for RegexFilter unless necessary

Modified:
    hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RegexStringComparator.java

Modified: hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RegexStringComparator.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RegexStringComparator.java?rev=1530060&r1=1530059&r2=1530060&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RegexStringComparator.java
(original)
+++ hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RegexStringComparator.java
Mon Oct  7 20:57:28 2013
@@ -109,12 +109,17 @@ public class RegexStringComparator exten
 
   @Override
   public int compareTo(byte[] value, int offset, int length) {
-    // See HBASE-9428. Make a copy of the relevant part of the byte[],
-    // or the JDK will copy the entire byte[] during String decode
-    byte[] tmp = Arrays.copyOfRange(value, offset, offset+length);
     // Use find() for subsequence match instead of matches() (full sequence
     // match) to adhere to the principle of least surprise.
-    return pattern.matcher(new String(tmp, charset)).find() ? 0 : 1;
+    String tmp;
+    if (length < value.length / 2) {
+      // See HBASE-9428. Make a copy of the relevant part of the byte[],
+      // or the JDK will copy the entire byte[] during String decode
+      tmp = new String(Arrays.copyOfRange(value, offset, offset + length), charset);
+    } else {
+      tmp = new String(value, offset, length, charset);
+    }
+    return pattern.matcher(tmp).find() ? 0 : 1;
   }
 
   /**



Mime
View raw message