// Path: src/main/java/io/izenecloud/msgpack/MsgpackInputFormat.java
// public class MsgpackInputFormat<V> extends InputFormat<Long, V> {
// 
// 	private long goalsize(Configuration conf) {
// 		String urlList = conf.get("com.b5m.laser.msgpack.host");
// 		int port = conf.getInt("com.b5m.laser.msgpack.port", 0);
// 		String collection = conf.get("com.b5m.laser.collection");
// 		String method = conf.get("com.b5m.laser.msgpack.input.method");
// 		MsgpackClient client = new MsgpackClient(urlList, port, collection);
// 		try {
// 			Long size = (Long) client.asyncRead(new Object[0], method + "|size",
// 					Long.class);
// 			client.close();
// 			return size;
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 		return 0;
// 	}
// 
// 	@Override
// 	public List<InputSplit> getSplits(JobContext context) throws IOException,
// 			InterruptedException {
// 		Configuration conf = context.getConfiguration();
// 		long goalSize = goalsize(conf);
// 		String[] urlList = conf.get("com.b5m.laser.msgpack.host").split(",");
// 		int numNode = urlList.length;
// 		List<InputSplit> splits = new ArrayList<InputSplit>();
// 		long splitLength = (long) Math.ceil((double) goalSize / numNode);
// 
// 		long bytesRemaining = goalSize;
// 		for (int i = 0; i < numNode; i++) {
// 			if (bytesRemaining > splitLength) {
// 				splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// 						splitLength, null));
// 			} else {
// 				splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// 						bytesRemaining, null));
// 			}
// 			bytesRemaining -= splitLength;
// 		}
// 		return splits;
// 	}
// 
// 	@Override
// 	public RecordReader<Long, V> createRecordReader(InputSplit split,
// 			TaskAttemptContext context) throws IOException,
// 			InterruptedException {
// 		return new MsgpackRecordReader<V>();
// 	}
// 
// }
// 
// 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.MsgpackInputFormat;
import io.izenecloud.msgpack.MsgpackOutputFormat;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
package io.izenecloud.larser.offline.precompute;




public class Compute {
	
	public static int run(Path model, Configuration baseConf) throws IOException, ClassNotFoundException,
			InterruptedException {
		Configuration conf = new Configuration(baseConf);
		conf.set("com.b5m.laser.msgpack.input.method", "ad_feature");
		conf.set("com.b5m.laser.msgpack.output.method", "precompute_ad_offline_model");
		conf.set("com.b5m.laser.offline.model", model.toString());
		Job job = Job.getInstance(conf);
		job.setJarByClass(Compute.class);
		job.setJobName("per compute stable part from offline model for each user");
		job.setInputFormatClass(MsgpackInputFormat.class);
// Path: src/main/java/io/izenecloud/msgpack/MsgpackInputFormat.java
// public class MsgpackInputFormat<V> extends InputFormat<Long, V> {
// 
// 	private long goalsize(Configuration conf) {
// 		String urlList = conf.get("com.b5m.laser.msgpack.host");
// 		int port = conf.getInt("com.b5m.laser.msgpack.port", 0);
// 		String collection = conf.get("com.b5m.laser.collection");
// 		String method = conf.get("com.b5m.laser.msgpack.input.method");
// 		MsgpackClient client = new MsgpackClient(urlList, port, collection);
// 		try {
// 			Long size = (Long) client.asyncRead(new Object[0], method + "|size",
// 					Long.class);
// 			client.close();
// 			return size;
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 		return 0;
// 	}
// 
// 	@Override
// 	public List<InputSplit> getSplits(JobContext context) throws IOException,
// 			InterruptedException {
// 		Configuration conf = context.getConfiguration();
// 		long goalSize = goalsize(conf);
// 		String[] urlList = conf.get("com.b5m.laser.msgpack.host").split(",");
// 		int numNode = urlList.length;
// 		List<InputSplit> splits = new ArrayList<InputSplit>();
// 		long splitLength = (long) Math.ceil((double) goalSize / numNode);
// 
// 		long bytesRemaining = goalSize;
// 		for (int i = 0; i < numNode; i++) {
// 			if (bytesRemaining > splitLength) {
// 				splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// 						splitLength, null));
// 			} else {
// 				splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// 						bytesRemaining, null));
// 			}
// 			bytesRemaining -= splitLength;
// 		}
// 		return splits;
// 	}
// 
// 	@Override
// 	public RecordReader<Long, V> createRecordReader(InputSplit split,
// 			TaskAttemptContext context) throws IOException,
// 			InterruptedException {
// 		return new MsgpackRecordReader<V>();
// 	}
// 
// }
// 
// 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/larser/offline/precompute/Compute.java
import io.izenecloud.msgpack.MsgpackInputFormat;
import io.izenecloud.msgpack.MsgpackOutputFormat;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;

package io.izenecloud.larser.offline.precompute;




public class Compute {
	
	public static int run(Path model, Configuration baseConf) throws IOException, ClassNotFoundException,
			InterruptedException {
		Configuration conf = new Configuration(baseConf);
		conf.set("com.b5m.laser.msgpack.input.method", "ad_feature");
		conf.set("com.b5m.laser.msgpack.output.method", "precompute_ad_offline_model");
		conf.set("com.b5m.laser.offline.model", model.toString());
		Job job = Job.getInstance(conf);
		job.setJarByClass(Compute.class);
		job.setJobName("per compute stable part from offline model for each user");
		job.setInputFormatClass(MsgpackInputFormat.class);
		job.setOutputFormatClass(MsgpackOutputFormat.class);