/**
 * Copyright (c) 2013, Cloudera, Inc. All Rights Reserved.
 *
 * Cloudera, Inc. licenses this file to you under the Apache License,
 * Version 2.0 (the "License"). You may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for
 * the specific language governing permissions and limitations under the
 * License.
 */
package com.cloudera.science.ml.client.params;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.crunch.Pipeline;
import org.apache.crunch.impl.mem.MemPipeline;
import org.apache.crunch.impl.mr.MRPipeline;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.compress.CompressionCodec;
import org.apache.hadoop.io.compress.SnappyCodec;
import org.apache.hadoop.util.NativeCodeLoader;

import com.beust.jcommander.Parameter;

/**
 *
 * Pipeline parameters to specify which pipeline to use.
 *
 * Following are possible options
 *
 * <PRE>
 * <b>--local</b>
 *   to ask ML to use Local in-memory pipeline implementation
 *   Default is to use MR pipeline
 * </PRE>
 */
public class PipelineParameters {
  
  private static final Log LOG = LogFactory.getLog(PipelineParameters.class);
  
  @Parameter(names = "--local",
      description = "Use the local, in-memory pipeline implementation")
  private boolean inMemory = false;

  @Parameter(names = "--compress",
      description = "Compress MapReduce output data using Snappy")
  private boolean compress = false;
  
  public Pipeline create(Class<?> jarClass, Configuration conf) {
    if (inMemory) {
      return MemPipeline.getInstance();
    }
    if (compress) {
      if (NativeCodeLoader.buildSupportsSnappy()) {
        conf.setBoolean("mapred.output.compress", true);
        conf.set("mapred.output.compression.type", "BLOCK");
        conf.setClass("mapred.output.compression.codec", SnappyCodec.class, CompressionCodec.class);
      } else {
        LOG.warn("Snappy compression disabled in this environment, no compression enabled");
      }
    }
    return new MRPipeline(jarClass, conf);
  }
}

@@ -1860,62 +1860,8 @@
 ) %7B%0A
-      if (NativeCodeLoader.buildSupportsSnappy()) %7B%0A  
     
@@ -1911,18 +1911,16 @@
  true);%0A
-  
       co
@@ -1966,24 +1966,92 @@
 , %22BLOCK%22);%0A
+      try %7B%0A        if (NativeCodeLoader.buildSupportsSnappy()) %7B%0A  
         conf
@@ -2149,14 +2149,50 @@
     
-%7D else
+  %7D%0A      %7D catch (UnsatisfiedLinkError e)
  %7B%0A 
@@ -2261,30 +2261,27 @@
 nt, 
-no compression enabled
+using default codec
 %22);%0A

Make the --compress option work with the DefaultCodec for local runs