You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2013/04/27 20:01:33 UTC
svn commit: r1476648 -
/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/RCFile.java
Author: hashutosh
Date: Sat Apr 27 18:01:33 2013
New Revision: 1476648
URL: http://svn.apache.org/r1476648
Log:
HIVE-4423 : Improve RCFile::sync(long) 10x (Gopal V via Ashutosh Chauhan)
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/RCFile.java
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/RCFile.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/RCFile.java?rev=1476648&r1=1476647&r2=1476648&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/RCFile.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/RCFile.java Sat Apr 27 18:01:33 2013
@@ -1385,21 +1385,31 @@ public class RCFile {
try {
seek(position + 4); // skip escape
- in.readFully(syncCheck);
- int syncLen = sync.length;
- for (int i = 0; in.getPos() < end; i++) {
- int j = 0;
- for (; j < syncLen; j++) {
- if (sync[j] != syncCheck[(i + j) % syncLen]) {
- break;
+
+ int prefix = sync.length;
+ int n = conf.getInt("io.bytes.per.checksum", 512);
+ byte[] buffer = new byte[prefix+n];
+ n = (int)Math.min(n, end - in.getPos());
+ /* fill array with a pattern that will never match sync */
+ Arrays.fill(buffer, (byte)(~sync[0]));
+ while(n > 0 && (in.getPos() + n) <= end) {
+ position = in.getPos();
+ in.readFully(buffer, prefix, n);
+ /* the buffer has n+sync bytes */
+ for(int i = 0; i < n; i++) {
+ int j;
+ for(j = 0; j < sync.length && sync[j] == buffer[i+j]; j++) {
+ /* nothing */
+ }
+ if(j == sync.length) {
+ /* simplified from (position + (i - prefix) + sync.length) - SYNC_SIZE */
+ in.seek(position + i - SYNC_SIZE);
+ return;
}
}
- if (j == syncLen) {
- in.seek(in.getPos() - SYNC_SIZE); // position before
- // sync
- return;
- }
- syncCheck[i % syncLen] = in.readByte();
+ /* move the last 16 bytes to the prefix area */
+ System.arraycopy(buffer, buffer.length - prefix - 1, buffer, 0, prefix);
+ n = (int)Math.min(n, end - in.getPos());
}
} catch (ChecksumException e) { // checksum failure
handleChecksumException(e);