Example usage for org.apache.hadoop.conf Configuration setFloat

List of usage examples for org.apache.hadoop.conf Configuration setFloat

Introduction

In this page you can find the example usage for org.apache.hadoop.conf Configuration setFloat.

Prototype

public void setFloat(String name, float value) 

Source Link

Document

Set the value of the name property to a float.

Usage

From source file:smile.wide.algorithms.SMILEBSjob.java

License:Apache License

/** Sets up the hadoop job and sends it to the cluster
 * waits for the job to be completed.*/
@Override//from   w  w w .  j a v  a  2 s.c  o  m
public int run(String[] params) throws Exception {
    //params: <trainfile> <output_path> <number of seeds>
    Configuration conf = super.getConf();
    conf.set("trainfile", params[0]);
    //distributed cache initialization
    DistributedCache.createSymlink(conf);

    DistributedCache.addFileToClassPath(new Path(libHDFSPath_ + "/smile.jar"), conf);
    DistributedCache.addCacheFile(new URI(libHDFSPath_ + "/libjsmile.so#libjsmile.so"), conf);
    //upload data file to HDFS and add it to the distributed cache
    FileSystem dfs = FileSystem.get(conf);
    dfs.copyFromLocalFile(new Path(params[0]), new Path(dataHDFSPath_));
    DistributedCache.addCacheFile(new URI(dataHDFSPath_ + basename(params[0]) + "#" + basename(params[0])),
            conf);

    //for now, keep the Bayesian search parameters constant
    conf.setInt("iterationCount", iterationCount);
    conf.setFloat("linkProbability", linkProbability);
    conf.setInt("maxParents", maxParents);
    conf.setInt("maxSearchTime", maxSearchTime);
    conf.setFloat("priorLinkProbability", priorLinkProbability);
    conf.setInt("priorSampleSize", priorSampleSize);
    //
    conf.setInt(RandSeedInputFormat.CONFKEY_SEED_COUNT, Integer.parseInt(params[2]));
    conf.setInt(RandSeedInputFormat.CONFKEY_WARMUP_ITER, 100000);
    conf.setLong("mapred.task.timeout", 3600000);

    Job job = new Job(conf);
    job.setJobName("Distributed Bayesian Search");
    job.setJarByClass(SMILEBSjob.class);
    job.setMapperClass(SMILEBSMapper.class);
    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(StrucLogLikeWritable.class);
    job.setReducerClass(SMILEBSReducer.class);
    job.setNumReduceTasks(1);
    job.setInputFormatClass(RandSeedInputFormat.class);
    Path outputPath = new Path(params[1]);
    FileOutputFormat.setOutputPath(job, outputPath);
    outputPath.getFileSystem(conf).delete(outputPath, true);

    //Run the job
    job.waitForCompletion(true);
    //now download result
    outputPath.suffix("/part-r-00000");
    dfs.copyToLocalFile(outputPath.suffix("/part-r-00000"), new Path("./smile-output.txt"));
    return 0;
}