Class CompactOperator<T>
- java.lang.Object
-
- org.apache.flink.streaming.api.operators.AbstractStreamOperator<PartitionCommitInfo>
-
- org.apache.flink.connector.file.table.stream.compact.CompactOperator<T>
-
- All Implemented Interfaces:
Serializable
,CheckpointListener
,BoundedOneInput
,Input<CompactMessages.CoordinatorOutput>
,KeyContext
,KeyContextHandler
,OneInputStreamOperator<CompactMessages.CoordinatorOutput,PartitionCommitInfo>
,StreamOperator<PartitionCommitInfo>
,StreamOperatorStateHandler.CheckpointedStreamOperator
,YieldingOperator<PartitionCommitInfo>
@Internal public class CompactOperator<T> extends AbstractStreamOperator<PartitionCommitInfo> implements OneInputStreamOperator<CompactMessages.CoordinatorOutput,PartitionCommitInfo>, BoundedOneInput
Receives compaction units to do compaction. Send partition commit information after compaction finished.Use
BulkFormat
to read and useBucketWriter
to write.STATE: This operator stores expired files in state, after the checkpoint completes successfully, We can ensure that these files will not be used again and they can be deleted from the file system.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMPACTED_PREFIX
static String
UNCOMPACTED_PREFIX
-
Fields inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
config, lastRecordAttributes1, lastRecordAttributes2, latencyStats, LOG, metrics, output, processingTimeService, stateHandler, stateKeySelector1, stateKeySelector2, timeServiceManager
-
-
Constructor Summary
Constructors Constructor Description CompactOperator(SupplierWithException<FileSystem,IOException> fsFactory, CompactReader.Factory<T> readerFactory, CompactWriter.Factory<T> writerFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Path
convertFromUncompacted(Path path)
static String
convertToUncompacted(String path)
void
endInput()
It is notified that no more data will arrive from the input.void
initializeState(StateInitializationContext context)
Stream operators with state which can be restored need to override this hook method.void
notifyCheckpointComplete(long checkpointId)
Notifies the listener that the checkpoint with the givencheckpointId
completed and was committed.void
processElement(StreamRecord<CompactMessages.CoordinatorOutput> element)
Processes one element that arrived on this input of theMultipleInputStreamOperator
.void
snapshotState(StateSnapshotContext context)
Stream operators with state, which want to participate in a snapshot need to override this hook method.-
Methods inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
close, finish, getContainingTask, getCurrentKey, getExecutionConfig, getInternalTimerService, getKeyedStateBackend, getKeyedStateStore, getMetricGroup, getOperatorConfig, getOperatorID, getOperatorName, getOperatorStateBackend, getOrCreateKeyedState, getPartitionedState, getPartitionedState, getProcessingTimeService, getRuntimeContext, getStateKeySelector1, getStateKeySelector2, getTimeServiceManager, getUserCodeClassloader, hasKeyContext1, hasKeyContext2, initializeState, isUsingCustomRawKeyedState, notifyCheckpointAborted, open, prepareSnapshotPreBarrier, processLatencyMarker, processLatencyMarker1, processLatencyMarker2, processRecordAttributes, processRecordAttributes1, processRecordAttributes2, processWatermark, processWatermark1, processWatermark2, processWatermarkStatus, processWatermarkStatus1, processWatermarkStatus2, reportOrForwardLatencyMarker, setCurrentKey, setKeyContextElement1, setKeyContextElement2, setMailboxExecutor, setProcessingTimeService, setup, snapshotState, useSplittableTimers
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.api.common.state.CheckpointListener
notifyCheckpointAborted
-
Methods inherited from interface org.apache.flink.streaming.api.operators.Input
processLatencyMarker, processRecordAttributes, processWatermark, processWatermarkStatus
-
Methods inherited from interface org.apache.flink.streaming.api.operators.KeyContext
getCurrentKey, setCurrentKey
-
Methods inherited from interface org.apache.flink.streaming.api.operators.KeyContextHandler
hasKeyContext
-
Methods inherited from interface org.apache.flink.streaming.api.operators.OneInputStreamOperator
setKeyContextElement
-
Methods inherited from interface org.apache.flink.streaming.api.operators.StreamOperator
close, finish, getMetricGroup, getOperatorAttributes, getOperatorID, initializeState, open, prepareSnapshotPreBarrier, setKeyContextElement1, setKeyContextElement2, snapshotState
-
-
-
-
Field Detail
-
UNCOMPACTED_PREFIX
public static final String UNCOMPACTED_PREFIX
- See Also:
- Constant Field Values
-
COMPACTED_PREFIX
public static final String COMPACTED_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CompactOperator
public CompactOperator(SupplierWithException<FileSystem,IOException> fsFactory, CompactReader.Factory<T> readerFactory, CompactWriter.Factory<T> writerFactory)
-
-
Method Detail
-
initializeState
public void initializeState(StateInitializationContext context) throws Exception
Description copied from class:AbstractStreamOperator
Stream operators with state which can be restored need to override this hook method.- Specified by:
initializeState
in interfaceStreamOperatorStateHandler.CheckpointedStreamOperator
- Overrides:
initializeState
in classAbstractStreamOperator<PartitionCommitInfo>
- Parameters:
context
- context that allows to register different states.- Throws:
Exception
-
processElement
public void processElement(StreamRecord<CompactMessages.CoordinatorOutput> element) throws Exception
Description copied from interface:Input
Processes one element that arrived on this input of theMultipleInputStreamOperator
. This method is guaranteed to not be called concurrently with other methods of the operator.- Specified by:
processElement
in interfaceInput<T>
- Throws:
Exception
-
snapshotState
public void snapshotState(StateSnapshotContext context) throws Exception
Description copied from class:AbstractStreamOperator
Stream operators with state, which want to participate in a snapshot need to override this hook method.- Specified by:
snapshotState
in interfaceStreamOperatorStateHandler.CheckpointedStreamOperator
- Overrides:
snapshotState
in classAbstractStreamOperator<PartitionCommitInfo>
- Parameters:
context
- context that provides information and means required for taking a snapshot- Throws:
Exception
-
notifyCheckpointComplete
public void notifyCheckpointComplete(long checkpointId) throws Exception
Description copied from interface:CheckpointListener
Notifies the listener that the checkpoint with the givencheckpointId
completed and was committed.These notifications are "best effort", meaning they can sometimes be skipped. To behave properly, implementers need to follow the "Checkpoint Subsuming Contract". Please see the
class-level JavaDocs
for details.Please note that checkpoints may generally overlap, so you cannot assume that the
notifyCheckpointComplete()
call is always for the latest prior checkpoint (or snapshot) that was taken on the function/operator implementing this interface. It might be for a checkpoint that was triggered earlier. Implementing the "Checkpoint Subsuming Contract" (see above) properly handles this situation correctly as well.Please note that throwing exceptions from this method will not cause the completed checkpoint to be revoked. Throwing exceptions will typically cause task/job failure and trigger recovery.
- Specified by:
notifyCheckpointComplete
in interfaceCheckpointListener
- Overrides:
notifyCheckpointComplete
in classAbstractStreamOperator<PartitionCommitInfo>
- Parameters:
checkpointId
- The ID of the checkpoint that has been completed.- Throws:
Exception
- This method can propagate exceptions, which leads to a failure/recovery for the task. Note that this will NOT lead to the checkpoint being revoked.
-
endInput
public void endInput() throws Exception
Description copied from interface:BoundedOneInput
It is notified that no more data will arrive from the input.WARNING: It is not safe to use this method to commit any transactions or other side effects! You can use this method to flush any buffered data that can later on be committed e.g. in a
CheckpointListener.notifyCheckpointComplete(long)
.NOTE: Given it is semantically very similar to the
StreamOperator.finish()
method. It might be dropped in favour of the other method at some point in time.- Specified by:
endInput
in interfaceBoundedOneInput
- Throws:
Exception
-
-