Cambridge SMT System
ExtractedData.java
Go to the documentation of this file.
1 /*******************************************************************************
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use these files except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  *
14  * Copyright 2014 - Juan Pino, Aurelien Waite, William Byrne
15  *******************************************************************************/
20 package uk.ac.cam.eng.extraction.hadoop.datatypes;
21 
22 import java.io.DataInput;
23 import java.io.DataOutput;
24 import java.io.IOException;
25 
26 import org.apache.hadoop.io.ByteWritable;
27 import org.apache.hadoop.io.IntWritable;
28 import org.apache.hadoop.io.Writable;
29 
30 import uk.ac.cam.eng.extraction.Alignment;
31 
32 
43 public class ExtractedData implements Writable {
44 
45  private ProvenanceCountMap provenance;
46  private AlignmentCountMapWritable alignment;
47 
48  public ExtractedData() {
49  provenance = new ProvenanceCountMap();
50  alignment = new AlignmentCountMapWritable();
51  }
52 
54  return provenance;
55  }
56 
58  return alignment;
59  }
60 
61  public void clear() {
62  provenance.clear();
63  alignment.clear();
64  }
65 
66  public void putProvenanceCount(
67  ByteWritable provenanceName, IntWritable count) {
68  provenance.put(provenanceName, count);
69  }
70 
71  public void putAlignmentCount(Alignment align, int count) {
72  alignment.put(align, count);
73  }
74 
75  public void increment(ExtractedData other) {
76  provenance.increment(other.provenance);
77  alignment.increment(other.alignment);
78  }
79 
80  /*
81  * (non-Javadoc)
82  *
83  * @see org.apache.hadoop.io.Writable#write(java.io.DataOutput)
84  */
85  @Override
86  public void write(DataOutput out) throws IOException {
87  provenance.write(out);
88  alignment.write(out);
89  }
90 
91  /*
92  * (non-Javadoc)
93  *
94  * @see org.apache.hadoop.io.Writable#readFields(java.io.DataInput)
95  */
96  @Override
97  public void readFields(DataInput in) throws IOException {
98  provenance.readFields(in);
99  alignment.readFields(in);
100  }
101 
102  public String toString() {
103  return provenance.toString() + "\t" + alignment.toString();
104  }
105 }
IntWritable put(ByteWritable key, IntWritable value)
void putProvenanceCount(ByteWritable provenanceName, IntWritable count)