@NotThreadSafe public class BufferBuilder extends Object
MemorySegment
. To access written data please use
BufferConsumer
which allows to build Buffer
instances from the written data.Constructor and Description |
---|
BufferBuilder(MemorySegment memorySegment,
BufferRecycler recycler) |
Modifier and Type | Method and Description |
---|---|
int |
append(ByteBuffer source)
Append as many data as possible from
source . |
int |
appendAndCommit(ByteBuffer source)
Same as
append(ByteBuffer) but additionally commit() the appending. |
void |
commit()
Make the change visible to the readers.
|
BufferConsumer |
createBufferConsumer()
This method always creates a
BufferConsumer starting from the current writer offset. |
int |
finish()
Mark this
BufferBuilder and associated BufferConsumer as finished - no new data writes will be
allowed. |
int |
getCommittedBytes() |
int |
getMaxCapacity() |
boolean |
isFinished() |
boolean |
isFull() |
public BufferBuilder(MemorySegment memorySegment, BufferRecycler recycler)
public BufferConsumer createBufferConsumer()
BufferConsumer
starting from the current writer offset. Data written to
BufferBuilder
before creation of BufferConsumer
won't be visible for that BufferConsumer
.BufferConsumer
to this BufferBuilder
.public int appendAndCommit(ByteBuffer source)
append(ByteBuffer)
but additionally commit()
the appending.public int append(ByteBuffer source)
source
. Not everything might be copied if there is not enough
space in the underlying MemorySegment
public void commit()
public int finish()
BufferBuilder
and associated BufferConsumer
as finished - no new data writes will be
allowed.
This method should be idempotent to handle failures and task interruptions. Check FLINK-8948 for more details.
public boolean isFinished()
public boolean isFull()
public int getMaxCapacity()
public int getCommittedBytes()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.