@Internal public abstract class KafkaTableSource extends Object implements org.apache.flink.table.sources.StreamTableSource<Row>, org.apache.flink.table.sources.DefinedProctimeAttribute, org.apache.flink.table.sources.DefinedRowtimeAttributes
StreamTableSource
.
The version-specific Kafka consumers need to extend this class and
override createKafkaConsumer(String, Properties, DeserializationSchema)
}.
Modifier and Type | Class and Description |
---|---|
protected static class |
KafkaTableSource.Builder<T extends KafkaTableSource,B extends KafkaTableSource.Builder>
Abstract builder for a
KafkaTableSource to be extended by builders of subclasses of
KafkaTableSource. |
Modifier | Constructor and Description |
---|---|
protected |
KafkaTableSource(String topic,
Properties properties,
org.apache.flink.table.api.TableSchema schema,
TypeInformation<Row> returnType)
Creates a generic Kafka
StreamTableSource . |
Modifier and Type | Method and Description |
---|---|
protected abstract FlinkKafkaConsumerBase<Row> |
createKafkaConsumer(String topic,
Properties properties,
DeserializationSchema<Row> deserializationSchema)
Creates a version-specific Kafka consumer.
|
boolean |
equals(Object o) |
String |
explainSource() |
DataStream<Row> |
getDataStream(StreamExecutionEnvironment env)
NOTE: This method is for internal use only for defining a TableSource.
|
protected abstract DeserializationSchema<Row> |
getDeserializationSchema()
Returns the deserialization schema.
|
protected FlinkKafkaConsumerBase<Row> |
getKafkaConsumer(String topic,
Properties properties,
DeserializationSchema<Row> deserializationSchema)
Returns a version-specific Kafka consumer with the start position configured.
|
String |
getProctimeAttribute() |
TypeInformation<Row> |
getReturnType() |
List<org.apache.flink.table.sources.RowtimeAttributeDescriptor> |
getRowtimeAttributeDescriptors() |
org.apache.flink.table.api.TableSchema |
getTableSchema() |
int |
hashCode() |
protected void |
setProctimeAttribute(String proctimeAttribute)
Declares a field of the schema to be the processing time attribute.
|
protected void |
setRowtimeAttributeDescriptors(List<org.apache.flink.table.sources.RowtimeAttributeDescriptor> rowtimeAttributeDescriptors)
Declares a list of fields to be rowtime attributes.
|
protected void |
setSpecificStartupOffsets(Map<KafkaTopicPartition,Long> specificStartupOffsets)
Sets the startup offsets of the TableSource; only relevant when the startup mode is
StartupMode.SPECIFIC_OFFSETS . |
protected void |
setStartupMode(StartupMode startupMode)
Sets the startup mode of the TableSource.
|
protected KafkaTableSource(String topic, Properties properties, org.apache.flink.table.api.TableSchema schema, TypeInformation<Row> returnType)
StreamTableSource
.topic
- Kafka topic to consume.properties
- Properties for the Kafka consumer.schema
- Schema of the produced table.returnType
- Type information of the produced physical DataStream.public DataStream<Row> getDataStream(StreamExecutionEnvironment env)
getDataStream
in interface org.apache.flink.table.sources.StreamTableSource<Row>
public TypeInformation<Row> getReturnType()
getReturnType
in interface org.apache.flink.table.sources.TableSource<Row>
public org.apache.flink.table.api.TableSchema getTableSchema()
getTableSchema
in interface org.apache.flink.table.sources.TableSource<Row>
public String getProctimeAttribute()
getProctimeAttribute
in interface org.apache.flink.table.sources.DefinedProctimeAttribute
public List<org.apache.flink.table.sources.RowtimeAttributeDescriptor> getRowtimeAttributeDescriptors()
getRowtimeAttributeDescriptors
in interface org.apache.flink.table.sources.DefinedRowtimeAttributes
public String explainSource()
explainSource
in interface org.apache.flink.table.sources.TableSource<Row>
protected FlinkKafkaConsumerBase<Row> getKafkaConsumer(String topic, Properties properties, DeserializationSchema<Row> deserializationSchema)
topic
- Kafka topic to consume.properties
- Properties for the Kafka consumer.deserializationSchema
- Deserialization schema to use for Kafka records.protected void setProctimeAttribute(String proctimeAttribute)
proctimeAttribute
- The name of the field that becomes the processing time field.protected void setRowtimeAttributeDescriptors(List<org.apache.flink.table.sources.RowtimeAttributeDescriptor> rowtimeAttributeDescriptors)
rowtimeAttributeDescriptors
- The descriptors of the rowtime attributes.protected void setStartupMode(StartupMode startupMode)
startupMode
- The startup mode.protected void setSpecificStartupOffsets(Map<KafkaTopicPartition,Long> specificStartupOffsets)
StartupMode.SPECIFIC_OFFSETS
.specificStartupOffsets
- The startup offsets for different partitions.protected abstract FlinkKafkaConsumerBase<Row> createKafkaConsumer(String topic, Properties properties, DeserializationSchema<Row> deserializationSchema)
topic
- Kafka topic to consume.properties
- Properties for the Kafka consumer.deserializationSchema
- Deserialization schema to use for Kafka records.protected abstract DeserializationSchema<Row> getDeserializationSchema()
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.