Skip to content

Commit

Permalink
Simplify block creation for all null values
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveen2112 authored and dain committed Mar 12, 2019
1 parent ed044b5 commit 7f2b3cd
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import io.prestosql.spi.Page;
import io.prestosql.spi.PrestoException;
import io.prestosql.spi.block.Block;
import io.prestosql.spi.block.BlockBuilder;
import io.prestosql.spi.block.LazyBlock;
import io.prestosql.spi.block.LazyBlockLoader;
import io.prestosql.spi.block.RunLengthEncodedBlock;
import io.prestosql.spi.connector.ConnectorPageSource;
import io.prestosql.spi.type.Type;
import io.prestosql.spi.type.TypeManager;
Expand Down Expand Up @@ -96,11 +96,7 @@ public OrcPageSource(
hiveColumnIndexes[columnIndex] = column.getHiveColumnIndex();

if (!recordReader.isColumnPresent(column.getHiveColumnIndex())) {
BlockBuilder blockBuilder = type.createBlockBuilder(null, MAX_BATCH_SIZE, NULL_ENTRY_SIZE);
for (int i = 0; i < MAX_BATCH_SIZE; i++) {
blockBuilder.appendNull();
}
constantBlocks[columnIndex] = blockBuilder.build();
constantBlocks[columnIndex] = RunLengthEncodedBlock.create(type, null, MAX_BATCH_SIZE);
}
}
types = typesBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public Block readBlock(Type type)

if (dataStream == null && presentStream != null) {
presentStream.skip(nextBatchSize);
Block nullValueBlock = new RunLengthEncodedBlock(
type.createBlockBuilder(null, 1).appendNull().build(),
nextBatchSize);
Block nullValueBlock = RunLengthEncodedBlock.create(type, null, nextBatchSize);
readOffset = 0;
nextBatchSize = 0;
return nullValueBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public Block readBlock(Type type)

if (dataStream == null && presentStream != null) {
presentStream.skip(nextBatchSize);
Block nullValueBlock = new RunLengthEncodedBlock(
type.createBlockBuilder(null, 1).appendNull().build(),
nextBatchSize);
Block nullValueBlock = RunLengthEncodedBlock.create(type, null, nextBatchSize);
readOffset = 0;
nextBatchSize = 0;
return nullValueBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ public Block readBlock(Type type)

if (decimalStream == null && scaleStream == null && presentStream != null) {
presentStream.skip(nextBatchSize);
Block nullValueBlock = new RunLengthEncodedBlock(
type.createBlockBuilder(null, 1).appendNull().build(),
nextBatchSize);
Block nullValueBlock = RunLengthEncodedBlock.create(type, null, nextBatchSize);
readOffset = 0;
nextBatchSize = 0;
return nullValueBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public Block readBlock(Type type)

if (dataStream == null && presentStream != null) {
presentStream.skip(nextBatchSize);
Block nullValueBlock = new RunLengthEncodedBlock(
type.createBlockBuilder(null, 1).appendNull().build(),
nextBatchSize);
Block nullValueBlock = RunLengthEncodedBlock.create(type, null, nextBatchSize);
readOffset = 0;
nextBatchSize = 0;
return nullValueBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ public Block readBlock(Type type)

if (dataStream == null && presentStream != null) {
presentStream.skip(nextBatchSize);
Block nullValueBlock = new RunLengthEncodedBlock(
type.createBlockBuilder(null, 1).appendNull().build(),
nextBatchSize);
Block nullValueBlock = RunLengthEncodedBlock.create(type, null, nextBatchSize);
readOffset = 0;
nextBatchSize = 0;
return nullValueBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public Block readBlock(Type type)

if (dataStream == null && presentStream != null) {
presentStream.skip(nextBatchSize);
Block nullValueBlock = new RunLengthEncodedBlock(
type.createBlockBuilder(null, 1).appendNull().build(),
nextBatchSize);
Block nullValueBlock = RunLengthEncodedBlock.create(type, null, nextBatchSize);
readOffset = 0;
nextBatchSize = 0;
return nullValueBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ public Block readBlock(Type type)

if (secondsStream == null && nanosStream == null && presentStream != null) {
presentStream.skip(nextBatchSize);
Block nullValueBlock = new RunLengthEncodedBlock(
type.createBlockBuilder(null, 1).appendNull().build(),
nextBatchSize);
Block nullValueBlock = RunLengthEncodedBlock.create(type, null, nextBatchSize);
readOffset = 0;
nextBatchSize = 0;
return nullValueBlock;
Expand Down

0 comments on commit 7f2b3cd

Please sign in to comment.