Github user sureshsubbiah commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1674#discussion_r207440918
--- Diff: core/sql/src/main/java/org/trafodion/sql/HDFSClient.java ---
@@ -240,7 +256,48 @@ int compressedFileRead(int readLenRemain) throws
IOException
return totalReadLen;
}
- native int copyToByteBuffer(ByteBuffer buf, int bufOffset, byte[]
bufArray, int copyLen);
+ /* Trafodion adds record delimiter '\n' while copying it
+ to buffer backing up the ByteBuffer */
+
+ int sequenceFileRead(int readLenRemain) throws IOException
+ {
+ boolean eof = false;
+ byte[] byteArray;
+ int readLen;
+ int totalReadLen = 0;
+ long tempPos;
+ int lenRemain = readLenRemain;
+
+ while (!eof && lenRemain > 0) {
+ tempPos = reader_.getPosition();
+ try {
+ eof = reader_.next(key_, value_);
+ }
+ catch (java.io.EOFException e)
+ {
+ eof = true;
+ break;
+ }
+ byteArray = ((Text)value_).getBytes();
+ readLen = ((Text)value_).getLength();
+ if (readLen <= lenRemain) {
+
+ buf_.put(byteArray, 0, readLen);
+ buf_.put(recDelimiter_);
--- End diff --
Should we be worried that the 1 byte delimiter will put us past us past end
of buffer as suggest in the comment in line 290? (when readLen == lenRemain)
---