Skip to content

Commit 22337f3

Browse files
author
Jim Carroll
committed
PARQUET-157: Fix a divide by zero error when Parquet runs quickly. Also avoid compiling log statements in some cases where it's unnecessary.
1 parent 23db4eb commit 22337f3

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

parquet-hadoop/src/main/java/parquet/hadoop/InternalParquetRecordReader.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,16 @@ public InternalParquetRecordReader(ReadSupport<T> readSupport, UnboundRecordFilt
102102
private void checkRead() throws IOException {
103103
if (current == totalCountLoadedSoFar) {
104104
if (current != 0) {
105-
long timeAssembling = System.currentTimeMillis() - startedAssemblingCurrentBlockAt;
106-
totalTimeSpentProcessingRecords += timeAssembling;
107-
LOG.info("Assembled and processed " + totalCountLoadedSoFar + " records from " + columnCount + " columns in " + totalTimeSpentProcessingRecords + " ms: "+((float)totalCountLoadedSoFar / totalTimeSpentProcessingRecords) + " rec/ms, " + ((float)totalCountLoadedSoFar * columnCount / totalTimeSpentProcessingRecords) + " cell/ms");
108-
long totalTime = totalTimeSpentProcessingRecords + totalTimeSpentReadingBytes;
109-
long percentReading = 100 * totalTimeSpentReadingBytes / totalTime;
110-
long percentProcessing = 100 * totalTimeSpentProcessingRecords / totalTime;
111-
LOG.info("time spent so far " + percentReading + "% reading ("+totalTimeSpentReadingBytes+" ms) and " + percentProcessing + "% processing ("+totalTimeSpentProcessingRecords+" ms)");
105+
totalTimeSpentProcessingRecords += (System.currentTimeMillis() - startedAssemblingCurrentBlockAt);
106+
if (Log.INFO) {
107+
LOG.info("Assembled and processed " + totalCountLoadedSoFar + " records from " + columnCount + " columns in " + totalTimeSpentProcessingRecords + " ms: "+((float)totalCountLoadedSoFar / totalTimeSpentProcessingRecords) + " rec/ms, " + ((float)totalCountLoadedSoFar * columnCount / totalTimeSpentProcessingRecords) + " cell/ms");
108+
final long totalTime = totalTimeSpentProcessingRecords + totalTimeSpentReadingBytes;
109+
if (totalTime != 0) {
110+
final long percentReading = 100 * totalTimeSpentReadingBytes / totalTime;
111+
final long percentProcessing = 100 * totalTimeSpentProcessingRecords / totalTime;
112+
LOG.info("time spent so far " + percentReading + "% reading ("+totalTimeSpentReadingBytes+" ms) and " + percentProcessing + "% processing ("+totalTimeSpentProcessingRecords+" ms)");
113+
}
114+
}
112115
}
113116

114117
LOG.info("at row " + current + ". reading next block");
@@ -120,7 +123,7 @@ private void checkRead() throws IOException {
120123
long timeSpentReading = System.currentTimeMillis() - t0;
121124
totalTimeSpentReadingBytes += timeSpentReading;
122125
BenchmarkCounter.incrementTime(timeSpentReading);
123-
LOG.info("block read in memory in " + timeSpentReading + " ms. row count = " + pages.getRowCount());
126+
if (Log.INFO) LOG.info("block read in memory in " + timeSpentReading + " ms. row count = " + pages.getRowCount());
124127
if (Log.DEBUG) LOG.debug("initializing Record assembly with requested schema " + requestedSchema);
125128
MessageColumnIO columnIO = columnIOFactory.getColumnIO(requestedSchema, fileSchema, strictTypeChecking);
126129
recordReader = columnIO.getRecordReader(pages, recordConverter, filter);
@@ -217,4 +220,4 @@ public boolean nextKeyValue() throws IOException, InterruptedException {
217220
}
218221
return true;
219222
}
220-
}
223+
}

0 commit comments

Comments
 (0)