Package org.fusesource.hawtbuf

Examples of org.fusesource.hawtbuf.AbstractVarIntSupport


        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;
        }

    }
View Full Code Here


    public void readExternal(final DataInput in) throws IOException {
        ranges.clear();

        int size = in.readInt();
        AbstractVarIntSupport helper = new AbstractVarIntSupport() {
            @Override
            protected byte readByte() throws IOException {
                return in.readByte();
            }

            @Override
            protected void writeByte(int value) throws IOException {
                throw new UnsupportedOperationException();
            }
        };

        int base = 0;
        for(int i=0; i < size; i++) {
            base += helper.readVarInt();
            int start = base;
            base += helper.readVarInt();
            int end = base;
            ranges.put(start, range(start, end));
        }
    }
View Full Code Here

TOP

Related Classes of org.fusesource.hawtbuf.AbstractVarIntSupport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.