use of org.apache.hadoop.hive.ql.Context.Operation in project hive by apache.
the class ExplainTask method getLocks.
private JSONObject getLocks(PrintStream out, ExplainWork work) {
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
boolean jsonOutput = work.isFormatted();
if (jsonOutput) {
out = null;
}
Operation operation = Optional.of(work).map(ExplainWork::getParseContext).map(ParseContext::getContext).map(Context::getOperation).orElse(Operation.OTHER);
List<LockComponent> lockComponents = AcidUtils.makeLockComponents(work.getOutputs(), work.getInputs(), operation, conf);
if (null != out) {
out.print("LOCK INFORMATION:\n");
}
List<ExplainLockDesc> locks = new ArrayList<>(lockComponents.size());
for (LockComponent component : lockComponents) {
ExplainLockDesc lockDesc = new ExplainLockDesc(component);
if (null != out) {
out.print(lockDesc.getFullName());
out.print(" -> ");
out.print(lockDesc.getLockType());
out.print('\n');
} else {
locks.add(lockDesc);
}
}
if (jsonOutput) {
jsonObject.put("LOCK INFORMATION:", locks);
}
return jsonObject;
}
Aggregations