hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r759030 - in /hadoop/core/trunk: CHANGES.txt src/mapred/org/apache/hadoop/mapred/join/TupleWritable.java src/test/org/apache/hadoop/mapred/join/TestTupleWritable.java
Date Fri, 27 Mar 2009 06:22:20 GMT
Author: cdouglas
Date: Fri Mar 27 06:22:18 2009
New Revision: 759030

URL: http://svn.apache.org/viewvc?rev=759030&view=rev
Log:
HADOOP-5571. Remove widening primitive conversion in TupleWritable mask
manipulation. Contributed by Jingkei Ly

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/join/TupleWritable.java
    hadoop/core/trunk/src/test/org/apache/hadoop/mapred/join/TestTupleWritable.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=759030&r1=759029&r2=759030&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Fri Mar 27 06:22:18 2009
@@ -1133,6 +1133,9 @@
     HADOOP-5459. Fix undetected CRC errors where intermediate output is closed
     before it has been completely consumed. (cdouglas)
 
+    HADOOP-5571. Remove widening primitive conversion in TupleWritable mask
+    manipulation. (Jingkei Ly via cdouglas)
+
 Release 0.19.2 - Unreleased
 
   BUG FIXES

Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/join/TupleWritable.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/join/TupleWritable.java?rev=759030&r1=759029&r2=759030&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/join/TupleWritable.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/join/TupleWritable.java Fri Mar
27 06:22:18 2009
@@ -63,7 +63,7 @@
    * Return true if tuple has an element at the position provided.
    */
   public boolean has(int i) {
-    return 0 != ((1 << i) & written);
+    return 0 != ((1L << i) & written);
   }
 
   /**
@@ -205,7 +205,7 @@
    * Record that the tuple contains an element at the position provided.
    */
   void setWritten(int i) {
-    written |= 1 << i;
+    written |= 1L << i;
   }
 
   /**
@@ -213,7 +213,7 @@
    * provided.
    */
   void clearWritten(int i) {
-    written &= -1 ^ (1 << i);
+    written &= -1 ^ (1L << i);
   }
 
   /**

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/mapred/join/TestTupleWritable.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/mapred/join/TestTupleWritable.java?rev=759030&r1=759029&r2=759030&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/mapred/join/TestTupleWritable.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/mapred/join/TestTupleWritable.java Fri Mar
27 06:22:18 2009
@@ -22,6 +22,7 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 
+import java.util.Arrays;
 import java.util.Random;
 
 import junit.framework.TestCase;
@@ -31,6 +32,7 @@
 import org.apache.hadoop.io.FloatWritable;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
 
 public class TestTupleWritable extends TestCase {
@@ -130,4 +132,43 @@
     assertTrue("Failed to write/read tuple", sTuple.equals(dTuple));
   }
 
+  public void testWideTuple() throws Exception {
+    Text emptyText = new Text("Should be empty");
+    Writable[] values = new Writable[64];
+    Arrays.fill(values,emptyText);
+    values[42] = new Text("Number 42");
+                                     
+    TupleWritable tuple = new TupleWritable(values);
+    tuple.setWritten(42);
+    
+    for (int pos=0; pos<tuple.size();pos++) {
+      boolean has = tuple.has(pos);
+      if (pos == 42) {
+        assertTrue(has);
+      }
+      else {
+        assertFalse("Tuple position is incorrectly labelled as set: " + pos, has);
+      }
+    }
+  }
+  
+  public void testWideTuple2() throws Exception {
+    Text emptyText = new Text("Should be empty");
+    Writable[] values = new Writable[64];
+    Arrays.fill(values,emptyText);
+    values[9] = new Text("Number 9");
+                                     
+    TupleWritable tuple = new TupleWritable(values);
+    tuple.setWritten(9);
+    
+    for (int pos=0; pos<tuple.size();pos++) {
+      boolean has = tuple.has(pos);
+      if (pos == 9) {
+        assertTrue(has);
+      }
+      else {
+        assertFalse("Tuple position is incorrectly labelled as set: " + pos, has);
+      }
+    }
+  }
 }



Mime
View raw message