Skip to content

Commit

Permalink
Remove Unnecessary Block Creation in ParquetPageSource
Browse files Browse the repository at this point in the history
Optional.orElse takes a strictly evaluated argument which
is unnecessary when the Field is present.
  • Loading branch information
pettyjamesm authored and kokosing committed Dec 11, 2019
1 parent 5a7033d commit cc987b9
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -91,10 +91,13 @@ public Page getNextPage()

Block[] blocks = new Block[fields.size()];
for (int fieldId = 0; fieldId < blocks.length; fieldId++) {
Type type = types.get(fieldId);
blocks[fieldId] = fields.get(fieldId)
.map(field -> (Block) new LazyBlock(batchSize, new ParquetBlockLoader(field)))
.orElse(RunLengthEncodedBlock.create(type, null, batchSize));
Optional<Field> field = fields.get(fieldId);
if (field.isPresent()) {
blocks[fieldId] = new LazyBlock(batchSize, new ParquetBlockLoader(field.get()));
}
else {
blocks[fieldId] = RunLengthEncodedBlock.create(types.get(fieldId), null, batchSize);
}
}
return new Page(batchSize, blocks);
}
Expand Down

0 comments on commit cc987b9

Please sign in to comment.