if (ts.tableHandle.isPartitioned()) {
partitions = (ts.partitions != null) ? ts.partitions : db.getPartitions(ts.tableHandle);
}
Path path = new Path(ctx.getLocalTmpPath(), "_metadata");
EximUtil.createExportDump(FileSystem.getLocal(conf), path, ts.tableHandle, partitions);
Task<? extends Serializable> rTask = TaskFactory.get(new CopyWork(
path, new Path(toURI), false), conf);
rootTasks.add(rTask);
LOG.debug("_metadata file written into " + path.toString()
+ " and then copied to " + toURI.toString());
} catch (Exception e) {
throw new SemanticException(
ErrorMsg.GENERIC_ERROR
.getMsg("Exception while writing out the local file"), e);
}
Path parentPath = new Path(toURI);
if (ts.tableHandle.isPartitioned()) {
for (Partition partition : partitions) {
Path fromPath = partition.getDataLocation();
Path toPartPath = new Path(parentPath, partition.getName());
Task<? extends Serializable> rTask = TaskFactory.get(
new CopyWork(fromPath, toPartPath, false),
conf);
rootTasks.add(rTask);
inputs.add(new ReadEntity(partition));
}
} else {
Path fromPath = ts.tableHandle.getDataLocation();
Path toDataPath = new Path(parentPath, "data");
Task<? extends Serializable> rTask = TaskFactory.get(new CopyWork(
fromPath, toDataPath, false), conf);
rootTasks.add(rTask);
inputs.add(new ReadEntity(ts.tableHandle));
}
outputs.add(new WriteEntity(parentPath, toURI.getScheme().equals("hdfs")));