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
RecordWriter
write
in interface RecordWriter<InternalRow>
Exception
public void writeBundle(BundleRecords bundle) throws Exception
BatchRecordWriter
writeBundle
in interface BatchRecordWriter
Exception
public void compact(boolean fullCompaction) throws Exception
RecordWriter
compact
in interface RecordWriter<InternalRow>
fullCompaction
- whether to trigger full compaction or just normal compactionException
public void addNewFiles(List<DataFileMeta> files)
RecordWriter
CompactManager
.addNewFiles
in interface RecordWriter<InternalRow>
files
- files to addpublic Collection<DataFileMeta> dataFiles()
RecordWriter
dataFiles
in interface RecordWriter<InternalRow>
public long maxSequenceNumber()
RecordWriter
maxSequenceNumber
in interface RecordWriter<InternalRow>
public CommitIncrement prepareCommit(boolean waitCompaction) throws Exception
RecordWriter
prepareCommit
in interface RecordWriter<InternalRow>
waitCompaction
- if this method need to wait for current compaction to completeException
public boolean isCompacting()
RecordWriter
isCompacting
in interface RecordWriter<InternalRow>
public void sync() throws Exception
RecordWriter
sync
in interface RecordWriter<InternalRow>
Exception
public void withInsertOnly(boolean insertOnly)
RecordWriter
withInsertOnly
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
RecordWriter
close
in interface RecordWriter<InternalRow>
Exception
public void setMemoryPool(MemorySegmentPool memoryPool)
MemoryOwner
MemorySegmentPool
for the owner.setMemoryPool
in interface MemoryOwner
public long memoryOccupancy()
MemoryOwner
memoryOccupancy
in interface MemoryOwner
public void flushMemory() throws Exception
MemoryOwner
flushMemory
in interface MemoryOwner
Exception
@VisibleForTesting public RowBuffer getWriteBuffer()
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.