use of org.apache.carbondata.core.datastore.filesystem.CarbonFileFilter in project carbondata by apache.
the class SegmentFileStore method getSegmentFileForPhysicalDataPartitions.
/**
* It provides segment file only for the partitions which has physical index files.
*
* @param partitionSpecs
*/
public static SegmentFile getSegmentFileForPhysicalDataPartitions(String tablePath, List<PartitionSpec> partitionSpecs) throws IOException {
SegmentFile segmentFile = null;
for (PartitionSpec spec : partitionSpecs) {
String location = spec.getLocation().toString();
CarbonFile carbonFile = FileFactory.getCarbonFile(location);
CarbonFile[] listFiles = carbonFile.listFiles(new CarbonFileFilter() {
@Override
public boolean accept(CarbonFile file) {
return CarbonTablePath.isCarbonIndexFile(file.getAbsolutePath());
}
});
if (listFiles != null && listFiles.length > 0) {
boolean isRelative = false;
if (location.startsWith(tablePath)) {
location = location.substring(tablePath.length(), location.length());
isRelative = true;
}
SegmentFile localSegmentFile = new SegmentFile();
FolderDetails folderDetails = new FolderDetails();
folderDetails.setRelative(isRelative);
folderDetails.setPartitions(spec.getPartitions());
folderDetails.setStatus(SegmentStatus.SUCCESS.getMessage());
for (CarbonFile file : listFiles) {
if (file.getName().endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT)) {
List<String> indexFiles = new SegmentIndexFileStore().getIndexFilesFromMergeFile(file.getAbsolutePath());
folderDetails.getFiles().addAll(indexFiles);
folderDetails.setMergeFileName(file.getName());
} else {
folderDetails.getFiles().add(file.getName());
}
}
localSegmentFile.addPath(location, folderDetails);
if (segmentFile == null) {
segmentFile = localSegmentFile;
} else {
segmentFile = segmentFile.merge(localSegmentFile);
}
}
}
return segmentFile;
}
use of org.apache.carbondata.core.datastore.filesystem.CarbonFileFilter in project carbondata by apache.
the class DiskBasedDMSchemaStorageProvider method retrieveAllSchemas.
@Override
public List<DataMapSchema> retrieveAllSchemas() throws IOException {
List<DataMapSchema> dataMapSchemas = new ArrayList<>();
CarbonFile carbonFile = FileFactory.getCarbonFile(storePath);
CarbonFile[] carbonFiles = carbonFile.listFiles(new CarbonFileFilter() {
@Override
public boolean accept(CarbonFile file) {
return file.getName().endsWith(".dmschema");
}
});
for (CarbonFile file : carbonFiles) {
dataMapSchemas.add(retrieveSchema(file.getName()));
}
return dataMapSchemas;
}
Aggregations