/** * writes the current row operation as a Put, for use with TableOutputFormat. * * @param context * @throws IOException * @throws InterruptedException */ public void put( TaskInputOutputContext<? extends Object, ? extends Object, ImmutableBytesWritable, Mutation> context) throws IOException, InterruptedException { Put put = createPut(); context.write(tableKey, put); values = new ArrayMap3(); }
@SuppressWarnings("unchecked") public void write(String namedOutput, K key, V value) throws IOException, InterruptedException { if (!namedOutputs.containsKey(namedOutput)) { throw new IllegalArgumentException("Undefined named output '" + namedOutput + "'"); } if (!disableOutputCounters) { baseContext.getCounter(COUNTERS_GROUP, namedOutput).increment(1); } getOutputState(namedOutput).write(key, value); }
public void putBulkLoadPut( TaskInputOutputContext<? extends Object, ? extends Object, ImmutableBytesWritable, Put> context) throws IOException, InterruptedException { // if (partitioner == null) { // partitioner = new TotalOrderPartitioner(); // partitioner.setConf(context.getConfiguration()); // } ImmutableBytesWritable key = new ImmutableBytesWritable(rowkey); Put put = createPut(); context.write(key, put); values = new ArrayMap3(); }
private static void write( TaskInputOutputContext<?, ?, BytesWritable, Text> context, final byte[] groupKey, DimValueCount dimValueCount) throws IOException, InterruptedException { context.write( new SortableBytes( groupKey, TAB_JOINER .join(dimValueCount.dim, dimValueCount.value) .getBytes(HadoopDruidIndexerConfig.JAVA_NATIVE_CHARSET)) .toBytesWritable(), dimValueCount.toText()); }
private OutputState<K, V> getOutputState(String namedOutput) throws IOException, InterruptedException { OutputState<?, ?> out = outputStates.get(namedOutput); if (out != null) { return (OutputState<K, V>) out; } // The following trick leverages the instantiation of a record writer via // the job thus supporting arbitrary output formats. Job job = getJob(baseContext.getJobID(), namedOutput, baseConf); // Get a job with the expected named output. job = getJob(job.getJobID(), namedOutput, baseConf); OutputFormat<K, V> fmt = getOutputFormat(namedOutput, job, namedOutputs.get(namedOutput)); TaskAttemptContext taskContext = getTaskContext(baseContext, job); RecordWriter<K, V> recordWriter = fmt.getRecordWriter(taskContext); OutputState<K, V> outputState = new OutputState(taskContext, recordWriter); this.outputStates.put(namedOutput, outputState); return outputState; }
/** * Creates and initializes multiple outputs support, it should be instantiated in the * Mapper/Reducer setup method. * * @param context the TaskInputOutputContext object */ public CrunchOutputs(TaskInputOutputContext<?, ?, K, V> context) { this(context.getConfiguration()); this.baseContext = context; }
private static Map<String, OutputConfig> getNamedOutputs( TaskInputOutputContext<?, ?, ?, ?> context) { return getNamedOutputs(context.getConfiguration()); }