// The input file does not exist, replace it by a empty file
Class<? extends HiveOutputFormat> outFileFormat = null;
boolean nonNative = true;
Properties props;
if (isEmptyPath) {
PartitionDesc partDesc = work.getPathToPartitionInfo().get(path);
props = partDesc.getProperties();
outFileFormat = partDesc.getOutputFileFormatClass();
nonNative = partDesc.getTableDesc().isNonNative();
} else {
TableDesc tableDesc = work.getAliasToPartnInfo().get(alias).getTableDesc();
props = tableDesc.getProperties();
outFileFormat = tableDesc.getOutputFileFormatClass();
nonNative = tableDesc.isNonNative();
}
if (nonNative) {
FileInputFormat.addInputPaths(job, path);
LOG.info("Add a non-native table " + path);
return numEmptyPaths;
}
// create a dummy empty file in a new directory
String newDir = hiveScratchDir + File.separator + (++numEmptyPaths);
Path newPath = new Path(newDir);
FileSystem fs = newPath.getFileSystem(job);
fs.mkdirs(newPath);
//Qualify the path against the filesystem. The user configured path might contain default port which is skipped
//in the file status. This makes sure that all paths which goes into PathToPartitionInfo are always listed status
//filepath.
newPath = fs.makeQualified(newPath);
String newFile = newDir + File.separator + "emptyFile";
Path newFilePath = new Path(newFile);
LOG.info("Changed input file to " + newPath.toString());
// toggle the work
LinkedHashMap<String, ArrayList<String>> pathToAliases = work.getPathToAliases();
if (isEmptyPath) {
assert path != null;
pathToAliases.put(newPath.toUri().toString(), pathToAliases.get(path));
pathToAliases.remove(path);
} else {
assert path == null;
ArrayList<String> newList = new ArrayList<String>();
newList.add(alias);
pathToAliases.put(newPath.toUri().toString(), newList);
}
work.setPathToAliases(pathToAliases);
LinkedHashMap<String, PartitionDesc> pathToPartitionInfo = work.getPathToPartitionInfo();
if (isEmptyPath) {
pathToPartitionInfo.put(newPath.toUri().toString(), pathToPartitionInfo.get(path));
pathToPartitionInfo.remove(path);
} else {
PartitionDesc pDesc = work.getAliasToPartnInfo().get(alias).clone();
pathToPartitionInfo.put(newPath.toUri().toString(), pDesc);
}
work.setPathToPartitionInfo(pathToPartitionInfo);
String onefile = newPath.toString();