Can anyone comment on why the base *Writable implementations (e.g.
IntWritable, LongWritable, etc) don't specify WritableComparable<T>'s
type param T?
I noticed this when I tried to use DoubleWritable [1] within a custom
WritableComparable parameterized type which constrains its own type
params:
public class Pair<
First extends WritableComparable<First>,
Second extends WritableComparable<Second>>
implements WritableComparable<Pair<First, Second>> {
...
}
With this declaration, something like the following will not compile:
Pair<DoubleWritable, DoubleWritable> pair = null;
ERROR: Bound mismatch: The type DoubleWritable is not a valid
substitute for the bounded parameter <First extends
WritableComparable<First>> of the type Pair<First,Second>
However, if DoubleWritable were declared as follows, the above line
would work just fine:
public class DoubleWritable implements WritableComparable<DoubleWritable> {
...
}
[1] http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/DoubleWritable.java?revision=786726&view=markup
Best,
|