/** * a new constructor with carbon index files * * @param indexFiles carbon index files */ public LatestFilesReadCommittedScope(CarbonFile[] indexFiles, Configuration configuration) { this.configuration = configuration; takeCarbonIndexFileSnapShot(indexFiles); }
@Override public LoadMetadataDetails[] getSegmentList() throws IOException { try { if (loadMetadataDetails == null) { takeCarbonIndexFileSnapShot(); } return loadMetadataDetails; } catch (IOException ex) { throw new IOException("Problem encountered while reading the Table Status file.", ex); } }
/** * a new constructor of this class * * @param path carbon file path * @param segmentId segment id */ public LatestFilesReadCommittedScope(String path, String segmentId, Configuration configuration) throws IOException { this.configuration = configuration; Objects.requireNonNull(path); this.carbonFilePath = path; this.segmentId = segmentId; takeCarbonIndexFileSnapShot(); }
@Override public void takeCarbonIndexFileSnapShot() throws IOException { // Read the current file Path get the list of indexes from the path. CarbonFile file = FileFactory.getCarbonFile(carbonFilePath, configuration); CarbonFile[] carbonIndexFiles = null; if (file.isDirectory()) { if (segmentId == null) { List<CarbonFile> indexFiles = new ArrayList<>(); SegmentIndexFileStore.getCarbonIndexFilesRecursively(file, indexFiles); carbonIndexFiles = indexFiles.toArray(new CarbonFile[0]); } else { String segmentPath = CarbonTablePath.getSegmentPath(carbonFilePath, segmentId); carbonIndexFiles = SegmentIndexFileStore.getCarbonIndexFiles(segmentPath, configuration); } if (carbonIndexFiles.length == 0) { throw new IOException( "No Index files are present in the table location :" + carbonFilePath); } takeCarbonIndexFileSnapShot(carbonIndexFiles); } else { throw new IOException("Path is not pointing to directory"); } }