Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/611#discussion_r86587743
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/VarLenBinaryReader.java
 ---
    @@ -43,43 +51,153 @@ public VarLenBinaryReader(ParquetRecordReader 
parentReader, List<VarLengthColumn
       public long readFields(long recordsToReadInThisPass, ColumnReader<?> 
firstColumnStatus) throws IOException {
     
         long recordsReadInCurrentPass = 0;
    -    int lengthVarFieldsInCurrentRecord;
    -    long totalVariableLengthData = 0;
    -    boolean exitLengthDeterminingLoop = false;
    +
         // write the first 0 offset
         for (VarLengthColumn<?> columnReader : columns) {
           columnReader.reset();
         }
     
    +    //if(useAsyncTasks){
    +    //  recordsReadInCurrentPass = 
determineSizesParallel(recordsToReadInThisPass);
    +    //} else {
    +      recordsReadInCurrentPass = 
determineSizesSerial(recordsToReadInThisPass);
    +    //}
    +    if(useAsyncTasks){
    +      readRecordsParallel(recordsReadInCurrentPass);
    +    }else{
    +      readRecordsSerial(recordsReadInCurrentPass);
    +    }
    +    return recordsReadInCurrentPass;
    +  }
    +
    +
    +  private long determineSizesSerial(long recordsToReadInThisPass) throws 
IOException {
    +    int lengthVarFieldsInCurrentRecord = 0;
    +    boolean exitLengthDeterminingLoop = false;
    +    long totalVariableLengthData = 0;
    +    long recordsReadInCurrentPass = 0;
         do {
    -      lengthVarFieldsInCurrentRecord = 0;
           for (VarLengthColumn<?> columnReader : columns) {
    -        if ( !exitLengthDeterminingLoop ) {
    -          exitLengthDeterminingLoop = 
columnReader.determineSize(recordsReadInCurrentPass, 
lengthVarFieldsInCurrentRecord);
    +        if (!exitLengthDeterminingLoop) {
    +          exitLengthDeterminingLoop =
    +              columnReader.determineSize(recordsReadInCurrentPass, 
lengthVarFieldsInCurrentRecord);
             } else {
               break;
             }
           }
           // check that the next record will fit in the batch
    -      if (exitLengthDeterminingLoop || (recordsReadInCurrentPass + 1) * 
parentReader.getBitWidthAllFixedFields() + totalVariableLengthData
    -          + lengthVarFieldsInCurrentRecord > parentReader.getBatchSize()) {
    +      if (exitLengthDeterminingLoop ||
    +          (recordsReadInCurrentPass + 1) * 
parentReader.getBitWidthAllFixedFields()
    +              + totalVariableLengthData + lengthVarFieldsInCurrentRecord > 
parentReader.getBatchSize()) {
    +        break;
    +      }
    +      for (VarLengthColumn<?> columnReader : columns) {
    +        columnReader.updateReadyToReadPosition();
    +        columnReader.currDefLevel = -1;
    +      }
    +      recordsReadInCurrentPass++;
    +      totalVariableLengthData += lengthVarFieldsInCurrentRecord;
    +    } while (recordsReadInCurrentPass < recordsToReadInThisPass);
    +
    +    return recordsReadInCurrentPass;
    +  }
    +
    +
    +  public long determineSizesParallel(long recordsToReadInThisPass ) throws 
IOException {
    +    boolean doneReading = false;
    +    int lengthVarFieldsInCurrentRecord = 0;
    +    boolean exitLengthDeterminingLoop = false;
    +    long totalVariableLengthData = 0;
    +    long recordsReadInCurrentPass = 0;
    +
    +    do {
    +    doneReading = readPagesParallel();
    +
    +    if (!doneReading) {
    --- End diff --
    
    Can't this be made simpler?
    ```
    if ( ! readPagesParallel( ) ) { break; }
    ```
    As far as I can tell, if doneReading is false, we'll skip the body of the 
loop (via another assignment later). A bit hard to follow...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to