Package org.apache.hadoop.mapred

Examples of org.apache.hadoop.mapred.Partitioner


      if (s.getPath().getName().contains("part-"))
        numPartitions++;
    }
    conf.setInt("NodeCount", nodeCount);

    Partitioner p = null;

    if (useRange) {
      p = new RangePartitioner<IntWritable, Writable>();
      p.configure(conf);
    } else {
      p = new HashPartitioner<WritableComparable, Writable>();
    }

    // this is really annoying: the mapping between the partition numbers on
    // disk (i.e., part-XXXX) and what partition the file contains (i.e.,
    // key.hash % #reducer) is arbitrary... so this means that we need to
    // open up each partition, peek inside to find out.
    IntWritable key = new IntWritable();
    HITSNode value = new HITSNode();
    FileStatus[] status = fs.listStatus(new Path(inputPath));

    StringBuilder sb = new StringBuilder();

    for (FileStatus f : status) {
      if (f.getPath().getName().contains("_logs"))
        continue;

      SequenceFile.Reader reader = new SequenceFile.Reader(fs, f
          .getPath(), conf);

      reader.next(key, value);
      @SuppressWarnings("unchecked")
      int np = p.getPartition(key, value, numPartitions);
      reader.close();

      sLogger.info(f.getPath() + "\t" + np);
      sb.append(np + "=" + f.getPath() + "\t");
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.mapred.Partitioner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.