Class CopyingStreamWindow
java.lang.Object
com.couchbase.client.core.json.stream.CopyingStreamWindow
- All Implemented Interfaces:
StreamWindow,Closeable,AutoCloseable
A stream window implementation that copies input data into a single accumulator buffer.
-
Constructor Summary
ConstructorsConstructorDescriptionCopyingStreamWindow(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator allocator) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf buf) Appends the given buffer to the end of the stream.voidclose()Releases all buffers owned by the window.byte[]getBytes(long startStreamOffset, long endStreamOffset) Returns a region of the stream as a byte array.voidreleaseBefore(long releaseStreamOffset) Forgets any bytes with stream offsets lower then the given offset.toString()
-
Constructor Details
-
CopyingStreamWindow
public CopyingStreamWindow(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator allocator)
-
-
Method Details
-
add
public void add(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf buf) Description copied from interface:StreamWindowAppends the given buffer to the end of the stream. The window takes ownership of the buffer (and may even release it immediately).- Specified by:
addin interfaceStreamWindow
-
releaseBefore
public void releaseBefore(long releaseStreamOffset) Description copied from interface:StreamWindowForgets any bytes with stream offsets lower then the given offset.- Specified by:
releaseBeforein interfaceStreamWindow- Parameters:
releaseStreamOffset- offset relative to the start of the stream.
-
getBytes
public byte[] getBytes(long startStreamOffset, long endStreamOffset) Description copied from interface:StreamWindowReturns a region of the stream as a byte array.- Specified by:
getBytesin interfaceStreamWindow- Parameters:
startStreamOffset- region start offset relative to beginning of stream.endStreamOffset- region end offset relative to beginning of stream.
-
close
public void close()Description copied from interface:StreamWindowReleases all buffers owned by the window.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceStreamWindow
-
toString
-