Implementation:Apache Flink ElementConverter Apply
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Stream_Processing, Data_Transformation |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Concrete interface for converting pipeline elements to destination-specific request entries provided by the Apache Flink connector-base module.
Description
The ElementConverter is a @FunctionalInterface extending Serializable with two methods: apply for the conversion logic and open as an optional lifecycle hook for initialization. Connector implementations provide concrete converters (e.g., converting records to Kinesis PutRecordRequest objects).
Usage
Implement this interface when building a custom async sink connector. The converter is passed to the AsyncSinkBase constructor or builder.
Code Reference
Source Location
- Repository: Apache Flink
- File: flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/writer/ElementConverter.java
- Lines: L35-41
Signature
@PublicEvolving
public interface ElementConverter<InputT, RequestEntryT> extends Serializable {
RequestEntryT apply(InputT element, SinkWriter.Context context);
default void open(WriterInitContext context) {}
}
Import
import org.apache.flink.connector.base.sink.writer.ElementConverter;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| element | InputT | Yes | Pipeline element to convert |
| context | SinkWriter.Context | Yes | Provides timestamp and watermark |
Outputs
| Name | Type | Description |
|---|---|---|
| requestEntry | RequestEntryT extends Serializable | Destination-specific request entry |
Usage Examples
Custom Element Converter
ElementConverter<MyEvent, PutRecordsRequestEntry> converter =
(element, context) -> {
return PutRecordsRequestEntry.builder()
.data(SdkBytes.fromUtf8String(element.toJson()))
.partitionKey(element.getKey())
.build();
};
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment