@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() |
int |
finish()
Mark this
BufferBuilder and associated BufferConsumer as finished - no new data writes will be
allowed. |
int |
getMaxCapacity() |
boolean |
isFinished() |
boolean |
isFull() |
public BufferBuilder(MemorySegment memorySegment, BufferRecycler recycler)
public BufferConsumer createBufferConsumer()
BufferConsumer
to this BufferBuilder
. There can exist only
one BufferConsumer
per each BufferBuilder
and vice versa.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()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.