Package org.apache.crunch.io

Examples of org.apache.crunch.io.FormatBundle


  // configuration field for specifying the separator character.
  private static final String OLD_KV_SEP = "key.value.separator.in.input.line";
  private static final String NEW_KV_SEP = "mapreduce.input.keyvaluelinerecordreader.key.value.separator";
 
  private static FormatBundle getBundle(String sep) {
    FormatBundle bundle = FormatBundle.forInput(KeyValueTextInputFormat.class);
    bundle.set(OLD_KV_SEP, sep);
    bundle.set(NEW_KV_SEP, sep);
    return bundle;
  }
View Full Code Here


  public void readFields(DataInput in) throws IOException {
    if (conf == null) {
      conf = new Configuration();
    }
    nodeIndex = in.readInt();
    bundle = new FormatBundle();
    bundle.setConf(conf);
    bundle.readFields(in);
    bundle.configure(conf); // yay bootstrap!
    Class<? extends InputSplit> inputSplitClass = readClass(in);
    inputSplit = (InputSplit) ReflectionUtils.newInstance(inputSplitClass, conf);
View Full Code Here

  }

  @Override
  public void configureForMapReduce(Job job, PType<?> ptype, Path outputPath, String name) {
    AvroType<?> atype = (AvroType<?>) ptype;
    FormatBundle bundle = FormatBundle.forOutput(AvroOutputFormat.class);
    String schemaParam = null;
    if (name == null) {
      schemaParam = "avro.output.schema";
    } else {
      schemaParam = "avro.output.schema." + name;
    }
    for (Map.Entry<String, String> e : extraConf.entrySet()) {
      bundle.set(e.getKey(), e.getValue());
    }
    bundle.set(schemaParam, atype.getSchema().toString());
    AvroMode.fromType(atype).configure(bundle);
    configureForMapReduce(job, AvroWrapper.class, NullWritable.class, bundle,
        outputPath, name);
  }
View Full Code Here

import org.apache.hadoop.fs.Path;

public class AvroFileSource<T> extends FileSourceImpl<T> implements ReadableSource<T> {

  private static <S> FormatBundle getBundle(AvroType<S> ptype) {
    FormatBundle bundle = FormatBundle.forInput(AvroInputFormat.class)
        .set(AvroJob.INPUT_IS_REFLECT, String.valueOf(ptype.hasReflect()))
        .set(AvroJob.INPUT_SCHEMA, ptype.getSchema().toString())
        .set(Avros.REFLECT_DATA_FACTORY_CLASS, Avros.REFLECT_DATA_FACTORY.getClass().getName());
    return bundle;
  }
View Full Code Here

  }

  @Override
  public void configureForMapReduce(Job job, PType<?> ptype, Path outputPath, String name) {
    AvroType<?> atype = (AvroType<?>) ptype;
    FormatBundle bundle = FormatBundle.forOutput(AvroOutputFormat.class);
    String schemaParam = null;
    if (name == null) {
      schemaParam = "avro.output.schema";
    } else {
      schemaParam = "avro.output.schema." + name;
    }
    bundle.set(schemaParam, atype.getSchema().toString());
    Avros.configureReflectDataFactory(job.getConfiguration());
    configureForMapReduce(job, AvroWrapper.class, NullWritable.class, bundle,
        outputPath, name);
  }
View Full Code Here

    Configuration base = job.getConfiguration();
    Map<FormatBundle, Map<Integer, List<Path>>> formatNodeMap = CrunchInputs.getFormatNodeMap(job);

    // First, build a map of InputFormats to Paths
    for (Map.Entry<FormatBundle, Map<Integer, List<Path>>> entry : formatNodeMap.entrySet()) {
      FormatBundle inputBundle = entry.getKey();
      Configuration conf = new Configuration(base);
      inputBundle.configure(conf);
      Job jobCopy = new Job(conf);
      InputFormat<?, ?> format = (InputFormat<?, ?>) ReflectionUtils.newInstance(inputBundle.getFormatClass(),
          jobCopy.getConfiguration());
      if (format instanceof FileInputFormat && !conf.getBoolean(RuntimeParameters.DISABLE_COMBINE_FILE, false)) {
        format = new CrunchCombineFileInputFormat<Object, Object>(job);
      }
      for (Map.Entry<Integer, List<Path>> nodeEntry : entry.getValue().entrySet()) {
View Full Code Here

    return String.format("CrunchInputSplit(%s)", inputSplit);
  }

  public void readFields(DataInput in) throws IOException {
    nodeIndex = in.readInt();
    bundle = new FormatBundle();
    bundle.setConf(conf);
    bundle.readFields(in);
    bundle.configure(conf); // yay bootstrap!
    Class<? extends InputSplit> inputSplitClass = readClass(in);
    inputSplit = ReflectionUtils.newInstance(inputSplitClass, conf);
View Full Code Here

import org.apache.hadoop.fs.Path;

public class AvroFileSource<T> extends FileSourceImpl<T> implements ReadableSource<T> {

  private static <S> FormatBundle getBundle(AvroType<S> ptype) {
    FormatBundle bundle = FormatBundle.forInput(AvroInputFormat.class)
        .set(AvroJob.INPUT_IS_REFLECT, String.valueOf(ptype.hasReflect()))
        .set(AvroJob.INPUT_SCHEMA, ptype.getSchema().toString())
        .set(Avros.REFLECT_DATA_FACTORY_CLASS, Avros.REFLECT_DATA_FACTORY.getClass().getName());
    return bundle;
  }
View Full Code Here

* run.
*/
public class NLineFileSource<T> extends FileSourceImpl<T> implements ReadableSource<T> {

  private static FormatBundle getBundle(int linesPerTask) {
    FormatBundle bundle = FormatBundle.forInput(NLineInputFormat.class);
    bundle.set(NLineInputFormat.LINES_PER_MAP, String.valueOf(linesPerTask));
    return bundle;
  }
View Full Code Here

  // configuration field for specifying the separator character.
  private static final String OLD_KV_SEP = "key.value.separator.in.input.line";
  private static final String NEW_KV_SEP = "mapreduce.input.keyvaluelinerecordreader.key.value.separator";
 
  private static FormatBundle getBundle(String sep) {
    FormatBundle bundle = FormatBundle.forInput(KeyValueTextInputFormat.class);
    bundle.set(OLD_KV_SEP, sep);
    bundle.set(NEW_KV_SEP, sep);
    return bundle;
  }
View Full Code Here

TOP

Related Classes of org.apache.crunch.io.FormatBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.