Search in sources :

Example 6 with TableFactoryHelper

use of org.apache.flink.table.factories.FactoryUtil.TableFactoryHelper in project flink by apache.

the class HBase2DynamicTableFactory method createDynamicTableSink.

@Override
public DynamicTableSink createDynamicTableSink(Context context) {
    TableFactoryHelper helper = createTableFactoryHelper(this, context);
    helper.validateExcept(PROPERTIES_PREFIX);
    final ReadableConfig tableOptions = helper.getOptions();
    validatePrimaryKey(context.getPhysicalRowDataType(), context.getPrimaryKeyIndexes());
    String tableName = tableOptions.get(TABLE_NAME);
    Configuration hbaseConf = getHBaseConfiguration(tableOptions);
    HBaseWriteOptions hBaseWriteOptions = getHBaseWriteOptions(tableOptions);
    String nullStringLiteral = tableOptions.get(NULL_STRING_LITERAL);
    HBaseTableSchema hbaseSchema = HBaseTableSchema.fromDataType(context.getPhysicalRowDataType());
    return new HBaseDynamicTableSink(tableName, hbaseSchema, hbaseConf, hBaseWriteOptions, nullStringLiteral);
}
Also used : ReadableConfig(org.apache.flink.configuration.ReadableConfig) Configuration(org.apache.hadoop.conf.Configuration) HBaseConnectorOptionsUtil.getHBaseConfiguration(org.apache.flink.connector.hbase.table.HBaseConnectorOptionsUtil.getHBaseConfiguration) TableFactoryHelper(org.apache.flink.table.factories.FactoryUtil.TableFactoryHelper) FactoryUtil.createTableFactoryHelper(org.apache.flink.table.factories.FactoryUtil.createTableFactoryHelper) HBaseTableSchema(org.apache.flink.connector.hbase.util.HBaseTableSchema) HBaseDynamicTableSink(org.apache.flink.connector.hbase2.sink.HBaseDynamicTableSink) HBaseWriteOptions(org.apache.flink.connector.hbase.options.HBaseWriteOptions) HBaseConnectorOptionsUtil.getHBaseWriteOptions(org.apache.flink.connector.hbase.table.HBaseConnectorOptionsUtil.getHBaseWriteOptions)

Example 7 with TableFactoryHelper

use of org.apache.flink.table.factories.FactoryUtil.TableFactoryHelper in project flink by apache.

the class TestDynamicTableFactory method createDynamicTableSource.

@Override
public DynamicTableSource createDynamicTableSource(Context context) {
    final TableFactoryHelper helper = FactoryUtil.createTableFactoryHelper(this, context);
    final Optional<DecodingFormat<DeserializationSchema<RowData>>> keyFormat = helper.discoverOptionalDecodingFormat(DeserializationFormatFactory.class, KEY_FORMAT);
    final DecodingFormat<DeserializationSchema<RowData>> valueFormat = helper.discoverOptionalDecodingFormat(DeserializationFormatFactory.class, FORMAT).orElseGet(() -> helper.discoverDecodingFormat(DeserializationFormatFactory.class, VALUE_FORMAT));
    helper.validate();
    return new DynamicTableSourceMock(helper.getOptions().get(TARGET), helper.getOptions().getOptional(PASSWORD).orElse(null), keyFormat.orElse(null), valueFormat);
}
Also used : RowData(org.apache.flink.table.data.RowData) DecodingFormat(org.apache.flink.table.connector.format.DecodingFormat) TableFactoryHelper(org.apache.flink.table.factories.FactoryUtil.TableFactoryHelper) DeserializationSchema(org.apache.flink.api.common.serialization.DeserializationSchema)

Example 8 with TableFactoryHelper

use of org.apache.flink.table.factories.FactoryUtil.TableFactoryHelper in project flink by apache.

the class TestDynamicTableFactory method createDynamicTableSink.

@Override
public DynamicTableSink createDynamicTableSink(Context context) {
    final TableFactoryHelper helper = FactoryUtil.createTableFactoryHelper(this, context);
    final Optional<EncodingFormat<SerializationSchema<RowData>>> keyFormat = helper.discoverOptionalEncodingFormat(SerializationFormatFactory.class, KEY_FORMAT);
    final EncodingFormat<SerializationSchema<RowData>> valueFormat = helper.discoverOptionalEncodingFormat(SerializationFormatFactory.class, FORMAT).orElseGet(() -> helper.discoverEncodingFormat(SerializationFormatFactory.class, VALUE_FORMAT));
    helper.validate();
    return new DynamicTableSinkMock(helper.getOptions().get(TARGET), helper.getOptions().get(BUFFER_SIZE), keyFormat.orElse(null), valueFormat);
}
Also used : EncodingFormat(org.apache.flink.table.connector.format.EncodingFormat) RowData(org.apache.flink.table.data.RowData) SerializationSchema(org.apache.flink.api.common.serialization.SerializationSchema) TableFactoryHelper(org.apache.flink.table.factories.FactoryUtil.TableFactoryHelper)

Aggregations

TableFactoryHelper (org.apache.flink.table.factories.FactoryUtil.TableFactoryHelper)8 ReadableConfig (org.apache.flink.configuration.ReadableConfig)6 HBaseConnectorOptionsUtil.getHBaseConfiguration (org.apache.flink.connector.hbase.table.HBaseConnectorOptionsUtil.getHBaseConfiguration)4 HBaseTableSchema (org.apache.flink.connector.hbase.util.HBaseTableSchema)4 RowData (org.apache.flink.table.data.RowData)4 FactoryUtil.createTableFactoryHelper (org.apache.flink.table.factories.FactoryUtil.createTableFactoryHelper)4 Configuration (org.apache.hadoop.conf.Configuration)4 DeserializationSchema (org.apache.flink.api.common.serialization.DeserializationSchema)2 SerializationSchema (org.apache.flink.api.common.serialization.SerializationSchema)2 HBaseWriteOptions (org.apache.flink.connector.hbase.options.HBaseWriteOptions)2 HBaseConnectorOptionsUtil.getHBaseWriteOptions (org.apache.flink.connector.hbase.table.HBaseConnectorOptionsUtil.getHBaseWriteOptions)2 DecodingFormat (org.apache.flink.table.connector.format.DecodingFormat)2 EncodingFormat (org.apache.flink.table.connector.format.EncodingFormat)2 DataType (org.apache.flink.table.types.DataType)2 Duration (java.time.Duration)1 Properties (java.util.Properties)1 DeliveryGuarantee (org.apache.flink.connector.base.DeliveryGuarantee)1 HBaseLookupOptions (org.apache.flink.connector.hbase.options.HBaseLookupOptions)1 HBaseConnectorOptionsUtil.getHBaseLookupOptions (org.apache.flink.connector.hbase.table.HBaseConnectorOptionsUtil.getHBaseLookupOptions)1 HBaseDynamicTableSink (org.apache.flink.connector.hbase1.sink.HBaseDynamicTableSink)1