T - type of record to write into FileStore.public class TableWriteImpl<T> extends Object implements InnerTableWrite, Restorable<List<FileStoreWrite.State<T>>>
TableWrite implementation.| Modifier and Type | Class and Description |
|---|---|
static interface |
TableWriteImpl.RecordExtractor<T>
Extractor to extract
T from the SinkRecord. |
| Constructor and Description |
|---|
TableWriteImpl(RowType rowType,
FileStoreWrite<T> write,
KeyAndBucketExtractor<InternalRow> keyAndBucketExtractor,
TableWriteImpl.RecordExtractor<T> recordExtractor,
RowKindGenerator rowKindGenerator,
boolean ignoreDelete) |
| Modifier and Type | Method and Description |
|---|---|
List<FileStoreWrite.State<T>> |
checkpoint()
Extract state of the current operation instance.
|
void |
close() |
void |
compact(BinaryRow partition,
int bucket,
boolean fullCompaction)
Compact a bucket of a partition.
|
int |
getBucket(InternalRow row)
Calculate which bucket
row belongs to. |
BinaryRow |
getPartition(InternalRow row)
Calculate which partition
row belongs to. |
FileStoreWrite<T> |
getWrite() |
void |
notifyNewFiles(long snapshotId,
BinaryRow partition,
int bucket,
List<DataFileMeta> files)
Notify that some new files are created at given snapshot in given bucket.
|
List<CommitMessage> |
prepareCommit()
Prepare commit for
TableCommit. |
List<CommitMessage> |
prepareCommit(boolean waitCompaction,
long commitIdentifier)
Prepare commit for
TableCommit. |
void |
restore(List<FileStoreWrite.State<T>> state)
Restore state of a previous operation instance into the current operation instance.
|
SinkRecord |
toLogRecord(SinkRecord record) |
TableWriteImpl<T> |
withBucketMode(BucketMode bucketMode) |
TableWriteImpl<T> |
withCompactExecutor(ExecutorService compactExecutor) |
TableWriteImpl<T> |
withExecutionMode(boolean isStreamingMode) |
TableWriteImpl<T> |
withIgnorePreviousFiles(boolean ignorePreviousFiles) |
void |
withInsertOnly(boolean insertOnly)
This method is called when the insert only status of the records changes.
|
TableWriteImpl<T> |
withIOManager(IOManager ioManager)
With
IOManager, this is needed if 'write-buffer-spillable' is set to true. |
TableWriteImpl<T> |
withMemoryPool(MemorySegmentPool memoryPool)
With
MemorySegmentPool for the current table write. |
TableWriteImpl<T> |
withMemoryPoolFactory(MemoryPoolFactory memoryPoolFactory) |
TableWriteImpl<T> |
withMetricRegistry(MetricRegistry metricRegistry)
With metrics to measure compaction.
|
void |
write(InternalRow row)
Write a row to the writer.
|
void |
write(InternalRow row,
int bucket)
Write a row with bucket.
|
SinkRecord |
writeAndReturn(InternalRow row) |
SinkRecord |
writeAndReturn(InternalRow row,
int bucket) |
void |
writeBundle(BinaryRow partition,
int bucket,
BundleRecords bundle)
Write a bundle records directly, not per row.
|
public TableWriteImpl(RowType rowType, FileStoreWrite<T> write, KeyAndBucketExtractor<InternalRow> keyAndBucketExtractor, TableWriteImpl.RecordExtractor<T> recordExtractor, @Nullable RowKindGenerator rowKindGenerator, boolean ignoreDelete)
public TableWriteImpl<T> withIgnorePreviousFiles(boolean ignorePreviousFiles)
withIgnorePreviousFiles in interface InnerTableWritepublic TableWriteImpl<T> withExecutionMode(boolean isStreamingMode)
withExecutionMode in interface InnerTableWritepublic TableWriteImpl<T> withIOManager(IOManager ioManager)
TableWriteIOManager, this is needed if 'write-buffer-spillable' is set to true.withIOManager in interface TableWritepublic TableWriteImpl<T> withMemoryPool(MemorySegmentPool memoryPool)
TableWriteMemorySegmentPool for the current table write.withMemoryPool in interface TableWritepublic TableWriteImpl<T> withMemoryPoolFactory(MemoryPoolFactory memoryPoolFactory)
public TableWriteImpl<T> withCompactExecutor(ExecutorService compactExecutor)
public TableWriteImpl<T> withBucketMode(BucketMode bucketMode)
public void withInsertOnly(boolean insertOnly)
TableWritewithInsertOnly in interface TableWriteinsertOnly - If true, all the following records would be of RowKind.INSERT, and no two records would have the same primary
key.public BinaryRow getPartition(InternalRow row)
TableWriterow belongs to.getPartition in interface TableWritepublic int getBucket(InternalRow row)
TableWriterow belongs to.getBucket in interface TableWritepublic void write(InternalRow row) throws Exception
TableWritewrite in interface TableWriteExceptionpublic void write(InternalRow row, int bucket) throws Exception
TableWritewrite in interface TableWriteExceptionpublic void writeBundle(BinaryRow partition, int bucket, BundleRecords bundle) throws Exception
TableWritewriteBundle in interface TableWriteException@Nullable public SinkRecord writeAndReturn(InternalRow row) throws Exception
Exception@Nullable public SinkRecord writeAndReturn(InternalRow row, int bucket) throws Exception
Exceptionpublic SinkRecord toLogRecord(SinkRecord record)
public void compact(BinaryRow partition, int bucket, boolean fullCompaction) throws Exception
TableWriteNOTE: In Java API, full compaction is not automatically executed. If you set 'changelog-producer' to 'full-compaction', please execute this method regularly to produce changelog.
compact in interface TableWriteExceptionpublic TableWriteImpl<T> withMetricRegistry(MetricRegistry metricRegistry)
TableWritewithMetricRegistry in interface TableWritepublic void notifyNewFiles(long snapshotId,
BinaryRow partition,
int bucket,
List<DataFileMeta> files)
Most probably, these files are created by another job. Currently this method is only used by the dedicated compact job to see files created by writer jobs.
public List<CommitMessage> prepareCommit(boolean waitCompaction, long commitIdentifier) throws Exception
StreamTableWriteTableCommit. Collect incremental files for this write.prepareCommit in interface StreamTableWritewaitCompaction - whether to wait for the end of the background compaction.commitIdentifier - Committed transaction ID, can start from 0. If there are multiple
commits, please increment this ID.ExceptionStreamTableCommit.commit(long, java.util.List<org.apache.paimon.table.sink.CommitMessage>)public List<CommitMessage> prepareCommit() throws Exception
BatchTableWriteTableCommit. Collect incremental files for this write.prepareCommit in interface BatchTableWriteExceptionBatchTableCommit.commit(java.util.List<org.apache.paimon.table.sink.CommitMessage>)public void close()
throws Exception
close in interface AutoCloseableExceptionpublic List<FileStoreWrite.State<T>> checkpoint()
Restorablecheckpoint in interface Restorable<List<FileStoreWrite.State<T>>>public void restore(List<FileStoreWrite.State<T>> state)
Restorablerestore in interface Restorable<List<FileStoreWrite.State<T>>>@VisibleForTesting public FileStoreWrite<T> getWrite()
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.