예제 #1
0
파일: Table.java 프로젝트: bejvisek/htools
 /**
  * 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();
 }
예제 #2
0
 @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);
 }
예제 #3
0
파일: Table.java 프로젝트: bejvisek/htools
 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());
 }
예제 #5
0
  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;
  }
예제 #6
0
 /**
  * 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;
 }
예제 #7
0
 private static Map<String, OutputConfig> getNamedOutputs(
     TaskInputOutputContext<?, ?, ?, ?> context) {
   return getNamedOutputs(context.getConfiguration());
 }