Search in sources :

Example 1 with Operation

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;
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) JSONObject(org.json.JSONObject) ParseContext(org.apache.hadoop.hive.ql.parse.ParseContext) ArrayList(java.util.ArrayList) Operation(org.apache.hadoop.hive.ql.Context.Operation) HiveOperation(org.apache.hadoop.hive.ql.plan.HiveOperation) ExplainLockDesc(org.apache.hadoop.hive.ql.plan.ExplainLockDesc)

Aggregations

ArrayList (java.util.ArrayList)1 LockComponent (org.apache.hadoop.hive.metastore.api.LockComponent)1 Operation (org.apache.hadoop.hive.ql.Context.Operation)1 ParseContext (org.apache.hadoop.hive.ql.parse.ParseContext)1 ExplainLockDesc (org.apache.hadoop.hive.ql.plan.ExplainLockDesc)1 HiveOperation (org.apache.hadoop.hive.ql.plan.HiveOperation)1 JSONObject (org.json.JSONObject)1