private static SegmentVersion getSegmentVersionToLoad( IndexLoadingConfigMetadata indexLoadingConfigMetadata) { if (indexLoadingConfigMetadata == null) { return SegmentVersion.fromStringOrDefault( CommonConstants.Server.DEFAULT_SEGMENT_FORMAT_VERSION); } String versionName = indexLoadingConfigMetadata.segmentVersionToLoad(); return SegmentVersion.fromStringOrDefault(versionName); }
public static com.linkedin.pinot.core.indexsegment.IndexSegment load( File indexDir, ReadMode readMode, IndexLoadingConfigMetadata indexLoadingConfigMetadata) throws Exception { SegmentMetadataImpl metadata = new SegmentMetadataImpl(indexDir); if (!metadata .getVersion() .equalsIgnoreCase(IndexSegmentImpl.EXPECTED_SEGMENT_VERSION.toString())) { SegmentVersion from = SegmentVersion.valueOf(metadata.getVersion()); SegmentVersion to = SegmentVersion.valueOf(IndexSegmentImpl.EXPECTED_SEGMENT_VERSION.toString()); LOGGER.info( "segment:{} needs to be converted from :{} to {} version.", indexDir.getName(), from, to); SegmentFormatConverter converter = SegmentFormatConverterFactory.getConverter(from, to); LOGGER.info("Using converter:{} to up-convert the format", converter.getClass().getName()); converter.convert(indexDir); LOGGER.info( "Successfully up-converted segment:{} from :{} to {} version.", indexDir.getName(), from, to); } Map<String, ColumnIndexContainer> indexContainerMap = new HashMap<String, ColumnIndexContainer>(); for (String column : metadata.getColumnMetadataMap().keySet()) { indexContainerMap.put( column, ColumnIndexContainer.init( column, indexDir, metadata.getColumnMetadataFor(column), indexLoadingConfigMetadata, readMode)); } // The star tree index (if available) StarTreeIndexNode starTreeRoot = null; if (metadata.hasStarTree()) { File starTreeFile = new File(indexDir, V1Constants.STARTREE_FILE); LOGGER.debug("Loading star tree index file {}", starTreeFile); starTreeRoot = StarTreeIndexNode.fromBytes(new FileInputStream(starTreeFile)); } return new IndexSegmentImpl(indexDir, metadata, indexContainerMap, starTreeRoot); }