protected Set<ElementDescriptor> findMetaFile(String path, String metaname, Configuration conf)
throws IOException {
Set<ElementDescriptor> metaFileSet = new HashSet<ElementDescriptor>();
String[] locations = LoadFunc.getPathStrings(path);
for (String loc : locations) {
DataStorage storage;
storage = new HDataStorage(new Path(loc).toUri(), ConfigurationUtil.toProperties(conf));
String fullPath = FileLocalizer.fullPath(loc, storage);
if(storage.isContainer(fullPath)) {
ElementDescriptor metaFilePath = storage.asElement(fullPath, metaname);
if (exists(metaFilePath)) {
metaFileSet.add(metaFilePath);
}
} else {
ElementDescriptor[] descriptors = storage.asCollection(loc);
for(ElementDescriptor descriptor : descriptors) {
ContainerDescriptor container = null;
if (descriptor instanceof HFile) {
Path descriptorPath = ((HPath) descriptor).getPath();
String fileName = descriptorPath.getName();
Path parent = descriptorPath.getParent();
String parentName = parent.toString();
container = new HDirectory((HDataStorage)storage,parent);
} else { // descriptor instanceof HDirectory
container = (HDirectory)descriptor;
}
// if no custom schema, try the parent directory
ElementDescriptor metaFilePath = storage.asElement(container, metaname);
if (exists(metaFilePath)) {
metaFileSet.add(metaFilePath);
}
}
}