Skip to content

Commit d598833

Browse files
authored
Move checking parquet types above fetching the batch from native code. (#1809)
1 parent ced7392 commit d598833

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

common/src/main/java/org/apache/comet/parquet/NativeBatchReader.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,6 @@ public void init() throws Throwable {
321321
}
322322
long[] starts = new long[blocks.size()];
323323
long[] lengths = new long[blocks.size()];
324-
starts = new long[blocks.size()];
325-
lengths = new long[blocks.size()];
326324
int blockIndex = 0;
327325
for (BlockMetaData block : blocks) {
328326
long blockStart = block.getStartingPos();
@@ -613,7 +611,10 @@ public void close() throws IOException {
613611

614612
@SuppressWarnings("deprecation")
615613
private int loadNextBatch() throws Throwable {
616-
long startNs = System.nanoTime();
614+
615+
for (ParquetColumn childColumn : JavaConverters.seqAsJavaList(parquetColumn.children())) {
616+
checkParquetType(childColumn);
617+
}
617618

618619
int batchSize = Native.readNextRecordBatch(this.handle);
619620
if (batchSize == 0) {
@@ -622,10 +623,6 @@ private int loadNextBatch() throws Throwable {
622623
if (importer != null) importer.close();
623624
importer = new CometSchemaImporter(ALLOCATOR);
624625

625-
for (ParquetColumn childColumn : JavaConverters.seqAsJavaList(parquetColumn.children())) {
626-
checkParquetType(childColumn);
627-
}
628-
629626
List<Type> fields = requestedSchema.getFields();
630627
for (int i = 0; i < fields.size(); i++) {
631628
if (!missingColumns[i]) {

0 commit comments

Comments
 (0)