hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r756107 - in /hadoop/core/trunk: CHANGES.txt src/core/org/apache/hadoop/io/SequenceFile.java
Date Thu, 19 Mar 2009 17:43:28 GMT
Author: mahadev
Date: Thu Mar 19 17:43:27 2009
New Revision: 756107

URL: http://svn.apache.org/viewvc?rev=756107&view=rev
Log:
HADOOP-5196. avoiding unnecessary byte[] allocation in SequenceFile.CompressedBytes and SequenceFile.UncompressedBytes.
(hong tang via mahadev)

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/core/org/apache/hadoop/io/SequenceFile.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=756107&r1=756106&r2=756107&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu Mar 19 17:43:27 2009
@@ -171,6 +171,10 @@
     HADOOP-5521. Removes dependency of TestJobInProgress on RESTART_COUNT 
     JobHistory tag. (Ravi Gummadi via ddas)
 
+    HADOOP-5196. avoiding unnecessary byte[] allocation in 
+    SequenceFile.CompressedBytes and SequenceFile.UncompressedBytes.
+    (hong tang via mahadev)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/core/trunk/src/core/org/apache/hadoop/io/SequenceFile.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/io/SequenceFile.java?rev=756107&r1=756106&r2=756107&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/io/SequenceFile.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/io/SequenceFile.java Thu Mar 19 17:43:27
2009
@@ -600,11 +600,14 @@
     }
     
     private void reset(DataInputStream in, int length) throws IOException {
-      data = new byte[length];
+      if (data == null) {
+        data = new byte[length];
+      } else if (length > data.length) {
+        data = new byte[Math.max(length, data.length * 2)];
+      }
       dataSize = -1;
-      
-      in.readFully(data);
-      dataSize = data.length;
+      in.readFully(data, 0, length);
+      dataSize = length;
     }
     
     public int getSize() {
@@ -638,11 +641,14 @@
     }
 
     private void reset(DataInputStream in, int length) throws IOException {
-      data = new byte[length];
+      if (data == null) {
+        data = new byte[length];
+      } else if (length > data.length) {
+        data = new byte[Math.max(length, data.length * 2)];
+      } 
       dataSize = -1;
-
-      in.readFully(data);
-      dataSize = data.length;
+      in.readFully(data, 0, length);
+      dataSize = length;
     }
     
     public int getSize() {



Mime
View raw message