You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ha...@apache.org on 2010/10/29 12:31:12 UTC
svn commit: r1028672 - in /pig/trunk: CHANGES.txt
src/org/apache/pig/data/DataByteArray.java
Author: hashutosh
Date: Fri Oct 29 10:31:12 2010
New Revision: 1028672
URL: http://svn.apache.org/viewvc?rev=1028672&view=rev
Log:
PIG-1696: Performance: Use System.arraycopy() instead of manually copying the bytes while reading the data
Modified:
pig/trunk/CHANGES.txt
pig/trunk/src/org/apache/pig/data/DataByteArray.java
Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1028672&r1=1028671&r2=1028672&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Fri Oct 29 10:31:12 2010
@@ -34,6 +34,8 @@ PIG-1608: pig should always include pig-
OPTIMIZATIONS
+PIG-1696: Performance: Use System.arraycopy() instead of manually copying the bytes while reading the data (hashutosh)
+
BUG FIXES
Release 0.8.0 - Unreleased
Modified: pig/trunk/src/org/apache/pig/data/DataByteArray.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/data/DataByteArray.java?rev=1028672&r1=1028671&r2=1028672&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/data/DataByteArray.java (original)
+++ pig/trunk/src/org/apache/pig/data/DataByteArray.java Fri Oct 29 10:31:12 2010
@@ -68,16 +68,8 @@ public class DataByteArray implements Co
if(totalSize == 0) {
return;
}
- mData = new byte[totalSize];
- int i = 0;
- for ( ;i < baLength; i++) {
- mData[i] = ba[i];
- }
-
- for (int j = 0; j < caLength; j++, i++) {
- mData[i] = ca[j];
- }
-
+ System.arraycopy(ba, 0, mData = new byte[totalSize], 0, baLength);
+ System.arraycopy(ca, 0, mData,baLength, caLength);
}
/**
@@ -88,10 +80,8 @@ public class DataByteArray implements Co
* @param end ending point to copy to, exclusive.
*/
public DataByteArray(byte[] b, int start, int end) {
- mData = new byte[end - start];
- for (int i = start; i < end; i++) {
- mData[i - start] = b[i];
- }
+
+ System.arraycopy(b, start, mData = new byte[end - start], 0, end-start);
}
/**
@@ -160,15 +150,8 @@ public class DataByteArray implements Co
return;
}
byte[] oldData = mData == null ? new byte[0] : mData.clone();
- mData = new byte[totalSize];
- int i = 0;
- for ( ;i < mDataLength; i++) {
- mData[i] = oldData[i];
- }
-
- for (int j = 0; j < baLength; j++, i++) {
- mData[i] = ba[j];
- }
+ System.arraycopy(oldData, 0, mData = new byte[totalSize], 0, mDataLength);
+ System.arraycopy(ba, 0, mData, mDataLength, baLength);
}
/**