hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r662667 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/io/Text.java src/test/org/apache/hadoop/io/TestText.java
Date Tue, 03 Jun 2008 07:04:07 GMT
Author: cdouglas
Date: Tue Jun  3 00:04:07 2008
New Revision: 662667

URL: http://svn.apache.org/viewvc?rev=662667&view=rev
Log:
HADOOP-3454. Fix Text::find to search only valid byte ranges. Contributed by Chad Whipkey.


Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/io/Text.java
    hadoop/core/trunk/src/test/org/apache/hadoop/io/TestText.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=662667&r1=662666&r2=662667&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Tue Jun  3 00:04:07 2008
@@ -394,6 +394,9 @@
     HADOOP-3443. Avoid copying map output across partitions when renaming a
     single spill. (omalley via cdouglas)
 
+    HADOOP-3454. Fix Text::find to search only valid byte ranges. (Chad Whipkey
+    via cdouglas)
+
 Release 0.17.0 - 2008-05-18
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/io/Text.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/io/Text.java?rev=662667&r1=662666&r2=662667&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/io/Text.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/io/Text.java Tue Jun  3 00:04:07 2008
@@ -126,7 +126,7 @@
    */
   public int find(String what, int start) {
     try {
-      ByteBuffer src = ByteBuffer.wrap(this.bytes);
+      ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);
       ByteBuffer tgt = encode(what);
       byte b = tgt.get();
       src.position(start);

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/io/TestText.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/io/TestText.java?rev=662667&r1=662666&r2=662667&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/io/TestText.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/io/TestText.java Tue Jun  3 00:04:07 2008
@@ -192,6 +192,14 @@
     assertTrue(text.find("\u20ac", 5)==11);
   }
 
+  public void testFindAfterUpdatingContents() throws Exception {
+    Text text = new Text("abcd");
+    text.set("a".getBytes());
+    assertEquals(text.getLength(),1);
+    assertEquals(text.find("a"), 0);
+    assertEquals(text.find("b"), -1);
+  }
+
   public void testValidate() throws Exception {
     Text text = new Text("abcd\u20acbdcd\u20ac");
     byte [] utf8 = text.getBytes();



Mime
View raw message