private void initStarTreeIndex(JobContext context) throws IOException { String _starTreeIndexSpecFile = PinotOutputFormat.getStarTreeIndexSpec(context); if (_starTreeIndexSpecFile != null) { StarTreeIndexSpec starTreeIndexSpec = StarTreeIndexSpec.fromFile(new File(_starTreeIndexSpecFile)); // Specifying star-tree index file enables star tree generation, even if _enableStarTreeIndex is not specified. _segmentConfig.enableStarTreeIndex(starTreeIndexSpec); } else if (PinotOutputFormat.getEnableStarTreeIndex(context)) { _segmentConfig.enableStarTreeIndex(null); } } }
StarTreeIndexSpec starTreeIndexSpec = StarTreeIndexSpec.fromFile(new File(_starTreeIndexSpecFile));
/** * Helper method to perform the conversion. * @param columnarSegment Columnar segment directory to convert * @throws Exception */ private void convertSegment(File columnarSegment) throws Exception { PinotSegmentRecordReader pinotSegmentRecordReader = new PinotSegmentRecordReader(columnarSegment); SegmentGeneratorConfig config = new SegmentGeneratorConfig(pinotSegmentRecordReader.getSchema()); config.setDataDir(_inputDirName); config.setInputFilePath(columnarSegment.getAbsolutePath()); config.setFormat(FileFormat.PINOT); config.setOutDir(_outputDirName); config.setOverwrite(_overwrite); StarTreeIndexSpec starTreeIndexSpec = null; if (_starTreeConfigFileName != null) { starTreeIndexSpec = StarTreeIndexSpec.fromFile(new File(_starTreeConfigFileName)); } config.enableStarTreeIndex(starTreeIndexSpec); // Read the segment and table name from the segment's metadata. SegmentMetadata metadata = new SegmentMetadataImpl(columnarSegment); SegmentNameGenerator nameGenerator = new DefaultSegmentNameGenerator(metadata.getName()); config.setSegmentNameGenerator(nameGenerator); config.setTableName(metadata.getTableName()); SegmentIndexCreationDriver indexCreator = new SegmentIndexCreationDriverImpl(); indexCreator.init(config); indexCreator.build(); }