Package com.dyuproject.protostuff.me

Examples of com.dyuproject.protostuff.me.LinkedBuffer


    }
   
    public void writeObject(final int fieldNumber, final Object value, final Schema schema,
            final boolean repeated) throws IOException
    {
        final LinkedBuffer lastBuffer = tail;
        final int lastSize = size;
        // view
        tail = new LinkedBuffer(lastBuffer, lastBuffer);
       
        schema.writeTo(this, value);
       
        final byte[] delimited = getTagAndRawVarInt32Bytes(
            WireFormat.makeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED),
                size - lastSize);
       
        size += delimited.length;
       
        // the first tag of the inner message
        final LinkedBuffer inner = lastBuffer.next;
       
        // wrap the byte array (delimited) and insert
        new LinkedBuffer(delimited, 0, delimited.length, lastBuffer).next = inner;
    }
View Full Code Here


            LinkedBuffer lb)
    {
        final int size = computeRawVarint32Size(value);

        if(lb.offset + size > lb.buffer.length)
            lb = new LinkedBuffer(session.nextBufferSize, lb);
       
        final byte[] buffer = lb.buffer;
        int offset = lb.offset;
        lb.offset += size;
        session.size += size;
View Full Code Here

        // zero copy
        lb.next = buffer;
       
        final int remaining = lb.buffer.length - lb.offset;
        // if all filled up, return a fresh buffer.
        return remaining == 0 ? new LinkedBuffer(session.nextBufferSize, buffer) :
            new LinkedBuffer(lb, buffer);
    }
View Full Code Here

            {
                // too large ... so we wrap and insert (zero-copy)
                if(available == 0)
                {
                    // buffer was actually full ... return a fresh buffer
                    return new LinkedBuffer(session.nextBufferSize,
                            new LinkedBuffer(value, offset, offset+valueLen, lb));
                }
               
                // continue with the existing byte array of the previous buffer
                return new LinkedBuffer(lb,
                        new LinkedBuffer(value, offset, offset+valueLen, lb));
            }
           
            // copy what can fit
            System.arraycopy(value, offset, lb.buffer, lb.offset, available);
           
            lb.offset += available;
           
            // grow
            lb = new LinkedBuffer(session.nextBufferSize, lb);
           
            final int leftover = valueLen - available;
           
            // copy what's left
            System.arraycopy(value, offset+available, lb.buffer, 0, leftover);
View Full Code Here

        final int tagSize = computeRawVarint32Size(tag);
        final int size = computeRawVarint32Size(value);
        final int totalSize = tagSize + size;

        if(lb.offset + totalSize > lb.buffer.length)
            lb = new LinkedBuffer(session.nextBufferSize, lb);
       
        final byte[] buffer = lb.buffer;
        int offset = lb.offset;
        lb.offset += totalSize;
        session.size += totalSize;
View Full Code Here

        final int tagSize = computeRawVarint32Size(tag);
        final int size = computeRawVarint64Size(value);
        final int totalSize = tagSize + size;
       
        if(lb.offset + totalSize > lb.buffer.length)
            lb = new LinkedBuffer(session.nextBufferSize, lb);
       
        final byte[] buffer = lb.buffer;
        int offset = lb.offset;
        lb.offset += totalSize;
        session.size += totalSize;
View Full Code Here

    {
        final int tagSize = computeRawVarint32Size(tag);
        final int totalSize = tagSize + LITTLE_ENDIAN_32_SIZE;
       
        if(lb.offset + totalSize > lb.buffer.length)
            lb = new LinkedBuffer(session.nextBufferSize, lb);
       
        final byte[] buffer = lb.buffer;
        int offset = lb.offset;
        lb.offset += totalSize;
        session.size += totalSize;
View Full Code Here

    {
        final int tagSize = computeRawVarint32Size(tag);
        final int totalSize = tagSize + LITTLE_ENDIAN_64_SIZE;

        if(lb.offset + totalSize > lb.buffer.length)
            lb = new LinkedBuffer(session.nextBufferSize, lb);
       
        final byte[] buffer = lb.buffer;
        int offset = lb.offset;
        lb.offset += totalSize;
        session.size += totalSize;
View Full Code Here

TOP

Related Classes of com.dyuproject.protostuff.me.LinkedBuffer

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.