Skip to content
Permalink
Browse files
DRILL-6570: Fixed IndexOutofBoundException in Parquet Reader
  • Loading branch information
sachouche authored and Ben-Zvi committed Jul 6, 2018
1 parent 287adec commit aee899c1b26ebb9a5781d280d5a73b42c273d4d5
Showing 1 changed file with 12 additions and 20 deletions.
@@ -18,7 +18,7 @@
package org.apache.drill.exec.store.parquet.columnreaders;

import org.apache.drill.exec.store.parquet.columnreaders.VarLenColumnBulkInput.ColumnPrecisionInfo;
import org.apache.drill.exec.store.parquet.columnreaders.VarLenColumnBulkInput.ColumnPrecisionType;
import org.apache.drill.exec.vector.UInt4Vector;
import org.apache.drill.exec.vector.VarLenBulkEntry;

import io.netty.buffer.DrillBuf;
@@ -55,25 +55,17 @@ final class VarLenColumnBulkEntry implements VarLenBulkEntry {
}

VarLenColumnBulkEntry(ColumnPrecisionInfo columnPrecInfo, int buffSz) {
int lengthSz = -1;
int dataSz = -1;

if (ColumnPrecisionType.isPrecTypeFixed(columnPrecInfo.columnPrecisionType)) {
final int expectedDataLen = columnPrecInfo.precision;
final int maxNumValues = buffSz / (4 + expectedDataLen);
lengthSz = maxNumValues;
dataSz = maxNumValues * expectedDataLen + PADDING;

} else {
// For variable length data, we need to handle a) maximum number of entries and b) max entry length
final int smallestDataLen = 1;
final int largestDataLen = buffSz - 4;
final int maxNumValues = buffSz / (4 + smallestDataLen);
lengthSz = maxNumValues;
dataSz = largestDataLen + PADDING;
}

this.lengths = new int[lengthSz];

// For variable length data, we need to handle a) maximum number of entries
// and b) max entry length. Note that we don't optimize for fixed length
// columns as the reader can notice a false-positive (that is, the first
// values were fixed but not the rest).
final int largestDataLen = buffSz - UInt4Vector.VALUE_WIDTH;
final int maxNumValues = buffSz / UInt4Vector.VALUE_WIDTH;
final int lengthSz = maxNumValues;
final int dataSz = largestDataLen + PADDING;

this.lengths = new int[lengthSz];
this.internalArray = new byte[dataSz];
}

0 comments on commit aee899c

Please sign in to comment.