Uploaded image for project: 'Crunch (Retired)'
  1. Crunch (Retired)
  2. CRUNCH-657

Can't activate Snappy compression with AvroPathPerKeyTarget

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.11.0
    • None
    • IO
    • None
    • Cloudera

    Description

      Compress.snappy(AvroPathPerKeyTarget) doesn't work.

      I needed to create my own class that extends AvroPathPerKeyTarget.

      public class CompressedAvroPathPerKeyTarget extends AvroPathPerKeyTarget {
      
          private Map<String, String> extraConf = Maps.newHashMap();
      
          public CompressedAvroPathPerKeyTarget(Path path) {
              super(path);
          }
      
          @Override
          public Target outputConf(String key, String value) {
              extraConf.put(key, value);
              return this;
          }
      
          @Override public void configureForMapReduce(Job job, PType<?> ptype, Path outputPath, String name) {
              AvroType<?> atype = (AvroType) ((PTableType) ptype).getValueType();
              FormatBundle bundle = FormatBundle.forOutput(AvroPathPerKeyOutputFormat.class);
              String schemaParam;
              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);
          }
      }
      

      Attachments

        1. CRUNCH-657.patch
          4 kB
          Josh Wills

        Activity

          People

            Unassigned Unassigned
            kazuya Jihed JOOBEUR
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: