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 InnerTableWrite
public TableWriteImpl<T> withExecutionMode(boolean isStreamingMode)
withExecutionMode
in interface InnerTableWrite
public TableWriteImpl<T> withIOManager(IOManager ioManager)
TableWrite
IOManager
, this is needed if 'write-buffer-spillable' is set to true.withIOManager
in interface TableWrite
public TableWriteImpl<T> withMemoryPool(MemorySegmentPool memoryPool)
TableWrite
MemorySegmentPool
for the current table write.withMemoryPool
in interface TableWrite
public TableWriteImpl<T> withMemoryPoolFactory(MemoryPoolFactory memoryPoolFactory)
public TableWriteImpl<T> withCompactExecutor(ExecutorService compactExecutor)
public TableWriteImpl<T> withBucketMode(BucketMode bucketMode)
public void withInsertOnly(boolean insertOnly)
TableWrite
withInsertOnly
in interface TableWrite
insertOnly
- 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)
TableWrite
row
belongs to.getPartition
in interface TableWrite
public int getBucket(InternalRow row)
TableWrite
row
belongs to.getBucket
in interface TableWrite
public void write(InternalRow row) throws Exception
TableWrite
write
in interface TableWrite
Exception
public void write(InternalRow row, int bucket) throws Exception
TableWrite
write
in interface TableWrite
Exception
public void writeBundle(BinaryRow partition, int bucket, BundleRecords bundle) throws Exception
TableWrite
writeBundle
in interface TableWrite
Exception
@Nullable public SinkRecord writeAndReturn(InternalRow row) throws Exception
Exception
@Nullable public SinkRecord writeAndReturn(InternalRow row, int bucket) throws Exception
Exception
public SinkRecord toLogRecord(SinkRecord record)
public void compact(BinaryRow partition, int bucket, boolean fullCompaction) throws Exception
TableWrite
NOTE: 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 TableWrite
Exception
public TableWriteImpl<T> withMetricRegistry(MetricRegistry metricRegistry)
TableWrite
withMetricRegistry
in interface TableWrite
public 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
StreamTableWrite
TableCommit
. Collect incremental files for this write.prepareCommit
in interface StreamTableWrite
waitCompaction
- 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.Exception
StreamTableCommit.commit(long, java.util.List<org.apache.paimon.table.sink.CommitMessage>)
public List<CommitMessage> prepareCommit() throws Exception
BatchTableWrite
TableCommit
. Collect incremental files for this write.prepareCommit
in interface BatchTableWrite
Exception
BatchTableCommit.commit(java.util.List<org.apache.paimon.table.sink.CommitMessage>)
public void close() throws Exception
close
in interface AutoCloseable
Exception
public List<FileStoreWrite.State<T>> checkpoint()
Restorable
checkpoint
in interface Restorable<List<FileStoreWrite.State<T>>>
public void restore(List<FileStoreWrite.State<T>> state)
Restorable
restore
in interface Restorable<List<FileStoreWrite.State<T>>>
@VisibleForTesting public FileStoreWrite<T> getWrite()
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.