My mapper output value is a type of an Enum, and I set the mapOutputValueClass as the Enum.class, but always get
Type mismatch in value from map expected StatisticTypes, recieved StatisticTypes$2
It seems like the it received a nested class instead of a subclass, is there anything wrong with my Enum class?
Job set up:
job.setMapOutputValueClass(StatisticTypes.class);
Output:
for(StatisticTypes statistic : dimensionCountMap.get(key)) {
context.write(key, statistic);
}
Enum:
public enum StatisticTypes implements Writable{
MAX {
@Override
public boolean aggregate(long v, LongWritable userId) {
if (v > value) {
value = v;
this.userId = userId;
return true;
}
return false;
}
@Override
public void write(DataOutput out) throws IOException {
ObjectWritable objWritable = new ObjectWritable(this);
objWritable.write(out);
}
@Override
public void readFields(DataInput in) throws IOException {
ObjectWritable objWritable = new ObjectWritable();
objWritable.readFields(in);
}
};
public LongWritable userId;
public long value;
public abstract boolean aggregate(long v, LongWritable userId);
public long getValue() {
return value;
};
public LongWritable getUserId() {
return userId;
}
@Override
public void write(DataOutput out) throws IOException {
ObjectWritable objWritable = new ObjectWritable(this);
objWritable.write(out);
}
@Override
public void readFields(DataInput in) throws IOException {
ObjectWritable objWritable = new ObjectWritable();
objWritable.readFields(in);
}
}