/** * Creates and initializes multiple outputs support, * it should be instantiated in the Mapper/Reducer setup method. * * @param context the TaskInputOutputContext object */ public AvroMultipleOutputs( TaskInputOutputContext<?, ?, ?, ?> context) { this.context = context; namedOutputs = Collections.unmodifiableSet( new HashSet<>(AvroMultipleOutputs.getNamedOutputsList(context))); recordWriters = new HashMap<>(); countersEnabled = getCountersEnabled(context); }
/** * Checks if a named output name is valid. * * @param namedOutput named output Name * @throws IllegalArgumentException if the output name is not valid. */ private static void checkNamedOutputName(JobContext job, String namedOutput, boolean alreadyDefined) { checkTokenName(namedOutput); checkBaseOutputPath(namedOutput); List<String> definedChannels = getNamedOutputsList(job); if (alreadyDefined && definedChannels.contains(namedOutput)) { throw new IllegalArgumentException("Named output '" + namedOutput + "' already alreadyDefined"); } else if (!alreadyDefined && !definedChannels.contains(namedOutput)) { throw new IllegalArgumentException("Named output '" + namedOutput + "' not defined"); } }
/** * Creates and initializes multiple outputs support, * it should be instantiated in the Mapper/Reducer setup method. * * @param context the TaskInputOutputContext object */ public AvroMultipleOutputs( TaskInputOutputContext<?, ?, ?, ?> context) { this.context = context; namedOutputs = Collections.unmodifiableSet( new HashSet<String>(AvroMultipleOutputs.getNamedOutputsList(context))); recordWriters = new HashMap<String, RecordWriter<?, ?>>(); countersEnabled = getCountersEnabled(context); }
/** * Checks if a named output name is valid. * * @param namedOutput named output Name * @throws IllegalArgumentException if the output name is not valid. */ private static void checkNamedOutputName(JobContext job, String namedOutput, boolean alreadyDefined) { checkTokenName(namedOutput); checkBaseOutputPath(namedOutput); List<String> definedChannels = getNamedOutputsList(job); if (alreadyDefined && definedChannels.contains(namedOutput)) { throw new IllegalArgumentException("Named output '" + namedOutput + "' already alreadyDefined"); } else if (!alreadyDefined && !definedChannels.contains(namedOutput)) { throw new IllegalArgumentException("Named output '" + namedOutput + "' not defined"); } }