use of com.facebook.presto.orc.OrcTester.OrcReaderSettings in project presto by prestodb.
the class TestSelectiveOrcReader method testHiddenConstantColumns.
@Test
public void testHiddenConstantColumns() throws Exception {
Type type = BIGINT;
List<Type> types = ImmutableList.of(type);
List<List<?>> values = ImmutableList.of(ImmutableList.of(1L, 2L));
TempFile tempFile = new TempFile();
writeOrcColumnsPresto(tempFile.getFile(), DWRF, ZSTD, Optional.empty(), types, values, new OrcWriterStats());
// Hidden columns like partition columns use negative indices (-13).
int hiddenColumnIndex = -13;
Map<Integer, Type> includedColumns = ImmutableMap.of(hiddenColumnIndex, VARCHAR, 0, BIGINT);
List<Integer> outputColumns = ImmutableList.of(hiddenColumnIndex, 0);
Slice constantSlice = Slices.utf8Slice("partition_value");
Map<Integer, Object> constantValues = ImmutableMap.of(hiddenColumnIndex, constantSlice);
OrcAggregatedMemoryContext systemMemoryUsage = new TestingHiveOrcAggregatedMemoryContext();
TupleDomainFilter filter = BigintRange.of(1, 1, false);
Map<Subfield, TupleDomainFilter> subFieldFilter = toSubfieldFilter(filter);
OrcReaderSettings readerSettings = OrcTester.OrcReaderSettings.builder().setColumnFilters(ImmutableMap.of(0, subFieldFilter)).build();
try (OrcSelectiveRecordReader recordReader = createCustomOrcSelectiveRecordReader(tempFile.getFile(), DWRF.getOrcEncoding(), OrcPredicate.TRUE, types, 1, readerSettings.getColumnFilters(), readerSettings.getFilterFunctions(), readerSettings.getFilterFunctionInputMapping(), readerSettings.getRequiredSubfields(), constantValues, ImmutableMap.of(), includedColumns, outputColumns, false, systemMemoryUsage, false)) {
Page page = recordReader.getNextPage();
assertEquals(page.getPositionCount(), 1);
Block partitionValueBlock = page.getBlock(0);
int length = partitionValueBlock.getSliceLength(0);
Slice varcharSlice = partitionValueBlock.getSlice(0, 0, length);
assertEquals(varcharSlice, constantSlice);
Block bigintBlock = page.getBlock(1);
assertEquals(bigintBlock.getLong(0), 1);
assertNull(recordReader.getNextPage());
}
}
Aggregations