16 package uk.ac.cam.eng.extraction.hadoop.datatypes;
18 import java.io.DataInput;
19 import java.io.IOException;
21 import org.apache.hadoop.io.IntWritable;
30 private static final int low = -128;
31 private static final int high = 127;
32 private static final IntWritable cache[];
34 private static class ImmutableIntWritable
extends IntWritable {
38 ImmutableIntWritable(
int i) {
43 public void set(
int value) {
45 throw new UnsupportedOperationException();
52 public void readFields(DataInput in)
throws IOException {
53 throw new UnsupportedOperationException();
58 cache =
new IntWritable[(high - low) + 1];
60 for (
int k = 0; k < cache.length; k++)
61 cache[k] =
new ImmutableIntWritable(j++);
68 if (i >= low && i <= high)
69 return cache[i + (-low)];
70 return new IntWritable(i);