16 package uk.ac.cam.eng.extraction.hadoop.datatypes;
18 import java.io.DataInput;
19 import java.io.DataOutput;
20 import java.io.IOException;
21 import java.util.EnumMap;
23 import org.apache.hadoop.io.Writable;
24 import org.apache.hadoop.io.WritableUtils;
28 public class FeatureMap extends EnumMap<Feature, ProvenanceProbMap> implements Writable {
38 for (Entry<Feature, ProvenanceProbMap> entry : other.entrySet()){
43 private static final long serialVersionUID = 1L;
47 private static final long serialVersionUID = 1L;
50 throw new UnsupportedOperationException();
56 public void readFields(DataInput in)
throws IOException {
58 int noOfKeys = WritableUtils.readVInt(in);
59 for(
int i=0;i<noOfKeys;++i){
60 int ordinal = WritableUtils.readVInt(in);
69 public void write(DataOutput out)
throws IOException {
70 WritableUtils.writeVInt(out, size());
71 for(Entry<Feature, ProvenanceProbMap> entry : entrySet()){
72 WritableUtils.writeVInt(out,entry.getKey().ordinal());
73 entry.getValue().write(out);
78 int expectedSize = size() + other.size();
80 if (expectedSize != size()) {
81 throw new RuntimeException(
"Two features with the same id: " +
this 82 +
" " + other +
" expected size = " + expectedSize);