use of org.apache.gobblin.hive.TableDeregisterStep in project incubator-gobblin by apache.
the class HiveCopyEntityHelper method addTableDeregisterSteps.
@VisibleForTesting
protected int addTableDeregisterSteps(List<CopyEntity> copyEntities, String fileSet, int initialPriority, Table table) throws IOException {
int stepPriority = initialPriority;
Collection<Path> tablePaths = Lists.newArrayList();
switch(this.getDeleteMethod()) {
case RECURSIVE:
tablePaths = Lists.newArrayList(table.getDataLocation());
break;
case INPUT_FORMAT:
InputFormat<?, ?> inputFormat = HiveUtils.getInputFormat(table.getSd());
HiveLocationDescriptor targetLocation = new HiveLocationDescriptor(table.getDataLocation(), inputFormat, this.getTargetFs(), this.getDataset().getProperties());
tablePaths = targetLocation.getPaths().keySet();
break;
case NO_DELETE:
tablePaths = Lists.newArrayList();
break;
default:
tablePaths = Lists.newArrayList();
}
if (!tablePaths.isEmpty()) {
DeleteFileCommitStep deletePaths = DeleteFileCommitStep.fromPaths(this.getTargetFs(), tablePaths, this.getDataset().getProperties(), table.getDataLocation());
copyEntities.add(new PostPublishStep(fileSet, Maps.<String, String>newHashMap(), deletePaths, stepPriority++));
}
TableDeregisterStep deregister = new TableDeregisterStep(table.getTTable(), this.getTargetURI(), this.getHiveRegProps());
copyEntities.add(new PostPublishStep(fileSet, Maps.<String, String>newHashMap(), deregister, stepPriority++));
return stepPriority;
}
Aggregations