diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/orc/OrcBatchPageSource.java b/presto-hive/src/main/java/com/facebook/presto/hive/orc/OrcBatchPageSource.java index 29f588f71179..e4623c9709cb 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/orc/OrcBatchPageSource.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/orc/OrcBatchPageSource.java @@ -23,9 +23,9 @@ import com.facebook.presto.spi.Page; import com.facebook.presto.spi.PrestoException; import com.facebook.presto.spi.block.Block; -import com.facebook.presto.spi.block.BlockBuilder; import com.facebook.presto.spi.block.LazyBlock; import com.facebook.presto.spi.block.LazyBlockLoader; +import com.facebook.presto.spi.block.RunLengthEncodedBlock; import com.facebook.presto.spi.type.Type; import com.facebook.presto.spi.type.TypeManager; import com.google.common.collect.ImmutableList; @@ -96,11 +96,7 @@ public OrcBatchPageSource( 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(); diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/BooleanBatchStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/BooleanBatchStreamReader.java index 2578c4f81c1a..e5f9ca0ff1b3 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/BooleanBatchStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/BooleanBatchStreamReader.java @@ -92,9 +92,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; diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/ByteBatchStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/ByteBatchStreamReader.java index f5ba1094156c..e492efc06336 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/ByteBatchStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/ByteBatchStreamReader.java @@ -93,9 +93,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; diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/DecimalBatchStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/DecimalBatchStreamReader.java index bd92f68be224..dd3c47952d95 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/DecimalBatchStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/DecimalBatchStreamReader.java @@ -96,9 +96,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; diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/DoubleBatchStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/DoubleBatchStreamReader.java index 87b4c76ea13f..acae839a869e 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/DoubleBatchStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/DoubleBatchStreamReader.java @@ -93,9 +93,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; diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/FloatBatchStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/FloatBatchStreamReader.java index 5e16ca3499f2..ef860f9be6fa 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/FloatBatchStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/FloatBatchStreamReader.java @@ -94,9 +94,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; diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectBatchStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectBatchStreamReader.java index 197db41d1ddd..0fea8ac1366a 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectBatchStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectBatchStreamReader.java @@ -93,9 +93,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; diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/TimestampBatchStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/TimestampBatchStreamReader.java index 0effdc179241..65707bde76c2 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/TimestampBatchStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/TimestampBatchStreamReader.java @@ -111,9 +111,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;