ソースを参照

HADOOP-3550. Fix the serialization data structures in MapTask where the value
lengths are incorrectly calculated.



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.18@669323 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas 17 年 前
コミット
d080cd85ba
2 ファイル変更7 行追加3 行削除
  1. 3 0
      CHANGES.txt
  2. 4 3
      src/mapred/org/apache/hadoop/mapred/MapTask.java

+ 3 - 0
CHANGES.txt

@@ -614,6 +614,9 @@ Release 0.18.0 - Unreleased
     HADOOP-3520.  TestDFSUpgradeFromImage triggers a race condition in the
     Upgrade Manager. Fixed. (dhruba)
 
+    HADOOP-3550. Fix the serialization data structures in MapTask where the
+    value lengths are incorrectly calculated. (cdouglas)
+
 Release 0.17.1 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 4 - 3
src/mapred/org/apache/hadoop/mapred/MapTask.java

@@ -426,7 +426,7 @@ class MapTask extends Task {
           // serialize key bytes into buffer
         int keystart = bufindex;
         keySerializer.serialize(key);
-        if (bufindex < keystart) {
+        if (bufindex < keystart || bufindex == bufvoid) {
           // wrapped the key; reset required
           bb.reset();
           keystart = 0;
@@ -853,10 +853,11 @@ class MapTask extends Task {
      * deserialized value bytes. Should only be called during a spill.
      */
     private void getVBytesForOffset(int kvoff, InMemValBytes vbytes) {
-      final int nextindex = kvoff / ACCTSIZE == kvend - 1
+      final int nextindex = ((kvoff/ACCTSIZE) == 
+                             ((kvend - 1 + kvoffsets.length) % kvoffsets.length))
         ? bufend
         : kvindices[(kvoff + ACCTSIZE + KEYSTART) % kvindices.length];
-      int vallen = (nextindex > kvindices[kvoff + VALSTART])
+      int vallen = (nextindex >= kvindices[kvoff + VALSTART])
         ? nextindex - kvindices[kvoff + VALSTART]
         : (bufvoid - kvindices[kvoff + VALSTART]) + nextindex;
       vbytes.reset(kvbuffer, kvindices[kvoff + VALSTART], vallen);