You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ti...@apache.org on 2019/03/22 19:42:17 UTC

[drill] branch master updated: Fixed IllegalStateException while reading Parquet data

This is an automated email from the ASF dual-hosted git repository.

timothyfarkas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git


The following commit(s) were added to refs/heads/master by this push:
     new 0a54770  Fixed IllegalStateException while reading Parquet data
0a54770 is described below

commit 0a547708d6734f893ca0d6bf673f7a6ae856375e
Author: Salim Achouche <sa...@gmail.com>
AuthorDate: Fri Mar 22 08:49:08 2019 -0700

    Fixed IllegalStateException while reading Parquet data
---
 .../parquet/columnreaders/VarLenAbstractPageEntryReader.java | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/VarLenAbstractPageEntryReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/VarLenAbstractPageEntryReader.java
index a708f52..c981924 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/VarLenAbstractPageEntryReader.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/VarLenAbstractPageEntryReader.java
@@ -78,14 +78,14 @@ abstract class VarLenAbstractPageEntryReader extends VarLenAbstractEntryReader {
     int bufferCapacity = buffer.capacity() - VarLenBulkPageReader.PADDING;
     int toCopy = remaining > bufferCapacity ? bufferCapacity : remaining;
 
+    buffer.limit(toCopy); // Update the limit regardless to indicate the number of bytes available for reading
+
     if (toCopy == 0) {
       return false;
     }
 
     pageInfo.pageData.getBytes(pageInfo.pageDataOff, buffer.array(), buffer.position(), toCopy);
 
-    buffer.limit(toCopy);
-
     // At this point the buffer position is 0 and its limit set to the number of bytes copied.
 
     return true;
@@ -99,7 +99,7 @@ abstract class VarLenAbstractPageEntryReader extends VarLenAbstractEntryReader {
   }
 
   /**
-   * Fixed length readers calculate upfront the maximum number of entries to process as entry length
+   * Fixed length readers calculate up front the maximum number of entries to process as entry length
    * are known.
    * @param valuesToRead requested number of values to read
    * @param entrySz sizeof(integer) + column's precision
@@ -110,8 +110,10 @@ abstract class VarLenAbstractPageEntryReader extends VarLenAbstractEntryReader {
     // Let's start with bulk's entry and requested values-to-read constraints
     int numEntriesToRead = Math.min(entry.getMaxEntries(), valuesToRead);
 
-    // Now include the size of the fixed entry (since they are fixed)
-    numEntriesToRead = Math.min(numEntriesToRead, buffer.limit() / entrySz);
+    // The goal is to ensure that a) we're not returning more than what is requested and
+    // b) ensure that we don't overflow while accessing the buffer
+    final int bufferCapacity = buffer.capacity() - VarLenBulkPageReader.PADDING;
+    numEntriesToRead = Math.min(numEntriesToRead, bufferCapacity / entrySz);
 
     return numEntriesToRead;
   }