Search in sources :

Example 1 with MRInputLegacy

use of org.apache.tez.mapreduce.input.MRInputLegacy in project hive by apache.

the class MapRecordProcessor method getMRInput.

private MRInputLegacy getMRInput(Map<String, LogicalInput> inputs) throws Exception {
    // there should be only one MRInput
    MRInputLegacy theMRInput = null;
    // start all mr/multi-mr inputs
    Set<Input> li = new HashSet<Input>();
    for (LogicalInput inp : inputs.values()) {
        if (inp instanceof MRInputLegacy || inp instanceof MultiMRInput) {
            inp.start();
            li.add(inp);
        }
    }
    // TODO: HIVE-14042. Potential blocking call. MRInput handles this correctly even if an interrupt is swallowed.
    // MultiMRInput may not. Fix once TEZ-3302 is resolved.
    processorContext.waitForAllInputsReady(li);
    l4j.info("The input names are: " + Arrays.toString(inputs.keySet().toArray()));
    for (Entry<String, LogicalInput> inp : inputs.entrySet()) {
        if (inp.getValue() instanceof MRInputLegacy) {
            if (theMRInput != null) {
                throw new IllegalArgumentException("Only one MRInput is expected");
            }
            // a better logic would be to find the alias
            theMRInput = (MRInputLegacy) inp.getValue();
        } else if (inp.getValue() instanceof MultiMRInput) {
            multiMRInputMap.put(inp.getKey(), (MultiMRInput) inp.getValue());
        }
    }
    if (theMRInput != null) {
        theMRInput.init();
    } else {
        String alias = mapWork.getAliasToWork().keySet().iterator().next();
        if (inputs.get(alias) instanceof MultiMRInput) {
            mainWorkMultiMRInput = (MultiMRInput) inputs.get(alias);
        } else {
            throw new IOException("Unexpected input type found: " + inputs.get(alias).getClass().getCanonicalName());
        }
    }
    return theMRInput;
}
Also used : LogicalInput(org.apache.tez.runtime.api.LogicalInput) Input(org.apache.tez.runtime.api.Input) MultiMRInput(org.apache.tez.mapreduce.input.MultiMRInput) LogicalInput(org.apache.tez.runtime.api.LogicalInput) IOException(java.io.IOException) MRInputLegacy(org.apache.tez.mapreduce.input.MRInputLegacy) HashSet(java.util.HashSet) MultiMRInput(org.apache.tez.mapreduce.input.MultiMRInput)

Example 2 with MRInputLegacy

use of org.apache.tez.mapreduce.input.MRInputLegacy in project hive by apache.

the class MergeFileRecordProcessor method getMRInput.

private MRInputLegacy getMRInput(Map<String, LogicalInput> inputs) throws Exception {
    LOG.info("The inputs are: " + inputs);
    // start the mr input and wait for ready event. number of MRInput is expected to be 1
    List<Input> li = Lists.newArrayList();
    int numMRInputs = 0;
    for (LogicalInput inp : inputs.values()) {
        if (inp instanceof MRInputLegacy) {
            numMRInputs++;
            if (numMRInputs > 1) {
                throw new IllegalArgumentException("Only one MRInput is expected");
            }
            inp.start();
            li.add(inp);
        } else {
            throw new IllegalArgumentException("Expecting only one input of type MRInputLegacy." + " Found type: " + inp.getClass().getCanonicalName());
        }
    }
    // typically alter table .. concatenate is run on only one partition/one table,
    // so it doesn't matter if we wait for all inputs or any input to be ready.
    processorContext.waitForAnyInputReady(li);
    final MRInputLegacy theMRInput;
    if (li.size() == 1) {
        theMRInput = (MRInputLegacy) li.get(0);
        theMRInput.init();
    } else {
        throw new IllegalArgumentException("MRInputs count is expected to be 1");
    }
    return theMRInput;
}
Also used : LogicalInput(org.apache.tez.runtime.api.LogicalInput) Input(org.apache.tez.runtime.api.Input) LogicalInput(org.apache.tez.runtime.api.LogicalInput) MRInputLegacy(org.apache.tez.mapreduce.input.MRInputLegacy)

Aggregations

MRInputLegacy (org.apache.tez.mapreduce.input.MRInputLegacy)2 Input (org.apache.tez.runtime.api.Input)2 LogicalInput (org.apache.tez.runtime.api.LogicalInput)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 MultiMRInput (org.apache.tez.mapreduce.input.MultiMRInput)1