// Path: src/main/java/io/izenecloud/msgpack/MsgpackOutputFormat.java
// public class MsgpackOutputFormat<K, V> extends OutputFormat<K, V> {
// 
// 	@Override
// 	public void checkOutputSpecs(JobContext context) throws IOException,
// 			InterruptedException {
// 	}
// 
// 	@Override
// 	public OutputCommitter getOutputCommitter(TaskAttemptContext context)
// 			throws IOException, InterruptedException {
// 		return new OutputCommitter() {
// 			public void abortTask(TaskAttemptContext taskContext) {
// 			}
// 
// 			public void cleanupJob(JobContext jobContext) {
// 			}
// 
// 			public void commitTask(TaskAttemptContext taskContext) {
// 			}
// 
// 			public boolean needsTaskCommit(TaskAttemptContext taskContext) {
// 				return false;
// 			}
// 
// 			public void setupJob(JobContext jobContext) {
// 			}
// 
// 			public void setupTask(TaskAttemptContext taskContext) {
// 			}
// 
// 			
// 			public boolean isRecoverySupported() {
// 				return true;
// 			}
// 
// 			
// 			public void recoverTask(TaskAttemptContext taskContext)
// 					throws IOException {
// 				// Nothing to do for recovering the task.
// 			}
// 		};
// 	}
// 
// 	@Override
// 	public RecordWriter<K, V> getRecordWriter(TaskAttemptContext context)
// 			throws IOException, InterruptedException {
// 		return new MsgpackRecordWriter<K, V>(context);
// 	}
// 
// }


import io.izenecloud.msgpack.MsgpackOutputFormat;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
package io.izenecloud.lr;




public class LrIterationDriver {
	public static int run(String collection, Path input, Path output,
			Float regularizationFactor, Boolean addIntercept,
			Configuration baseConf) throws IOException, ClassNotFoundException,
			InterruptedException {
		Configuration conf = new Configuration(baseConf);
		if (null != addIntercept) {
			conf.setBoolean("lr.iteration.add.intercept", addIntercept);
		}
		if (null != regularizationFactor) {
			conf.setDouble("lr.iteration.regulariztion.factor",
					regularizationFactor);
		}

		conf.set("com.b5m.laser.msgpack.output.method", "update_online_model");

		Job job = Job.getInstance(conf);
		job.setJarByClass(LrIterationDriver.class);
		job.setJobName("logistic regression");

		FileInputFormat.setInputPaths(job, input);

// Path: src/main/java/io/izenecloud/msgpack/MsgpackOutputFormat.java
// public class MsgpackOutputFormat<K, V> extends OutputFormat<K, V> {
// 
// 	@Override
// 	public void checkOutputSpecs(JobContext context) throws IOException,
// 			InterruptedException {
// 	}
// 
// 	@Override
// 	public OutputCommitter getOutputCommitter(TaskAttemptContext context)
// 			throws IOException, InterruptedException {
// 		return new OutputCommitter() {
// 			public void abortTask(TaskAttemptContext taskContext) {
// 			}
// 
// 			public void cleanupJob(JobContext jobContext) {
// 			}
// 
// 			public void commitTask(TaskAttemptContext taskContext) {
// 			}
// 
// 			public boolean needsTaskCommit(TaskAttemptContext taskContext) {
// 				return false;
// 			}
// 
// 			public void setupJob(JobContext jobContext) {
// 			}
// 
// 			public void setupTask(TaskAttemptContext taskContext) {
// 			}
// 
// 			
// 			public boolean isRecoverySupported() {
// 				return true;
// 			}
// 
// 			
// 			public void recoverTask(TaskAttemptContext taskContext)
// 					throws IOException {
// 				// Nothing to do for recovering the task.
// 			}
// 		};
// 	}
// 
// 	@Override
// 	public RecordWriter<K, V> getRecordWriter(TaskAttemptContext context)
// 			throws IOException, InterruptedException {
// 		return new MsgpackRecordWriter<K, V>(context);
// 	}
// 
// }


// Path: src/main/java/io/izenecloud/lr/LrIterationDriver.java
import io.izenecloud.msgpack.MsgpackOutputFormat;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

package io.izenecloud.lr;




public class LrIterationDriver {
	public static int run(String collection, Path input, Path output,
			Float regularizationFactor, Boolean addIntercept,
			Configuration baseConf) throws IOException, ClassNotFoundException,
			InterruptedException {
		Configuration conf = new Configuration(baseConf);
		if (null != addIntercept) {
			conf.setBoolean("lr.iteration.add.intercept", addIntercept);
		}
		if (null != regularizationFactor) {
			conf.setDouble("lr.iteration.regulariztion.factor",
					regularizationFactor);
		}

		conf.set("com.b5m.laser.msgpack.output.method", "update_online_model");

		Job job = Job.getInstance(conf);
		job.setJarByClass(LrIterationDriver.class);
		job.setJobName("logistic regression");

		FileInputFormat.setInputPaths(job, input);

		job.setOutputFormatClass(MsgpackOutputFormat.class);