Source:
public List<File> convertSegment() throws Exception { List<File> resultFiles = new ArrayList<>(); for (int currentPartition = 0; currentPartition < _totalNumPartition; currentPartition++) { Preconditions.checkNotNull(_recordTransformer); String mapperOutputPath = _workingDir.getPath() + File.separator + MAPPER_PREFIX + currentPartition; String outputSegmentName = (_totalNumPartition <= 1) ? _segmentName : _segmentName + "_" + currentPartition; try (MapperRecordReader mapperRecordReader = new MapperRecordReader(_inputIndexDirs, _recordTransformer, _recordPartitioner, _totalNumPartition, currentPartition)) { buildSegment(mapperOutputPath, outputSegmentName, mapperRecordReader, mapperRecordReader.getSchema(), _tableConfig); } File outputSegment = new File(mapperOutputPath + File.separator + outputSegmentName); if (_recordAggregator != null && _groupByColumns != null && _groupByColumns.size() > 0) { String reducerOutputPath = _workingDir.getPath() + File.separator + REDUCER_PREFIX + currentPartition; try (ReducerRecordReader reducerRecordReader = new ReducerRecordReader(outputSegment, _recordAggregator, _groupByColumns)) { buildSegment(reducerOutputPath, outputSegmentName, reducerRecordReader, reducerRecordReader.getSchema(), _tableConfig); } outputSegment = new File(reducerOutputPath + File.separator + outputSegmentName); } if (_tableConfig != null) { IndexingConfig indexingConfig = _tableConfig.getIndexingConfig(); List<String> sortedColumn = indexingConfig.getSortedColumn(); List<String> invertedIndexColumns = indexingConfig.getInvertedIndexColumns(); if (CollectionUtils.isNotEmpty(sortedColumn) || CollectionUtils.isNotEmpty(invertedIndexColumns)) { String indexGenerationOutputPath = _workingDir.getPath() + File.separator + INDEX_PREFIX + currentPartition; try (PinotSegmentRecordReader pinotSegmentRecordReader = new PinotSegmentRecordReader(outputSegment, null, sortedColumn)) { buildSegment(indexGenerationOutputPath, outputSegmentName, pinotSegmentRecordReader, pinotSegmentRecordReader.getSchema(), _tableConfig); } outputSegment = new File(indexGenerationOutputPath + File.separator + outputSegmentName); } } resultFiles.add(outputSegment); } return resultFiles; }

Target:
public List<File> convertSegment() throws Exception { List<File> resultFiles = new ArrayList<>(); for (int currentPartition = 0; currentPartition < _totalNumPartition; currentPartition++) { Preconditions.checkNotNull(_recordTransformer); String mapperOutputPath = _workingDir.getPath() + File.separator + MAPPER_PREFIX + currentPartition; String outputSegmentName = (_totalNumPartition <= 1) ? _segmentName : _segmentName + "_" + currentPartition; try (MapperRecordReader mapperRecordReader = new MapperRecordReader(_inputIndexDirs, _recordTransformer, _recordPartitioner, _totalNumPartition, currentPartition)) { buildSegment(mapperOutputPath, outputSegmentName, mapperRecordReader, mapperRecordReader.getSchema(), _tableConfig); } File outputSegment = new File(mapperOutputPath + File.separator + outputSegmentName); if (_recordAggregator != null && _groupByColumns != null && _groupByColumns.size() > 0) { String reducerOutputPath = _workingDir.getPath() + File.separator + REDUCER_PREFIX + currentPartition; try (ReducerRecordReader reducerRecordReader = new ReducerRecordReader(outputSegment, _recordAggregator, _groupByColumns)) { buildSegment(reducerOutputPath, outputSegmentName, reducerRecordReader, reducerRecordReader.getSchema(), _tableConfig); } outputSegment = new File(reducerOutputPath + File.separator + outputSegmentName); } IndexingConfig indexingConfig = _tableConfig.getIndexingConfig(); List<String> sortedColumn = indexingConfig.getSortedColumn(); List<String> invertedIndexColumns = indexingConfig.getInvertedIndexColumns(); if (CollectionUtils.isNotEmpty(sortedColumn) || CollectionUtils.isNotEmpty(invertedIndexColumns)) { String indexGenerationOutputPath = _workingDir.getPath() + File.separator + INDEX_PREFIX + currentPartition; try (PinotSegmentRecordReader pinotSegmentRecordReader = new PinotSegmentRecordReader(outputSegment, null, sortedColumn)) { buildSegment(indexGenerationOutputPath, outputSegmentName, pinotSegmentRecordReader, pinotSegmentRecordReader.getSchema(), _tableConfig); } outputSegment = new File(indexGenerationOutputPath + File.separator + outputSegmentName); } resultFiles.add(outputSegment); } return resultFiles; }