readExternal((DataInput)in);
}
public void writeExternal(final DataOutput out) throws IOException {
ArrayList<Range> values = new ArrayList<Range>(ranges.values());
out.writeInt(values.size());
AbstractVarIntSupport helper = new AbstractVarIntSupport() {
@Override
protected byte readByte() throws IOException {
throw new UnsupportedOperationException();
}
@Override
protected void writeByte(int value) throws IOException {
out.writeByte(value);
}
};
// We should get good compression since ranges should be
// close to each other and we are just recording a var int
// of the difference between the points.
int base = 0;
for( Range range: values) {
helper.writeVarInt(range.start-base);
base = range.start;
helper.writeVarInt(range.end-base);
base = range.end;
}
}