Example usage for org.apache.hadoop.io LongWritable toString

List of usage examples for org.apache.hadoop.io LongWritable toString

Introduction

In this page you can find the example usage for org.apache.hadoop.io LongWritable toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.mrgeo.cmd.findholes.mapreduce.FindHolesReducer.java

License:Apache License

/**
 * output of this reducer is:/*from w  ww .  j av  a2 s  .com*/
 * y: x x x x x x x x
 */
public void reduce(LongWritable key, Iterable<LongWritable> values, Context context)
        throws IOException, InterruptedException {

    pw.print(key.toString() + ":");
    for (LongWritable v : values) {
        pw.print(" " + Long.toString(v.get()));
    }
    pw.println();

}

From source file:org.rad.bc.reduce.BookCreatorReducer.java

License:Open Source License

@Override
public void reduce(LongWritable key, Iterable<Text> values, Context context)
        throws IOException, InterruptedException {
    Configuration config = new Configuration();
    Iterator<Text> textIterator = values.iterator();

    String outputPath = context.getConfiguration().get("mapred.output.dir") == null ? ""
            : context.getConfiguration().get("mapred.output.dir") + System.getProperty("file.separator");

    Text text;// w  ww  . j av  a2  s.com
    BufferedWriter bw;
    FileSystem fs;
    OutputStream out;

    while (textIterator.hasNext()) {
        text = textIterator.next();
        fs = FileSystem.get(URI.create("."), config);
        out = fs.create(new Path(outputPath + key.toString() + "_" + System.currentTimeMillis() + ".htm"));
        bw = new BufferedWriter(new OutputStreamWriter(out));
        bw.write(text.toString());
        bw.close();
    }
}

From source file:org.rad.pnf.map.PrimeNumberMapper.java

License:Open Source License

@Override
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
    String line = value.toString();
    StringTokenizer tokens = new StringTokenizer(line, ",");

    int candidate;
    IntWritable primeNumber;/*from   w  w  w.ja  v a  2  s . c o  m*/

    while (tokens.hasMoreTokens()) {
        candidate = Integer.parseInt(tokens.nextToken());

        if (PrimeFinder.isPrime(candidate)) {
            primeNumber = new IntWritable(candidate);
            context.write(new Text(key.toString()), primeNumber);
        }
    }
}

From source file:U.CC.ExpediaMapper3.java

public void map(LongWritable key, Text value, OutputCollector output, Reporter reporter) throws IOException {
    reporter.setStatus(key.toString());
    String page = value.toString();
    String[] arr = page.split("\\s");

    String userDestHot = arr[0] + "," + arr[1] + ":" + arr[2];
    //   System.out.println("userDestHot>>> "+userDestHot);
    String toEmit = arr[3] + " " + arr[4];

    //   System.out.println("toEmit>>> "+toEmit);

    output.collect(new Text(userDestHot), new Text(toEmit));

}

From source file:U.CC.LicenseMapper1.java

public void map(LongWritable key, Text value, OutputCollector output, Reporter reporter) throws IOException {
    // Prepare the input data.
    String license = value.toString();
    //System.out.println("< "+key.toString()+" > "+"< "+license+" >");
    String licenseMap[] = license.split(" ");
    //System.out.println("length >>"+licenseMap.length);
    // we are not interested in people who have no friends at all
    if (licenseMap.length == 4) {

        String plate_number = licenseMap[1].trim(); // plate numbers apparantly have trailing spaces
        String confidence = licenseMap[3];

        output.collect(new Text(plate_number), new Text(confidence));

        // int indexOfcrime = friend.indexOf("#");
        // emmit reverse friendship only if part2 is a person and not a crime
        /*//w w  w.ja  v  a2 s . co  m
         if(indexOfcrime == -1){
           output.collect(new Text(person), new Text(friend));
           output.collect(new Text(friend), new Text(person));
         }else{
           output.collect(new Text(person), new Text("list"));
         }
        */

    } else {
        System.out.println("< " + key.toString() + " > " + "< " + license + " >");
        return;
    }

}