@PublicEvolving public final class FactoryUtil extends Object
Factory
s.Modifier and Type | Class and Description |
---|---|
static class |
FactoryUtil.CatalogFactoryHelper
Helper utility for catalog implementations to validate options provided by
CatalogFactory . |
static class |
FactoryUtil.DefaultCatalogContext
Default implementation of
CatalogFactory.Context . |
static class |
FactoryUtil.DefaultDynamicTableContext
Default implementation of
DynamicTableFactory.Context . |
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 String |
FORMAT_SUFFIX
Suffix for keys of
ConfigOption in case a connector requires multiple formats (e.g. |
static String |
PLACEHOLDER_SYMBOL
The placeholder symbol to be used for keys of options which can be templated.
|
static ConfigOption<Integer> |
PROPERTY_VERSION
Describes the property version.
|
static ConfigOption<Integer> |
SINK_PARALLELISM |
Modifier and Type | Method and Description |
---|---|
static Catalog |
createCatalog(String catalogName,
Map<String,String> options,
ReadableConfig configuration,
ClassLoader classLoader)
Attempts to discover an appropriate catalog factory and creates an instance of the catalog.
|
static FactoryUtil.CatalogFactoryHelper |
createCatalogFactoryHelper(CatalogFactory factory,
CatalogFactory.Context context)
Creates a utility that helps validating options for a
CatalogFactory . |
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,
ResolvedCatalogTable catalogTable,
ReadableConfig configuration,
ClassLoader classLoader,
boolean isTemporary)
Creates a
DynamicTableSink from a CatalogTable . |
static DynamicTableSource |
createTableSource(Catalog catalog,
ObjectIdentifier objectIdentifier,
ResolvedCatalogTable catalogTable,
ReadableConfig configuration,
ClassLoader classLoader,
boolean isTemporary)
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. |
static void |
validateFactoryOptions(Set<ConfigOption<?>> requiredOptions,
Set<ConfigOption<?>> optionalOptions,
ReadableConfig options)
Validates the required options and optional options.
|
static void |
validateUnconsumedKeys(String factoryIdentifier,
Set<String> allOptionKeys,
Set<String> consumedOptionKeys)
Validates unconsumed option keys.
|
public static final ConfigOption<Integer> PROPERTY_VERSION
public static final ConfigOption<String> CONNECTOR
public static final ConfigOption<String> FORMAT
public static final ConfigOption<Integer> SINK_PARALLELISM
public static final String FORMAT_SUFFIX
ConfigOption
in case a connector requires multiple formats (e.g.
for both key and value).
See createTableFactoryHelper(DynamicTableFactory, DynamicTableFactory.Context)
for more information.
public static final String PLACEHOLDER_SYMBOL
Factory
for details.public static DynamicTableSource createTableSource(@Nullable Catalog catalog, ObjectIdentifier objectIdentifier, ResolvedCatalogTable catalogTable, ReadableConfig configuration, ClassLoader classLoader, boolean isTemporary)
public static DynamicTableSink createTableSink(@Nullable Catalog catalog, ObjectIdentifier objectIdentifier, ResolvedCatalogTable catalogTable, ReadableConfig configuration, ClassLoader classLoader, boolean isTemporary)
public static FactoryUtil.CatalogFactoryHelper createCatalogFactoryHelper(CatalogFactory factory, CatalogFactory.Context context)
CatalogFactory
.
Note: This utility checks for left-over options in the final step.
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.discoverDecodingFormat(DeserializationFormatFactory.class, KEY_FORMAT);
valueFormat = helper.discoverDecodingFormat(DeserializationFormatFactory.class, VALUE_FORMAT);
helper.validate();
... // construct connector with discovered formats
Note: The format option parameter of FactoryUtil.TableFactoryHelper.discoverEncodingFormat(Class, ConfigOption)
and FactoryUtil.TableFactoryHelper.discoverDecodingFormat(Class, ConfigOption)
must be FORMAT
or
end with FORMAT_SUFFIX
. The discovery logic will replace 'format' with the factory
identifier value as the format prefix. For example, assuming the identifier is 'json', if the
format option key is 'format', then the format prefix is 'json.'. If the format option key is
'value.format', then the 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 Catalog createCatalog(String catalogName, Map<String,String> options, ReadableConfig configuration, ClassLoader classLoader)
This first uses the legacy TableFactory
stack to discover a matching CatalogFactory
. If none is found, it falls back to the new stack using Factory
instead.
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,
ResolvedCatalogTable, ReadableConfig, ClassLoader, boolean)
, and createTableSink(Catalog, ObjectIdentifier, ResolvedCatalogTable, ReadableConfig,
ClassLoader, boolean)
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.
public static void validateFactoryOptions(Set<ConfigOption<?>> requiredOptions, Set<ConfigOption<?>> optionalOptions, ReadableConfig options)
Note: It does not check for left-over options.
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.