public AutoExpandingBufferWriteTransport(int initialCapacity, double growthCoefficient) { this.buf = new AutoExpandingBuffer(initialCapacity, growthCoefficient); this.pos = 0; }
@Override public void write(byte[] toWrite, int off, int len) throws TTransportException { buf.resizeIfNecessary(pos + len); System.arraycopy(toWrite, off, buf.array(), pos, len); pos += len; }
@Override public final byte[] getBuffer() { return buf.array(); }
@Override public final byte[] getBuffer() { return buf.array(); }
@Override public void write(byte[] toWrite, int off, int len) throws TTransportException { buf.resizeIfNecessary(pos + len); System.arraycopy(toWrite, off, buf.array(), pos, len); pos += len; }
@Override public final int read(byte[] target, int off, int len) throws TTransportException { int amtToRead = Math.min(len, getBytesRemainingInBuffer()); System.arraycopy(buf.array(), pos, target, off, amtToRead); consumeBuffer(amtToRead); return amtToRead; }
public AutoExpandingBufferReadTransport(int initialCapacity, double overgrowthCoefficient) { this.buf = new AutoExpandingBuffer(initialCapacity, overgrowthCoefficient); }
public void fill(TTransport inTrans, int length) throws TTransportException { buf.resizeIfNecessary(length); inTrans.readAll(buf.array(), 0, length); pos = 0; limit = length; }
@Override public final int read(byte[] target, int off, int len) throws TTransportException { int amtToRead = Math.min(len, getBytesRemainingInBuffer()); System.arraycopy(buf.array(), pos, target, off, amtToRead); consumeBuffer(amtToRead); return amtToRead; }
public AutoExpandingBufferWriteTransport(int initialCapacity, double growthCoefficient) { this.buf = new AutoExpandingBuffer(initialCapacity, growthCoefficient); this.pos = 0; }
public void fill(TTransport inTrans, int length) throws TTransportException { buf.resizeIfNecessary(length); inTrans.readAll(buf.array(), 0, length); pos = 0; limit = length; }
@Override public void flush() throws TTransportException { int length = writeBuffer.getPos(); TFramedTransport.encodeFrameSize(length, i32buf); underlying.write(i32buf, 0, 4); underlying.write(writeBuffer.getBuf().array(), 0, length); writeBuffer.reset(); underlying.flush(); }
public AutoExpandingBufferReadTransport(int initialCapacity, double overgrowthCoefficient) { this.buf = new AutoExpandingBuffer(initialCapacity, overgrowthCoefficient); }
@Override public void flush() throws TTransportException { int length = writeBuffer.getPos(); TFramedTransport.encodeFrameSize(length, i32buf); underlying.write(i32buf, 0, 4); underlying.write(writeBuffer.getBuf().array(), 0, length); writeBuffer.reset(); underlying.flush(); }