Skip to content

Commit

Permalink
revert on optimization, all naive for now
Browse files Browse the repository at this point in the history
  • Loading branch information
jortiz16 committed Jul 25, 2016
1 parent b2f1104 commit cc80dda
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ record = iterator.next();
* If the previous character is not a new line, we discard the line.
*/
if (lineNumber - 1 == 0 && partitionStartByteRange != 0) {
char currentChar = (char) partitionInputStream.read();
char currentChar =
(char)
source.getInputStream(adjustedStartByteRange - 1, adjustedStartByteRange).read();
if (currentChar != '\n' && currentChar != '\r') {
discardedRecord = true;
/*
Expand All @@ -221,7 +223,11 @@ record = iterator.next();
/*
* This handles the case in which the splitting occurs in the middle of \r\n.
*/
currentChar = (char) partitionInputStream.read();
currentChar =
(char)
source
.getInputStream(adjustedStartByteRange, adjustedStartByteRange + 1)
.read();
if (currentChar == '\n') {
discardedRecord = true;
}
Expand Down Expand Up @@ -360,11 +366,7 @@ protected Schema generateSchema() {
protected void init(final ImmutableMap<String, Object> execEnvVars) throws DbException {
buffer = new TupleBatchBuffer(getSchema());
try {
/* Optimization : if not the first worker, read the previous byte */
adjustedStartByteRange = partitionStartByteRange;
if (partitionStartByteRange != 0) {
adjustedStartByteRange -= 1;
}
adjustedEndByteRange = partitionEndByteRange;
partitionInputStream = source.getInputStream(adjustedStartByteRange, adjustedEndByteRange);
parser =
Expand Down

0 comments on commit cc80dda

Please sign in to comment.