The example is just to illustrate how one should implement one's own WritableComparable class and in the compreTo method, it is just showing how it works in case of IntWritable with "value" as its member variable.
You are right the example's code is misleading. It should have used either timestamp or counter or both and not "value". -Taran On Thu, Dec 11, 2008 at 3:55 PM, Andy Sautins <andy.saut...@returnpath.net>wrote: > > > I have a question regarding the Hadoop API documentation for .19. The > question is in regard to: > http://hadoop.apache.org/core/docs/current/api/org/apache/hadoop/io/Writ > ableComparable.html<http://hadoop.apache.org/core/docs/current/api/org/apache/hadoop/io/WritableComparable.html>. > The document shows the following for the compareTo > method: > > > > public int compareTo(MyWritableComparable w) { > > int thisValue = this.value; > > int thatValue = ((IntWritable)o).value; > > return (thisValue < thatValue ? -1 : (thisValue==thatValue ? 0 > : 1)); > > } > > > > > > Taking the full class example doesn't compile. What I _think_ would > be right would be: > > > > public int compareTo(Object o) { > > int thisValue = this.value; > > int thatValue = ((MyWritableComparable)o).value; > > return (thisValue < thatValue ? -1 : (thisValue==thatValue ? 0 > : 1)); > > } > > > > But even at that it's unclear why the compareTo function is comparing > value ( which isn't a member of the class in the example ) and not the > counter and timestamp variables in the class. > > > > Am I understanding this right? Is there something amiss with the > documentation? > > > > Thanks > > > > Andy > > > > > >