比较if语句中的两个LongWritable

时间:2013-04-22 14:12:14

标签: hadoop mapreduce key-value

如何在If语句中比较两个LongWritable ???等,

if(compareTo(key1,new LongWritable(1))
 { 

    //do something;
 }

1 个答案:

答案 0 :(得分:2)

LongWritable实现Comparable,所以使用compareTo方法:

if (lw1.compareTo(lw2) == 0) {
  // lw1 has same value as lw2
}