Class ResettableExternalBuffer
- java.lang.Object
-
- org.apache.flink.table.runtime.util.ResettableExternalBuffer
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ResettableRowBuffer
public class ResettableExternalBuffer extends Object implements ResettableRowBuffer
A resettable external buffer for binary row. It stores records in memory and spill to disk when memory is not enough. When the spill is completed, the records are written to memory again. The returned iterator reads the data in write order (read spilled records first). It supports infinite length. It can open multiple Iterators. It support new iterator with beginRow.NOTE: Not supports reading while writing. In the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classResettableExternalBuffer.BufferIteratorIterator of external buffer.-
Nested classes/interfaces inherited from interface org.apache.flink.table.runtime.util.ResettableRowBuffer
ResettableRowBuffer.ResettableIterator
-
-
Field Summary
Fields Modifier and Type Field Description static intMIN_NUM_MEMORYThe minimum number of segments that are required, 320 KibiBytes.
-
Constructor Summary
Constructors Constructor Description ResettableExternalBuffer(org.apache.flink.runtime.io.disk.iomanager.IOManager ioManager, LazyMemorySegmentPool pool, AbstractRowDataSerializer serializer, boolean isRowAllInFixedPart)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(org.apache.flink.table.data.RowData row)Appends the specified row to the end of this buffer.voidclose()Delete all files and release the memory.voidcomplete()Finally, complete add.intgetNumSpillFiles()longgetSpillInBytes()longgetUsedMemoryInBytes()ResettableExternalBuffer.BufferIteratornewIterator()Get a new iterator starting from first row.ResettableExternalBuffer.BufferIteratornewIterator(int beginRow)Get a new iterator starting from the `beginRow`-th row.voidreset()Re-initialize the buffer state.intsize()
-
-
-
Field Detail
-
MIN_NUM_MEMORY
public static final int MIN_NUM_MEMORY
The minimum number of segments that are required, 320 KibiBytes.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ResettableExternalBuffer
public ResettableExternalBuffer(org.apache.flink.runtime.io.disk.iomanager.IOManager ioManager, LazyMemorySegmentPool pool, AbstractRowDataSerializer serializer, boolean isRowAllInFixedPart)
-
-
Method Detail
-
reset
public void reset()
Description copied from interface:ResettableRowBufferRe-initialize the buffer state.- Specified by:
resetin interfaceResettableRowBuffer
-
add
public void add(org.apache.flink.table.data.RowData row) throws IOExceptionDescription copied from interface:ResettableRowBufferAppends the specified row to the end of this buffer.- Specified by:
addin interfaceResettableRowBuffer- Throws:
IOException
-
complete
public void complete()
Description copied from interface:ResettableRowBufferFinally, complete add.- Specified by:
completein interfaceResettableRowBuffer
-
newIterator
public ResettableExternalBuffer.BufferIterator newIterator()
Description copied from interface:ResettableRowBufferGet a new iterator starting from first row.- Specified by:
newIteratorin interfaceResettableRowBuffer
-
newIterator
public ResettableExternalBuffer.BufferIterator newIterator(int beginRow)
Description copied from interface:ResettableRowBufferGet a new iterator starting from the `beginRow`-th row. `beginRow` is 0-indexed.- Specified by:
newIteratorin interfaceResettableRowBuffer
-
close
public void close()
Delete all files and release the memory.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
size
public int size()
-
getUsedMemoryInBytes
public long getUsedMemoryInBytes()
-
getNumSpillFiles
public int getNumSpillFiles()
-
getSpillInBytes
public long getSpillInBytes()
-
-