@PublicEvolving public final class FactoryUtil extends Object
Factory
s.Modifier and Type | Class and Description |
---|---|
static class |
FactoryUtil.TableFactoryHelper
Helper utility for discovering formats and validating all options for a
DynamicTableFactory . |
Modifier and Type | Field and Description |
---|---|
static ConfigOption<String> |
CONNECTOR |
static ConfigOption<String> |
FORMAT |
static ConfigOption<String> |
KEY_FORMAT |
static ConfigOption<Integer> |
PROPERTY_VERSION |
static ConfigOption<String> |
VALUE_FORMAT |
Modifier and Type | Method and Description |
---|---|
static FactoryUtil.TableFactoryHelper |
createTableFactoryHelper(DynamicTableFactory factory,
DynamicTableFactory.Context context)
Creates a utility that helps in discovering formats and validating all options for a
DynamicTableFactory . |
static DynamicTableSink |
createTableSink(Catalog catalog,
ObjectIdentifier objectIdentifier,
CatalogTable catalogTable,
ReadableConfig configuration,
ClassLoader classLoader)
Creates a
DynamicTableSink from a CatalogTable . |
static DynamicTableSource |
createTableSource(Catalog catalog,
ObjectIdentifier objectIdentifier,
CatalogTable catalogTable,
ReadableConfig configuration,
ClassLoader classLoader)
Creates a
DynamicTableSource from a CatalogTable . |
static <T extends Factory> |
discoverFactory(ClassLoader classLoader,
Class<T> factoryClass,
String factoryIdentifier)
Discovers a factory using the given factory base class and identifier.
|
static void |
validateFactoryOptions(Factory factory,
ReadableConfig options)
Validates the required and optional
ConfigOption s of a factory. |
public static final ConfigOption<Integer> PROPERTY_VERSION
public static final ConfigOption<String> CONNECTOR
public static final ConfigOption<String> KEY_FORMAT
public static final ConfigOption<String> VALUE_FORMAT
public static final ConfigOption<String> FORMAT
public static DynamicTableSource createTableSource(@Nullable Catalog catalog, ObjectIdentifier objectIdentifier, CatalogTable catalogTable, ReadableConfig configuration, ClassLoader classLoader)
public static DynamicTableSink createTableSink(@Nullable Catalog catalog, ObjectIdentifier objectIdentifier, CatalogTable catalogTable, ReadableConfig configuration, ClassLoader classLoader)
public static FactoryUtil.TableFactoryHelper createTableFactoryHelper(DynamicTableFactory factory, DynamicTableFactory.Context context)
DynamicTableFactory
.
The following example sketches the usage:
// in createDynamicTableSource()
helper = FactoryUtil.createTableFactoryHelper(this, context);
keyFormat = helper.discoverScanFormat(DeserializationFormatFactory.class, KEY_FORMAT);
valueFormat = helper.discoverScanFormat(DeserializationFormatFactory.class, VALUE_FORMAT);
helper.validate();
... // construct connector with discovered formats
Note: The format option parameter of helper.discoverScanFormat(formatFactoryClass,
formatOption)
and helper.discoverSinkFormat(formatFactoryClass, formatOption)
must
be 'format' or with '.format' suffix (e.g. FORMAT
, KEY_FORMAT
and VALUE_FORMAT
). The discovery logic will replace 'format' with the factory identifier value
as the format prefix. For example, assuming the identifier is 'json', if format option key is
'format', then format prefix is 'json.'. If format option key is 'value.format', then format
prefix is 'value.json'. The format prefix is used to project the options for the format
factory.
Note: This utility checks for left-over options in the final step.
public static <T extends Factory> T discoverFactory(ClassLoader classLoader, Class<T> factoryClass, String factoryIdentifier)
This method is meant for cases where createTableFactoryHelper(DynamicTableFactory,
DynamicTableFactory.Context)
createTableSource(Catalog, ObjectIdentifier,
CatalogTable, ReadableConfig, ClassLoader)
, and createTableSink(Catalog,
ObjectIdentifier, CatalogTable, ReadableConfig, ClassLoader)
are not applicable.
public static void validateFactoryOptions(Factory factory, ReadableConfig options)
ConfigOption
s of a factory.
Note: It does not check for left-over options.
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.