public class AppendOnlyWriter extends Object implements BatchRecordWriter, MemoryOwner
RecordWriter implementation that only accepts records which are always insert
operations and don't have any unique keys or sort keys.| Constructor and Description |
|---|
AppendOnlyWriter(FileIO fileIO,
IOManager ioManager,
long schemaId,
FileFormat fileFormat,
long targetFileSize,
RowType writeSchema,
long maxSequenceNumber,
CompactManager compactManager,
IOFunction<List<DataFileMeta>,RecordReaderIterator<InternalRow>> bucketFileRead,
boolean forceCompact,
DataFilePathFactory pathFactory,
CommitIncrement increment,
boolean useWriteBuffer,
boolean spillable,
String fileCompression,
CompressOptions spillCompression,
SimpleColStatsCollector.Factory[] statsCollectors,
MemorySize maxDiskSize,
FileIndexOptions fileIndexOptions,
boolean asyncFileWrite) |
| Modifier and Type | Method and Description |
|---|---|
void |
addNewFiles(List<DataFileMeta> files)
Add files to the internal
CompactManager. |
void |
close()
Close this writer, the call will delete newly generated but not committed files.
|
void |
compact(boolean fullCompaction)
Compact files related to the writer.
|
Collection<DataFileMeta> |
dataFiles()
Get all data files maintained by this writer.
|
void |
flushMemory()
Flush memory of owner, release memory.
|
RowBuffer |
getWriteBuffer() |
boolean |
isCompacting()
Check if a compaction is in progress, or if a compaction result remains to be fetched.
|
long |
maxSequenceNumber()
Get max sequence number of records written by this writer.
|
long |
memoryOccupancy()
Memory occupancy size of this owner.
|
CommitIncrement |
prepareCommit(boolean waitCompaction)
Prepare for a commit.
|
void |
setMemoryPool(MemorySegmentPool memoryPool)
Set
MemorySegmentPool for the owner. |
void |
sync()
Sync the writer.
|
void |
toBufferedWriter() |
void |
withInsertOnly(boolean insertOnly)
This method is called when the insert only status of the records changes.
|
void |
write(InternalRow rowData)
Add a key-value element to the writer.
|
void |
writeBundle(BundleRecords bundle)
Add a batch elemens to the writer.
|
public AppendOnlyWriter(FileIO fileIO, @Nullable IOManager ioManager, long schemaId, FileFormat fileFormat, long targetFileSize, RowType writeSchema, long maxSequenceNumber, CompactManager compactManager, IOFunction<List<DataFileMeta>,RecordReaderIterator<InternalRow>> bucketFileRead, boolean forceCompact, DataFilePathFactory pathFactory, @Nullable CommitIncrement increment, boolean useWriteBuffer, boolean spillable, String fileCompression, CompressOptions spillCompression, SimpleColStatsCollector.Factory[] statsCollectors, MemorySize maxDiskSize, FileIndexOptions fileIndexOptions, boolean asyncFileWrite)
public void write(InternalRow rowData) throws Exception
RecordWriterwrite in interface RecordWriter<InternalRow>Exceptionpublic void writeBundle(BundleRecords bundle) throws Exception
BatchRecordWriterwriteBundle in interface BatchRecordWriterExceptionpublic void compact(boolean fullCompaction)
throws Exception
RecordWritercompact in interface RecordWriter<InternalRow>fullCompaction - whether to trigger full compaction or just normal compactionExceptionpublic void addNewFiles(List<DataFileMeta> files)
RecordWriterCompactManager.addNewFiles in interface RecordWriter<InternalRow>files - files to addpublic Collection<DataFileMeta> dataFiles()
RecordWriterdataFiles in interface RecordWriter<InternalRow>public long maxSequenceNumber()
RecordWritermaxSequenceNumber in interface RecordWriter<InternalRow>public CommitIncrement prepareCommit(boolean waitCompaction) throws Exception
RecordWriterprepareCommit in interface RecordWriter<InternalRow>waitCompaction - if this method need to wait for current compaction to completeExceptionpublic boolean isCompacting()
RecordWriterisCompacting in interface RecordWriter<InternalRow>public void sync()
throws Exception
RecordWritersync in interface RecordWriter<InternalRow>Exceptionpublic void withInsertOnly(boolean insertOnly)
RecordWriterwithInsertOnly in interface RecordWriter<InternalRow>insertOnly - If true, all the following records would be of RowKind.INSERT, and no two records would have the same primary
key.public void close()
throws Exception
RecordWriterclose in interface RecordWriter<InternalRow>Exceptionpublic void setMemoryPool(MemorySegmentPool memoryPool)
MemoryOwnerMemorySegmentPool for the owner.setMemoryPool in interface MemoryOwnerpublic long memoryOccupancy()
MemoryOwnermemoryOccupancy in interface MemoryOwnerpublic void flushMemory()
throws Exception
MemoryOwnerflushMemory in interface MemoryOwnerException@VisibleForTesting public RowBuffer getWriteBuffer()
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.