17 package uk.ac.cam.eng.extraction.hadoop.datatypes;
19 import java.io.DataInput;
20 import java.io.DataOutput;
21 import java.io.IOException;
22 import java.util.HashMap;
24 import org.apache.hadoop.io.Writable;
25 import org.apache.hadoop.io.file.tfile.Utils;
35 HashMap<Alignment, Integer> implements Writable {
37 private static final long serialVersionUID = 1L;
41 private static final long serialVersionUID = 1L;
43 public Integer put(Alignment key, Integer value) {
44 throw new UnsupportedOperationException();
53 for(Entry<Alignment, Integer> entry : other.entrySet()){
54 put(
new Alignment(entry.getKey()), entry.getValue());
59 for (Entry<Alignment, Integer> alignCount : newCounts
61 Alignment key = alignCount.getKey();
62 if (containsKey(key)) {
63 put(key,
get(key) + newCounts.get(key));
65 put(key, newCounts.get(key));
71 int expectedSize = size() + other.size();
73 if (expectedSize != size()) {
74 throw new RuntimeException(
"Merging twice the same alignment " 85 public void write(DataOutput out)
throws IOException {
86 Utils.writeVInt(out, size());
87 for (Alignment a : keySet()) {
89 Utils.writeVInt(out,
get(a));
99 public void readFields(DataInput in)
throws IOException {
101 int size = Utils.readVInt(in);
102 for (
int i = 0; i < size; ++i) {
103 Alignment a =
new Alignment();
105 int alignmentCount = Utils.readVInt(in);
106 put(a, alignmentCount);