Java Code Examples for org.apache.hadoop.io.LongWritable#compareTo()

The following examples show how to use org.apache.hadoop.io.LongWritable#compareTo() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   File: TestOldCombinerGrouping.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void reduce(Text key, Iterator<LongWritable> values,
    OutputCollector<Text, LongWritable> output, Reporter reporter)
    throws IOException {
  LongWritable maxValue = null;
  while (values.hasNext()) {
    LongWritable value = values.next();
    if (maxValue == null) {
      maxValue = value;
    } else if (value.compareTo(maxValue) > 0) {
      maxValue = value;
    }
  }
  output.collect(key, maxValue);
}
 
Example 2
Source Project: hadoop   File: TestNewCombinerGrouping.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void reduce(Text key, Iterable<LongWritable> values,
    Context context)
    throws IOException, InterruptedException {
  LongWritable maxValue = null;
  for (LongWritable value : values) {
    if (maxValue == null) {
      maxValue = value;
    } else if (value.compareTo(maxValue) > 0) {
      maxValue = value;
    }
  }
  context.write(key, maxValue);
}
 
Example 3
Source Project: big-c   File: TestOldCombinerGrouping.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void reduce(Text key, Iterator<LongWritable> values,
    OutputCollector<Text, LongWritable> output, Reporter reporter)
    throws IOException {
  LongWritable maxValue = null;
  while (values.hasNext()) {
    LongWritable value = values.next();
    if (maxValue == null) {
      maxValue = value;
    } else if (value.compareTo(maxValue) > 0) {
      maxValue = value;
    }
  }
  output.collect(key, maxValue);
}
 
Example 4
Source Project: big-c   File: TestNewCombinerGrouping.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void reduce(Text key, Iterable<LongWritable> values,
    Context context)
    throws IOException, InterruptedException {
  LongWritable maxValue = null;
  for (LongWritable value : values) {
    if (maxValue == null) {
      maxValue = value;
    } else if (value.compareTo(maxValue) > 0) {
      maxValue = value;
    }
  }
  context.write(key, maxValue);
}
 
Example 5
Source Project: MLHadoop   File: find_nth_mapper.java    License: Apache License 2.0 5 votes vote down vote up
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
	String[] input = value.toString().split("\\t");
	if (!input[0].contains(",")) {
		LongWritable rowKey = new LongWritable(Long.valueOf(input[0]));
		if (rowKey.compareTo(this.nthKey) == 0) {
			this.nthValue = new Text(input[1]);
		}
	}
}