hadoop-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Schlaikjer <andrew.schlaik...@gmail.com>
Subject specification of type params in org.apache.hadoop.io.*Writable impls
Date Mon, 29 Mar 2010 23:06:50 GMT
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,

Mime
View raw message