Source:
public void testMaxReadBytes(int rowCount) throws Exception { int maxReadBytes = 1_000; HiveClientConfig config = new HiveClientConfig(); config.setOrcMaxReadBlockSize(new DataSize(maxReadBytes, BYTE)); ConnectorSession session = new TestingConnectorSession(new HiveSessionProperties(config).getSessionProperties()); FileFormatDataSourceStats stats = new FileFormatDataSourceStats(); int numColumns = 5; int step = 250; ImmutableList.Builder<TestColumn> columnBuilder = ImmutableList.<TestColumn>builder() .add(new TestColumn("p_empty_string", javaStringObjectInspector, () -> "", true)); AccumulativeTestColumn[] dataColumns = new AccumulativeTestColumn[numColumns]; for (int i = 0; i < numColumns; i++) { dataColumns[i] = new AccumulativeTestColumn("p_string", javaStringObjectInspector, () -> Long.toHexString(random.nextLong()), false, step * (i + 1)); columnBuilder.add(dataColumns[i]); } List<TestColumn> testColumns = columnBuilder.build(); File tempFile = File.createTempFile("presto_test_orc_page_source_max_read_bytes", "orc"); tempFile.delete(); TestPreparer testPreparer = new TestPreparer(tempFile.getAbsolutePath(), testColumns, rowCount, rowCount); ConnectorPageSource pageSource = testPreparer.newPageSource(stats, session); try { int positionCount = 0; while (true) { Page page = pageSource.getNextPage(); if (pageSource.isFinished()) { break; } assertNotNull(page); page.assureLoaded(); positionCount += page.getPositionCount(); if (positionCount > MAX_BATCH_SIZE) { assertTrue(page.getSizeInBytes() < maxReadBytes * (MAX_BATCH_SIZE / step) || 1 == page.getPositionCount()); } } Distribution distribution = stats.getMaxCombinedBytesPerRow().getAllTime(); assertEquals((int) distribution.getCount(), 1); assertEquals((int) distribution.getMax(), Arrays.stream(dataColumns).mapToInt(AccumulativeTestColumn::getMaxSize).sum()); pageSource.close(); } finally { tempFile.delete(); } }

Target:
public void testMaxReadBytes(int rowCount) throws Exception { int maxReadBytes = 1_000; HiveClientConfig config = new HiveClientConfig(); config.setOrcMaxReadBlockSize(new DataSize(maxReadBytes, BYTE)); ConnectorSession session = new TestingConnectorSession(new HiveSessionProperties(config).getSessionProperties()); FileFormatDataSourceStats stats = new FileFormatDataSourceStats(); int numColumns = 5; int step = 250; ImmutableList.Builder<TestColumn> columnBuilder = ImmutableList.<TestColumn>builder() .add(new TestColumn("p_empty_string", javaStringObjectInspector, () -> "", true)); GrowingTestColumn[] dataColumns = new GrowingTestColumn[numColumns]; for (int i = 0; i < numColumns; i++) { dataColumns[i] = new GrowingTestColumn("p_string", javaStringObjectInspector, () -> Long.toHexString(random.nextLong()), false, step * (i + 1)); columnBuilder.add(dataColumns[i]); } List<TestColumn> testColumns = columnBuilder.build(); File tempFile = File.createTempFile("presto_test_orc_page_source_max_read_bytes", "orc"); tempFile.delete(); TestPreparer testPreparer = new TestPreparer(tempFile.getAbsolutePath(), testColumns, rowCount, rowCount); ConnectorPageSource pageSource = testPreparer.newPageSource(stats, session); try { int positionCount = 0; while (true) { Page page = pageSource.getNextPage(); if (pageSource.isFinished()) { break; } assertNotNull(page); page.assureLoaded(); positionCount += page.getPositionCount(); if (positionCount > MAX_BATCH_SIZE) { assertTrue(page.getSizeInBytes() < maxReadBytes * (MAX_BATCH_SIZE / step) || 1 == page.getPositionCount()); } } Distribution distribution = stats.getMaxCombinedBytesPerRow().getAllTime(); assertEquals((int) distribution.getCount(), 1); assertEquals((int) distribution.getMax(), Arrays.stream(dataColumns).mapToInt(GrowingTestColumn::getMaxSize).sum()); pageSource.close(); } finally { tempFile.delete(); } }