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
ConstructorDescriptionCopyingStreamWindow
(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator allocator) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf buf) Appends the given buffer to the end of the stream.void
close()
Releases all buffers owned by the window.byte[]
getBytes
(long startStreamOffset, long endStreamOffset) Returns a region of the stream as a byte array.void
releaseBefore
(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:StreamWindow
Appends the given buffer to the end of the stream. The window takes ownership of the buffer (and may even release it immediately).- Specified by:
add
in interfaceStreamWindow
-
releaseBefore
public void releaseBefore(long releaseStreamOffset) Description copied from interface:StreamWindow
Forgets any bytes with stream offsets lower then the given offset.- Specified by:
releaseBefore
in interfaceStreamWindow
- Parameters:
releaseStreamOffset
- offset relative to the start of the stream.
-
getBytes
public byte[] getBytes(long startStreamOffset, long endStreamOffset) Description copied from interface:StreamWindow
Returns a region of the stream as a byte array.- Specified by:
getBytes
in 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:StreamWindow
Releases all buffers owned by the window.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceStreamWindow
-
toString
-