You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by lz...@apache.org on 2023/02/13 12:14:20 UTC
[flink-table-store] branch master updated: [FLINK-31023] Introduce ConfigOption for table store
This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-table-store.git
The following commit(s) were added to refs/heads/master by this push:
new 1796d3fa [FLINK-31023] Introduce ConfigOption for table store
1796d3fa is described below
commit 1796d3fa960169649299bb4bdaffac6d3848718e
Author: JingsongLi <lz...@aliyun.com>
AuthorDate: Sat Feb 11 21:47:59 2023 +0800
[FLINK-31023] Introduce ConfigOption for table store
This closes #524
---
.../shortcodes/generated/core_configuration.html | 24 +-
.../table/store/benchmark/config/ConfigUtil.java | 10 +-
.../benchmark/config/FileBenchmarkOptions.java | 4 +-
.../file/mergetree/MergeTreeBenchmark.java | 8 +-
.../ConfigGroup.java} | 16 +-
.../flink/table/store/annotation/ConfigGroups.java | 32 +-
.../table/store/annotation/Documentation.java | 90 +++++
.../flink/table/store/format/FileFormat.java | 16 +-
.../table/store/format/FileFormatFactory.java | 4 +-
.../flink/table/store/options/CatalogOptions.java | 4 +-
.../flink/table/store/options/ConfigOption.java | 296 +++++++++++++++
.../flink/table/store/options/ConfigOptions.java | 279 ++++++++++++++
.../flink/table/store/options/FallbackKey.java | 78 ++++
.../flink/table/store/options/MemorySize.java | 419 +++++++++++++++++++++
.../apache/flink/table/store/options/Options.java | 184 ++++++++-
.../flink/table/store/options/OptionsUtils.java | 358 ++++++++++++++++++
.../store/options/StructuredOptionsSplitter.java | 211 +++++++++++
.../description/BlockElement.java} | 15 +-
.../store/options/description/DescribedEnum.java | 42 +++
.../store/options/description/Description.java | 118 ++++++
.../description/DescriptionElement.java} | 20 +-
.../table/store/options/description/Formatter.java | 109 ++++++
.../store/options/description/HtmlFormatter.java | 72 ++++
.../description/InlineElement.java} | 15 +-
.../options/description/LineBreakElement.java | 22 +-
.../store/options/description/LinkElement.java | 64 ++++
.../store/options/description/ListElement.java | 58 +++
.../store/options/description/TextElement.java | 101 +++++
.../flink/table/store/plugin/PluginLoader.java | 5 +-
.../apache/flink/table/store/table/TableType.java | 6 +-
.../table/store/datagen/DataGenVisitorBase.java | 8 +-
.../store/datagen/DataGeneratorContainer.java | 2 +-
.../store/datagen/RandomGeneratorVisitor.java | 10 +-
.../flink/table/store/utils/RowDataUtilsTest.java | 4 +-
.../store/connector/AbstractTableStoreFactory.java | 12 +-
.../table/store/connector/FlinkCatalogFactory.java | 8 +-
.../store/connector/FlinkConnectorOptions.java | 20 +-
.../table/store/connector/RocksDBOptions.java | 20 +-
.../connector/TableStoreConnectorFactory.java | 4 +-
.../connector/lookup/FileStoreLookupFunction.java | 6 +-
.../connector/lookup/RocksDBStateFactory.java | 4 +-
.../table/store/connector/sink/TableStoreSink.java | 6 +-
.../store/connector/source/FlinkSourceBuilder.java | 6 +-
.../store/connector/source/TableStoreSource.java | 6 +-
.../flink/table/store/kafka/KafkaLogOptions.java | 4 +-
.../table/store/kafka/KafkaLogStoreFactory.java | 32 +-
.../table/store/log/LogStoreTableFactory.java | 30 +-
.../table/store/connector/ChangelogModeTest.java | 14 +-
.../store/connector/ForceCompactionITCase.java | 4 +-
.../store/connector/lookup/LookupTableTest.java | 4 +-
.../source/TestChangelogDataReadWrite.java | 4 +-
.../org/apache/flink/table/store/CoreOptions.java | 148 ++++----
.../apache/flink/table/store/file/WriteMode.java | 6 +-
.../compact/aggregate/AggregateMergeFunction.java | 12 +-
.../store/file/operation/FileStoreCommitImpl.java | 2 +-
.../store/file/sort/BinaryExternalSortBuffer.java | 2 +-
.../store/file/utils/FileStorePathFactory.java | 4 +-
.../table/store/table/AbstractFileStoreTable.java | 4 +-
.../table/ChangelogWithKeyFileStoreTable.java | 4 +-
.../table/store/table/FileStoreTableFactory.java | 3 +-
.../apache/flink/table/store/CoreOptionsTest.java | 12 +-
.../flink/table/store/file/FileFormatTest.java | 4 +-
.../flink/table/store/file/TestFileStore.java | 6 +-
.../store/file/append/AppendOnlyWriterTest.java | 4 +-
.../store/file/format/FileFormatSuffixTest.java | 4 +-
.../file/format/FileStatsExtractingAvroFormat.java | 4 +-
.../FileStatsExtractingAvroFormatFactory.java | 4 +-
.../store/file/format/FlushingFileFormat.java | 4 +-
.../table/store/file/io/RollingFileWriterTest.java | 4 +-
.../store/file/manifest/ManifestFileMetaTest.java | 4 +-
.../store/file/manifest/ManifestFileTest.java | 4 +-
.../store/file/manifest/ManifestListTest.java | 4 +-
.../table/store/file/mergetree/MergeTreeTest.java | 6 +-
.../store/table/SchemaEvolutionTableTestBase.java | 8 +-
.../table/store/table/WritePreemptMemoryTest.java | 2 +-
.../configuration/ConfigOptionsDocGenerator.java | 22 +-
.../docs/configuration/OptionsClassLocation.java | 2 +-
.../ConfigOptionsDocGeneratorTest.java | 22 +-
.../ConfigOptionsDocsCompletenessITCase.java | 4 +-
.../docs/configuration/data/TestCommonOptions.java | 6 +-
.../table/store/format/avro/AvroFileFormat.java | 15 +-
.../store/format/avro/AvroFileFormatFactory.java | 4 +-
.../table/store/format/orc/OrcFileFormat.java | 9 +-
.../store/format/orc/OrcFileFormatFactory.java | 8 +-
.../store/format/parquet/ParquetFileFormat.java | 12 +-
.../format/parquet/ParquetFileFormatFactory.java | 8 +-
.../store/format/parquet/ParquetReaderFactory.java | 8 +-
.../parquet/writer/RowDataParquetBuilder.java | 6 +-
.../table/store/format/BulkFileFormatTest.java | 4 +-
.../table/store/format/orc/OrcFileFormatTest.java | 6 +-
.../format/orc/OrcFileStatsExtractorTest.java | 4 +-
.../format/parquet/ParquetFileFormatTest.java | 19 +-
.../parquet/ParquetFileStatsExtractorTest.java | 4 +-
.../store/format/parquet/ParquetReadWriteTest.java | 10 +-
.../flink/table/store/hive/HiveCatalogFactory.java | 4 +-
95 files changed, 2868 insertions(+), 456 deletions(-)
diff --git a/docs/layouts/shortcodes/generated/core_configuration.html b/docs/layouts/shortcodes/generated/core_configuration.html
index 74c05951..88c895cc 100644
--- a/docs/layouts/shortcodes/generated/core_configuration.html
+++ b/docs/layouts/shortcodes/generated/core_configuration.html
@@ -86,18 +86,6 @@
<td>String</td>
<td>Specify the message format of data files.</td>
</tr>
- <tr>
- <td><h5>orc.bloom.filter.columns</h5></td>
- <td style="word-wrap: break-word;">(none)</td>
- <td>String</td>
- <td>A comma-separated list of columns for which to create a bloon filter when writing.</td>
- </tr>
- <tr>
- <td><h5>orc.bloom.filter.fpp</h5></td>
- <td style="word-wrap: break-word;">0.05</td>
- <td>Double</td>
- <td>Define the default false positive probability for bloom filters.</td>
- </tr>
<tr>
<td><h5>local-sort.max-num-file-handles</h5></td>
<td style="word-wrap: break-word;">128</td>
@@ -182,6 +170,18 @@
<td>Integer</td>
<td>The number of sorted runs that trigger the stopping of writes, the default value is 'num-sorted-run.compaction-trigger' + 1.</td>
</tr>
+ <tr>
+ <td><h5>orc.bloom.filter.columns</h5></td>
+ <td style="word-wrap: break-word;">(none)</td>
+ <td>String</td>
+ <td>A comma-separated list of columns for which to create a bloon filter when writing.</td>
+ </tr>
+ <tr>
+ <td><h5>orc.bloom.filter.fpp</h5></td>
+ <td style="word-wrap: break-word;">0.05</td>
+ <td>Double</td>
+ <td>Define the default false positive probability for bloom filters.</td>
+ </tr>
<tr>
<td><h5>page-size</h5></td>
<td style="word-wrap: break-word;">64 kb</td>
diff --git a/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/config/ConfigUtil.java b/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/config/ConfigUtil.java
index dec6b714..d29f322a 100644
--- a/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/config/ConfigUtil.java
+++ b/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/config/ConfigUtil.java
@@ -18,7 +18,7 @@
package org.apache.flink.table.store.benchmark.config;
-import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.store.options.Options;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,7 +40,7 @@ public class ConfigUtil {
private static final String BENCHMARK_CONF = "benchmark-conf.yaml";
/** Load benchmark conf from classpath. */
- public static Configuration loadBenchMarkConf() {
+ public static Options loadBenchMarkConf() {
InputStream inputStream =
ConfigUtil.class.getClassLoader().getResourceAsStream(BENCHMARK_CONF);
return loadYAMLResource(inputStream);
@@ -50,8 +50,8 @@ public class ConfigUtil {
* This is copied from {@code GlobalConfiguration#loadYAMLResource} to avoid depending
* on @Internal api.
*/
- private static Configuration loadYAMLResource(InputStream inputStream) {
- final Configuration config = new Configuration();
+ private static Options loadYAMLResource(InputStream inputStream) {
+ final Options config = new Options();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
@@ -111,7 +111,7 @@ public class ConfigUtil {
* @param configuration the configuration
* @return the file data dir
*/
- public static String createFileDataDir(Configuration configuration) {
+ public static String createFileDataDir(Options configuration) {
return configuration.get(FileBenchmarkOptions.FILE_DATA_BASE_DIR)
+ "/"
+ UUID.randomUUID().toString();
diff --git a/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/config/FileBenchmarkOptions.java b/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/config/FileBenchmarkOptions.java
index d27bd8b9..a41d76a7 100644
--- a/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/config/FileBenchmarkOptions.java
+++ b/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/config/FileBenchmarkOptions.java
@@ -18,9 +18,9 @@
package org.apache.flink.table.store.benchmark.config;
-import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOption;
-import static org.apache.flink.configuration.ConfigOptions.key;
+import static org.apache.flink.table.store.options.ConfigOptions.key;
/** Benchmark options for file. */
public class FileBenchmarkOptions {
diff --git a/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/file/mergetree/MergeTreeBenchmark.java b/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/file/mergetree/MergeTreeBenchmark.java
index 80b9f218..b8d6ae87 100644
--- a/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/file/mergetree/MergeTreeBenchmark.java
+++ b/flink-table-store-benchmark/flink-table-store-micro-benchmarks/src/main/java/org/apache/flink/table/store/benchmark/file/mergetree/MergeTreeBenchmark.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.benchmark.file.mergetree;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.benchmark.config.ConfigUtil;
import org.apache.flink.table.store.benchmark.config.FileBenchmarkOptions;
@@ -50,6 +49,7 @@ import org.apache.flink.table.store.file.utils.RecordWriter;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.DataField;
import org.apache.flink.table.store.types.IntType;
import org.apache.flink.table.store.types.RowKind;
@@ -117,7 +117,7 @@ public class MergeTreeBenchmark {
protected long sequenceNumber = 0;
protected void createRecordWriter() {
- Configuration configuration = ConfigUtil.loadBenchMarkConf();
+ Options configuration = ConfigUtil.loadBenchMarkConf();
batchCount = configuration.get(FileBenchmarkOptions.WRITER_BATCH_COUNT);
countPerBatch = configuration.get(FileBenchmarkOptions.WRITER_RECORD_COUNT_PER_BATCH);
service = Executors.newSingleThreadExecutor();
@@ -133,11 +133,11 @@ public class MergeTreeBenchmark {
}
private RecordWriter<KeyValue> recreateMergeTree(
- Configuration configuration, Path path, FileStorePathFactory pathFactory) {
+ Options configuration, Path path, FileStorePathFactory pathFactory) {
options = new CoreOptions(configuration);
RowType keyType = new RowType(singletonList(new DataField(0, "k", new IntType())));
RowType valueType = new RowType(singletonList(new DataField(1, "v", new IntType())));
- FileFormat flushingFormat = FileFormat.fromIdentifier(format, new Configuration());
+ FileFormat flushingFormat = FileFormat.fromIdentifier(format, new Options());
KeyValueFileReaderFactory.Builder readerBuilder =
KeyValueFileReaderFactory.builder(
LocalFileIO.create(),
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/annotation/ConfigGroup.java
similarity index 71%
copy from flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
copy to flink-table-store-common/src/main/java/org/apache/flink/table/store/annotation/ConfigGroup.java
index f0ff0c01..147b6cd3 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/annotation/ConfigGroup.java
@@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,14 +16,14 @@
* limitations under the License.
*/
-package org.apache.flink.table.store.format;
+package org.apache.flink.table.store.annotation;
-import org.apache.flink.configuration.Configuration;
+import java.lang.annotation.Target;
-/** Factory to create {@link FileFormat}. */
-public interface FileFormatFactory {
+/** A class that specifies a group of config options. */
+@Target({})
+public @interface ConfigGroup {
+ String name();
- String identifier();
-
- FileFormat create(Configuration formatOptions);
+ String keyPrefix();
}
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormatFactory.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/annotation/ConfigGroups.java
similarity index 50%
copy from flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormatFactory.java
copy to flink-table-store-common/src/main/java/org/apache/flink/table/store/annotation/ConfigGroups.java
index ee89402a..0fc6f73c 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormatFactory.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/annotation/ConfigGroups.java
@@ -16,22 +16,22 @@
* limitations under the License.
*/
-package org.apache.flink.table.store.file.format;
+package org.apache.flink.table.store.annotation;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.table.store.format.FileFormat;
-import org.apache.flink.table.store.format.FileFormatFactory;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
-/** Factory to create {@link FileStatsExtractingAvroFormat}. */
-public class FileStatsExtractingAvroFormatFactory implements FileFormatFactory {
-
- @Override
- public String identifier() {
- return "avro-extract";
- }
-
- @Override
- public FileFormat create(Configuration formatOptions) {
- return new FileStatsExtractingAvroFormat();
- }
+/**
+ * Annotation used on classes containing config options that enables the separation of options into
+ * different tables based on key prefixes. A config option is assigned to a {@link ConfigGroup} if
+ * the option key matches the group prefix. If a key matches multiple prefixes the longest matching
+ * prefix takes priority. An option is never assigned to multiple groups. Options that don't match
+ * any group are implicitly added to a default group.
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ConfigGroups {
+ ConfigGroup[] groups() default {};
}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/annotation/Documentation.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/annotation/Documentation.java
new file mode 100644
index 00000000..b02cbf63
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/annotation/Documentation.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.annotation;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.store.options.ConfigOption;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/** Collection of annotations to modify the behavior of the documentation generators. */
+public final class Documentation {
+
+ /** Annotation used on config option fields to override the documented default. */
+ @Target(ElementType.FIELD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @Internal
+ public @interface OverrideDefault {
+ String value();
+ }
+
+ /** Annotation used on {@link ConfigOption} fields to exclude it from schema change. */
+ @Target(ElementType.FIELD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Immutable {}
+
+ /**
+ * Annotation used on config option fields or REST API message headers to exclude it from
+ * documentation.
+ */
+ @Target({ElementType.FIELD, ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface ExcludeFromDocumentation {
+ /** The optional reason why it is excluded from documentation. */
+ String value() default "";
+ }
+
+ /**
+ * Annotation used on config option fields to include them in specific sections. Sections are
+ * groups of options that are aggregated across option classes, with each group being placed
+ * into a dedicated file.
+ *
+ * <p>The {@link Documentation.Section#position()} argument controls the position in the
+ * generated table, with lower values being placed at the top. Fields with the same position are
+ * sorted alphabetically by key.
+ */
+ @Target(ElementType.FIELD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @Internal
+ public @interface Section {
+
+ /** The sections in the config docs where this option should be included. */
+ String[] value() default {};
+
+ /** The relative position of the option in its section. */
+ int position() default Integer.MAX_VALUE;
+ }
+
+ /**
+ * Annotation used on config option fields or options class to mark them as a suffix-option;
+ * i.e., a config option where the key is only a suffix, with the prefix being dynamically
+ * provided at runtime.
+ */
+ @Target({ElementType.FIELD, ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ @Internal
+ public @interface SuffixOption {
+ String value();
+ }
+
+ private Documentation() {}
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormat.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormat.java
index dee199e0..e0a8045d 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormat.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormat.java
@@ -18,10 +18,9 @@
package org.apache.flink.table.store.format;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.DelegatingConfiguration;
import org.apache.flink.table.store.file.predicate.Predicate;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.RowType;
import javax.annotation.Nullable;
@@ -52,7 +51,6 @@ public abstract class FileFormat {
* Create a {@link FormatReaderFactory} from the type, with projection pushed down.
*
* @param type Type without projection.
- * @param projection See {@link org.apache.flink.table.connector.Projection#toNestedIndexes()}.
* @param filters A list of filters in conjunctive form for filtering on a best-effort basis.
*/
public abstract FormatReaderFactory createReaderFactory(
@@ -79,15 +77,13 @@ public abstract class FileFormat {
/** Create a {@link FileFormat} from table options. */
public static FileFormat fromTableOptions(
- Configuration tableOptions, ConfigOption<String> formatOption) {
+ Options tableOptions, ConfigOption<String> formatOption) {
String formatIdentifier = tableOptions.get(formatOption);
- DelegatingConfiguration formatOptions =
- new DelegatingConfiguration(tableOptions, formatIdentifier + ".");
- return fromIdentifier(formatIdentifier, formatOptions);
+ return fromIdentifier(formatIdentifier, tableOptions.removePrefix(formatIdentifier + "."));
}
/** Create a {@link FileFormat} from format identifier and format options. */
- public static FileFormat fromIdentifier(String identifier, Configuration options) {
+ public static FileFormat fromIdentifier(String identifier, Options options) {
Optional<FileFormat> format =
fromIdentifier(identifier, options, Thread.currentThread().getContextClassLoader());
return format.orElseGet(
@@ -103,7 +99,7 @@ public abstract class FileFormat {
}
private static Optional<FileFormat> fromIdentifier(
- String formatIdentifier, Configuration formatOptions, ClassLoader classLoader) {
+ String formatIdentifier, Options formatOptions, ClassLoader classLoader) {
ServiceLoader<FileFormatFactory> serviceLoader =
ServiceLoader.load(FileFormatFactory.class, classLoader);
for (FileFormatFactory factory : serviceLoader) {
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
index f0ff0c01..10bcf60f 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
@@ -18,12 +18,12 @@
package org.apache.flink.table.store.format;
-import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.store.options.Options;
/** Factory to create {@link FileFormat}. */
public interface FileFormatFactory {
String identifier();
- FileFormat create(Configuration formatOptions);
+ FileFormat create(Options formatOptions);
}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/CatalogOptions.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/CatalogOptions.java
index e9480a31..cd4150c7 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/CatalogOptions.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/CatalogOptions.java
@@ -18,8 +18,6 @@
package org.apache.flink.table.store.options;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.FileIOLoader;
import org.apache.flink.table.store.fs.hadoop.HadoopFileIOLoader;
@@ -33,7 +31,7 @@ import java.time.Duration;
import java.util.Map;
import java.util.Set;
-import static org.apache.flink.configuration.ConfigOptions.key;
+import static org.apache.flink.table.store.options.ConfigOptions.key;
/** Configuration for {@link FileIO}. */
public class CatalogOptions {
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/ConfigOption.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/ConfigOption.java
new file mode 100644
index 00000000..7c97355f
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/ConfigOption.java
@@ -0,0 +1,296 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options;
+
+import org.apache.flink.table.store.options.description.Description;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * A {@code ConfigOption} describes a configuration parameter. It encapsulates the configuration
+ * key, deprecated older versions of the key, and an optional default value for the configuration
+ * parameter.
+ *
+ * <p>{@code ConfigOptions} are built via the {@link ConfigOptions} class. Once created, a config
+ * option is immutable.
+ *
+ * @param <T> The type of value associated with the configuration option.
+ */
+public class ConfigOption<T> {
+
+ private static final FallbackKey[] EMPTY = new FallbackKey[0];
+
+ static final Description EMPTY_DESCRIPTION = Description.builder().text("").build();
+
+ // ------------------------------------------------------------------------
+
+ /** The current key for that config option. */
+ private final String key;
+
+ /** The list of deprecated keys, in the order to be checked. */
+ private final FallbackKey[] fallbackKeys;
+
+ /** The default value for this option. */
+ private final T defaultValue;
+
+ /** The description for this option. */
+ private final Description description;
+
+ /**
+ * Type of the value that this ConfigOption describes.
+ *
+ * <ul>
+ * <li>typeClass == atomic class (e.g. {@code Integer.class}) -> {@code ConfigOption<Integer>}
+ * <li>typeClass == {@code Map.class} -> {@code ConfigOption<Map<String, String>>}
+ * <li>typeClass == atomic class and isList == true for {@code ConfigOption<List<Integer>>}
+ * </ul>
+ */
+ private final Class<?> clazz;
+
+ private final boolean isList;
+
+ // ------------------------------------------------------------------------
+
+ Class<?> getClazz() {
+ return clazz;
+ }
+
+ boolean isList() {
+ return isList;
+ }
+
+ /**
+ * Creates a new config option with fallback keys.
+ *
+ * @param key The current key for that config option
+ * @param clazz describes type of the ConfigOption, see description of the clazz field
+ * @param description Description for that option
+ * @param defaultValue The default value for this option
+ * @param isList tells if the ConfigOption describes a list option, see description of the clazz
+ * field
+ * @param fallbackKeys The list of fallback keys, in the order to be checked
+ */
+ ConfigOption(
+ String key,
+ Class<?> clazz,
+ Description description,
+ T defaultValue,
+ boolean isList,
+ FallbackKey... fallbackKeys) {
+ this.key = checkNotNull(key);
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.fallbackKeys = fallbackKeys == null || fallbackKeys.length == 0 ? EMPTY : fallbackKeys;
+ this.clazz = checkNotNull(clazz);
+ this.isList = isList;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Creates a new config option, using this option's key and default value, and adding the given
+ * fallback keys.
+ *
+ * <p>When obtaining a value from the configuration via {@link Options#get(ConfigOption)}, the
+ * fallback keys will be checked in the order provided to this method. The first key for which a
+ * value is found will be used - that value will be returned.
+ *
+ * @param fallbackKeys The fallback keys, in the order in which they should be checked.
+ * @return A new config options, with the given fallback keys.
+ */
+ public ConfigOption<T> withFallbackKeys(String... fallbackKeys) {
+ final Stream<FallbackKey> newFallbackKeys =
+ Arrays.stream(fallbackKeys).map(FallbackKey::createFallbackKey);
+ final Stream<FallbackKey> currentAlternativeKeys = Arrays.stream(this.fallbackKeys);
+
+ // put fallback keys first so that they are prioritized
+ final FallbackKey[] mergedAlternativeKeys =
+ Stream.concat(newFallbackKeys, currentAlternativeKeys).toArray(FallbackKey[]::new);
+ return new ConfigOption<>(
+ key, clazz, description, defaultValue, isList, mergedAlternativeKeys);
+ }
+
+ /**
+ * Creates a new config option, using this option's key and default value, and adding the given
+ * deprecated keys.
+ *
+ * <p>When obtaining a value from the configuration via {@link Options#get(ConfigOption)}, the
+ * deprecated keys will be checked in the order provided to this method. The first key for which
+ * a value is found will be used - that value will be returned.
+ *
+ * @param deprecatedKeys The deprecated keys, in the order in which they should be checked.
+ * @return A new config options, with the given deprecated keys.
+ */
+ public ConfigOption<T> withDeprecatedKeys(String... deprecatedKeys) {
+ final Stream<FallbackKey> newDeprecatedKeys =
+ Arrays.stream(deprecatedKeys).map(FallbackKey::createDeprecatedKey);
+ final Stream<FallbackKey> currentAlternativeKeys = Arrays.stream(this.fallbackKeys);
+
+ // put deprecated keys last so that they are de-prioritized
+ final FallbackKey[] mergedAlternativeKeys =
+ Stream.concat(currentAlternativeKeys, newDeprecatedKeys)
+ .toArray(FallbackKey[]::new);
+ return new ConfigOption<>(
+ key, clazz, description, defaultValue, isList, mergedAlternativeKeys);
+ }
+
+ /**
+ * Creates a new config option, using this option's key and default value, and adding the given
+ * description. The given description is used when generation the configuration documentation.
+ *
+ * @param description The description for this option.
+ * @return A new config option, with given description.
+ */
+ public ConfigOption<T> withDescription(final String description) {
+ return withDescription(Description.builder().text(description).build());
+ }
+
+ /**
+ * Creates a new config option, using this option's key and default value, and adding the given
+ * description. The given description is used when generation the configuration documentation.
+ *
+ * @param description The description for this option.
+ * @return A new config option, with given description.
+ */
+ public ConfigOption<T> withDescription(final Description description) {
+ return new ConfigOption<>(key, clazz, description, defaultValue, isList, fallbackKeys);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Gets the configuration key.
+ *
+ * @return The configuration key
+ */
+ public String key() {
+ return key;
+ }
+
+ /**
+ * Checks if this option has a default value.
+ *
+ * @return True if it has a default value, false if not.
+ */
+ public boolean hasDefaultValue() {
+ return defaultValue != null;
+ }
+
+ /**
+ * Returns the default value, or null, if there is no default value.
+ *
+ * @return The default value, or null.
+ */
+ public T defaultValue() {
+ return defaultValue;
+ }
+
+ /**
+ * Checks whether this option has deprecated keys.
+ *
+ * @return True if the option has deprecated keys, false if not.
+ * @deprecated Replaced by {@link #hasFallbackKeys()}
+ */
+ @Deprecated
+ public boolean hasDeprecatedKeys() {
+ return fallbackKeys != EMPTY
+ && Arrays.stream(fallbackKeys).anyMatch(FallbackKey::isDeprecated);
+ }
+
+ /**
+ * Gets the deprecated keys, in the order to be checked.
+ *
+ * @return The option's deprecated keys.
+ * @deprecated Replaced by {@link #fallbackKeys()}
+ */
+ @Deprecated
+ public Iterable<String> deprecatedKeys() {
+ return fallbackKeys == EMPTY
+ ? Collections.emptyList()
+ : Arrays.stream(fallbackKeys)
+ .filter(FallbackKey::isDeprecated)
+ .map(FallbackKey::getKey)
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Checks whether this option has fallback keys.
+ *
+ * @return True if the option has fallback keys, false if not.
+ */
+ public boolean hasFallbackKeys() {
+ return fallbackKeys != EMPTY;
+ }
+
+ /**
+ * Gets the fallback keys, in the order to be checked.
+ *
+ * @return The option's fallback keys.
+ */
+ public Iterable<FallbackKey> fallbackKeys() {
+ return (fallbackKeys == EMPTY) ? Collections.emptyList() : Arrays.asList(fallbackKeys);
+ }
+
+ /**
+ * Returns the description of this option.
+ *
+ * @return The option's description.
+ */
+ public Description description() {
+ return description;
+ }
+
+ // ------------------------------------------------------------------------
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o != null && o.getClass() == ConfigOption.class) {
+ ConfigOption<?> that = (ConfigOption<?>) o;
+ return this.key.equals(that.key)
+ && Arrays.equals(this.fallbackKeys, that.fallbackKeys)
+ && (this.defaultValue == null
+ ? that.defaultValue == null
+ : (that.defaultValue != null
+ && this.defaultValue.equals(that.defaultValue)));
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * key.hashCode()
+ + 17 * Arrays.hashCode(fallbackKeys)
+ + (defaultValue != null ? defaultValue.hashCode() : 0);
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "Key: '%s' , default: %s (fallback keys: %s)",
+ key, defaultValue, Arrays.toString(fallbackKeys));
+ }
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/ConfigOptions.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/ConfigOptions.java
new file mode 100644
index 00000000..ba1ba1f0
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/ConfigOptions.java
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options;
+
+import org.apache.flink.table.store.options.description.Description;
+
+import java.time.Duration;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.flink.table.store.utils.Preconditions.checkNotNull;
+
+/**
+ * {@code ConfigOptions} are used to build a {@link ConfigOption}. The option is typically built in
+ * one of the following pattern:
+ *
+ * <pre>{@code
+ * // simple string-valued option with a default value
+ * ConfigOption<String> tempDirs = ConfigOptions
+ * .key("tmp.dir")
+ * .stringType()
+ * .defaultValue("/tmp");
+ *
+ * // simple integer-valued option with a default value
+ * ConfigOption<Integer> parallelism = ConfigOptions
+ * .key("application.parallelism")
+ * .intType()
+ * .defaultValue(100);
+ *
+ * // option of list of integers with a default value
+ * ConfigOption<Integer> parallelism = ConfigOptions
+ * .key("application.ports")
+ * .intType()
+ * .asList()
+ * .defaultValue(8000, 8001, 8002);
+ *
+ * // option with no default value
+ * ConfigOption<String> userName = ConfigOptions
+ * .key("user.name")
+ * .stringType()
+ * .noDefaultValue();
+ *
+ * // option with deprecated keys to check
+ * ConfigOption<Double> threshold = ConfigOptions
+ * .key("cpu.utilization.threshold")
+ * .doubleType()
+ * .defaultValue(0.9)
+ * .withDeprecatedKeys("cpu.threshold");
+ * }</pre>
+ */
+public class ConfigOptions {
+
+ /**
+ * Starts building a new {@link ConfigOption}.
+ *
+ * @param key The key for the config option.
+ * @return The builder for the config option with the given key.
+ */
+ public static OptionBuilder key(String key) {
+ checkNotNull(key);
+ return new OptionBuilder(key);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * The option builder is used to create a {@link ConfigOption}. It is instantiated via {@link
+ * ConfigOptions#key(String)}.
+ */
+ public static final class OptionBuilder {
+ /**
+ * Workaround to reuse the {@link TypedConfigOptionBuilder} for a {@link Map Map<String,
+ * String>}.
+ */
+ @SuppressWarnings("unchecked")
+ private static final Class<Map<String, String>> PROPERTIES_MAP_CLASS =
+ (Class<Map<String, String>>) (Class<?>) Map.class;
+
+ /** The key for the config option. */
+ private final String key;
+
+ /**
+ * Creates a new OptionBuilder.
+ *
+ * @param key The key for the config option
+ */
+ OptionBuilder(String key) {
+ this.key = key;
+ }
+
+ /** Defines that the value of the option should be of {@link Boolean} type. */
+ public TypedConfigOptionBuilder<Boolean> booleanType() {
+ return new TypedConfigOptionBuilder<>(key, Boolean.class);
+ }
+
+ /** Defines that the value of the option should be of {@link Integer} type. */
+ public TypedConfigOptionBuilder<Integer> intType() {
+ return new TypedConfigOptionBuilder<>(key, Integer.class);
+ }
+
+ /** Defines that the value of the option should be of {@link Long} type. */
+ public TypedConfigOptionBuilder<Long> longType() {
+ return new TypedConfigOptionBuilder<>(key, Long.class);
+ }
+
+ /** Defines that the value of the option should be of {@link Float} type. */
+ public TypedConfigOptionBuilder<Float> floatType() {
+ return new TypedConfigOptionBuilder<>(key, Float.class);
+ }
+
+ /** Defines that the value of the option should be of {@link Double} type. */
+ public TypedConfigOptionBuilder<Double> doubleType() {
+ return new TypedConfigOptionBuilder<>(key, Double.class);
+ }
+
+ /** Defines that the value of the option should be of {@link String} type. */
+ public TypedConfigOptionBuilder<String> stringType() {
+ return new TypedConfigOptionBuilder<>(key, String.class);
+ }
+
+ /** Defines that the value of the option should be of {@link Duration} type. */
+ public TypedConfigOptionBuilder<Duration> durationType() {
+ return new TypedConfigOptionBuilder<>(key, Duration.class);
+ }
+
+ /** Defines that the value of the option should be of {@link MemorySize} type. */
+ public TypedConfigOptionBuilder<MemorySize> memoryType() {
+ return new TypedConfigOptionBuilder<>(key, MemorySize.class);
+ }
+
+ /**
+ * Defines that the value of the option should be of {@link Enum} type.
+ *
+ * @param enumClass Concrete type of the expected enum.
+ */
+ public <T extends Enum<T>> TypedConfigOptionBuilder<T> enumType(Class<T> enumClass) {
+ return new TypedConfigOptionBuilder<>(key, enumClass);
+ }
+
+ /**
+ * Defines that the value of the option should be a set of properties, which can be
+ * represented as {@code Map<String, String>}.
+ */
+ public TypedConfigOptionBuilder<Map<String, String>> mapType() {
+ return new TypedConfigOptionBuilder<>(key, PROPERTIES_MAP_CLASS);
+ }
+
+ /**
+ * Creates a ConfigOption with the given default value.
+ *
+ * <p>This method does not accept "null". For options with no default value, choose one of
+ * the {@code noDefaultValue} methods.
+ *
+ * @param value The default value for the config option
+ * @param <T> The type of the default value.
+ * @return The config option with the default value.
+ * @deprecated define the type explicitly first with one of the intType(), stringType(),
+ * etc.
+ */
+ @Deprecated
+ public <T> ConfigOption<T> defaultValue(T value) {
+ checkNotNull(value);
+ return new ConfigOption<>(
+ key, value.getClass(), ConfigOption.EMPTY_DESCRIPTION, value, false);
+ }
+
+ /**
+ * Creates a string-valued option with no default value. String-valued options are the only
+ * ones that can have no default value.
+ *
+ * @return The created ConfigOption.
+ * @deprecated define the type explicitly first with one of the intType(), stringType(),
+ * etc.
+ */
+ @Deprecated
+ public ConfigOption<String> noDefaultValue() {
+ return new ConfigOption<>(
+ key, String.class, ConfigOption.EMPTY_DESCRIPTION, null, false);
+ }
+ }
+
+ /**
+ * Builder for {@link ConfigOption} with a defined atomic type.
+ *
+ * @param <T> atomic type of the option
+ */
+ public static class TypedConfigOptionBuilder<T> {
+ private final String key;
+ private final Class<T> clazz;
+
+ TypedConfigOptionBuilder(String key, Class<T> clazz) {
+ this.key = key;
+ this.clazz = clazz;
+ }
+
+ /** Defines that the option's type should be a list of previously defined atomic type. */
+ public ListConfigOptionBuilder<T> asList() {
+ return new ListConfigOptionBuilder<>(key, clazz);
+ }
+
+ /**
+ * Creates a ConfigOption with the given default value.
+ *
+ * @param value The default value for the config option
+ * @return The config option with the default value.
+ */
+ public ConfigOption<T> defaultValue(T value) {
+ return new ConfigOption<>(key, clazz, ConfigOption.EMPTY_DESCRIPTION, value, false);
+ }
+
+ /**
+ * Creates a ConfigOption without a default value.
+ *
+ * @return The config option without a default value.
+ */
+ public ConfigOption<T> noDefaultValue() {
+ return new ConfigOption<>(
+ key, clazz, Description.builder().text("").build(), null, false);
+ }
+ }
+
+ /**
+ * Builder for {@link ConfigOption} of list of type {@link E}.
+ *
+ * @param <E> list element type of the option
+ */
+ public static class ListConfigOptionBuilder<E> {
+ private final String key;
+ private final Class<E> clazz;
+
+ ListConfigOptionBuilder(String key, Class<E> clazz) {
+ this.key = key;
+ this.clazz = clazz;
+ }
+
+ /**
+ * Creates a ConfigOption with the given default value.
+ *
+ * @param values The list of default values for the config option
+ * @return The config option with the default value.
+ */
+ @SafeVarargs
+ public final ConfigOption<List<E>> defaultValues(E... values) {
+ return new ConfigOption<>(
+ key, clazz, ConfigOption.EMPTY_DESCRIPTION, Arrays.asList(values), true);
+ }
+
+ /**
+ * Creates a ConfigOption without a default value.
+ *
+ * @return The config option without a default value.
+ */
+ public ConfigOption<List<E>> noDefaultValue() {
+ return new ConfigOption<>(key, clazz, ConfigOption.EMPTY_DESCRIPTION, null, true);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /** Not intended to be instantiated. */
+ private ConfigOptions() {}
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/FallbackKey.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/FallbackKey.java
new file mode 100644
index 00000000..3be7c0d3
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/FallbackKey.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options;
+
+/** A key with FallbackKeys will fall back to the FallbackKeys if it itself is not configured. */
+public class FallbackKey {
+
+ // -------------------------
+ // Factory methods
+ // -------------------------
+
+ static FallbackKey createFallbackKey(String key) {
+ return new FallbackKey(key, false);
+ }
+
+ static FallbackKey createDeprecatedKey(String key) {
+ return new FallbackKey(key, true);
+ }
+
+ // ------------------------------------------------------------------------
+
+ private final String key;
+
+ private final boolean isDeprecated;
+
+ public String getKey() {
+ return key;
+ }
+
+ public boolean isDeprecated() {
+ return isDeprecated;
+ }
+
+ private FallbackKey(String key, boolean isDeprecated) {
+ this.key = key;
+ this.isDeprecated = isDeprecated;
+ }
+
+ // ------------------------------------------------------------------------
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o != null && o.getClass() == FallbackKey.class) {
+ FallbackKey that = (FallbackKey) o;
+ return this.key.equals(that.key) && (this.isDeprecated == that.isDeprecated);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * key.hashCode() + (isDeprecated ? 1 : 0);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("{key=%s, isDeprecated=%s}", key, isDeprecated);
+ }
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/MemorySize.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/MemorySize.java
new file mode 100644
index 00000000..b9ffe16b
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/MemorySize.java
@@ -0,0 +1,419 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Optional;
+import java.util.stream.IntStream;
+
+import static org.apache.flink.table.store.options.MemorySize.MemoryUnit.BYTES;
+import static org.apache.flink.table.store.options.MemorySize.MemoryUnit.GIGA_BYTES;
+import static org.apache.flink.table.store.options.MemorySize.MemoryUnit.KILO_BYTES;
+import static org.apache.flink.table.store.options.MemorySize.MemoryUnit.MEGA_BYTES;
+import static org.apache.flink.table.store.options.MemorySize.MemoryUnit.TERA_BYTES;
+import static org.apache.flink.table.store.options.MemorySize.MemoryUnit.hasUnit;
+import static org.apache.flink.table.store.utils.Preconditions.checkArgument;
+import static org.apache.flink.table.store.utils.Preconditions.checkNotNull;
+
+/**
+ * MemorySize is a representation of a number of bytes, viewable in different units.
+ *
+ * <h2>Parsing</h2>
+ *
+ * <p>The size can be parsed from a text expression. If the expression is a pure number, the value
+ * will be interpreted as bytes.
+ */
+public class MemorySize implements java.io.Serializable, Comparable<MemorySize> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final MemorySize ZERO = new MemorySize(0L);
+
+ public static final MemorySize MAX_VALUE = new MemorySize(Long.MAX_VALUE);
+
+ private static final List<MemoryUnit> ORDERED_UNITS =
+ Arrays.asList(BYTES, KILO_BYTES, MEGA_BYTES, GIGA_BYTES, TERA_BYTES);
+
+ // ------------------------------------------------------------------------
+
+ /** The memory size, in bytes. */
+ private final long bytes;
+
+ /** The memorized value returned by toString(). */
+ private transient String stringified;
+
+ /** The memorized value returned by toHumanReadableString(). */
+ private transient String humanReadableStr;
+
+ /**
+ * Constructs a new MemorySize.
+ *
+ * @param bytes The size, in bytes. Must be zero or larger.
+ */
+ public MemorySize(long bytes) {
+ checkArgument(bytes >= 0, "bytes must be >= 0");
+ this.bytes = bytes;
+ }
+
+ public static MemorySize ofMebiBytes(long mebiBytes) {
+ return new MemorySize(mebiBytes << 20);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /** Gets the memory size in bytes. */
+ public long getBytes() {
+ return bytes;
+ }
+
+ /** Gets the memory size in Kibibytes (= 1024 bytes). */
+ public long getKibiBytes() {
+ return bytes >> 10;
+ }
+
+ /** Gets the memory size in Mebibytes (= 1024 Kibibytes). */
+ public int getMebiBytes() {
+ return (int) (bytes >> 20);
+ }
+
+ /** Gets the memory size in Gibibytes (= 1024 Mebibytes). */
+ public long getGibiBytes() {
+ return bytes >> 30;
+ }
+
+ /** Gets the memory size in Tebibytes (= 1024 Gibibytes). */
+ public long getTebiBytes() {
+ return bytes >> 40;
+ }
+
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ return (int) (bytes ^ (bytes >>> 32));
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj == this
+ || (obj != null
+ && obj.getClass() == this.getClass()
+ && ((MemorySize) obj).bytes == this.bytes);
+ }
+
+ @Override
+ public String toString() {
+ if (stringified == null) {
+ stringified = formatToString();
+ }
+
+ return stringified;
+ }
+
+ private String formatToString() {
+ MemoryUnit highestIntegerUnit =
+ IntStream.range(0, ORDERED_UNITS.size())
+ .sequential()
+ .filter(idx -> bytes % ORDERED_UNITS.get(idx).getMultiplier() != 0)
+ .boxed()
+ .findFirst()
+ .map(
+ idx -> {
+ if (idx == 0) {
+ return ORDERED_UNITS.get(0);
+ } else {
+ return ORDERED_UNITS.get(idx - 1);
+ }
+ })
+ .orElse(BYTES);
+
+ return String.format(
+ "%d %s",
+ bytes / highestIntegerUnit.getMultiplier(), highestIntegerUnit.getUnits()[1]);
+ }
+
+ public String toHumanReadableString() {
+ if (humanReadableStr == null) {
+ humanReadableStr = formatToHumanReadableString();
+ }
+
+ return humanReadableStr;
+ }
+
+ private String formatToHumanReadableString() {
+ MemoryUnit highestUnit =
+ IntStream.range(0, ORDERED_UNITS.size())
+ .sequential()
+ .filter(idx -> bytes > ORDERED_UNITS.get(idx).getMultiplier())
+ .boxed()
+ .max(Comparator.naturalOrder())
+ .map(ORDERED_UNITS::get)
+ .orElse(BYTES);
+
+ if (highestUnit == BYTES) {
+ return String.format("%d %s", bytes, BYTES.getUnits()[1]);
+ } else {
+ double approximate = 1.0 * bytes / highestUnit.getMultiplier();
+ return String.format(
+ Locale.ROOT,
+ "%.3f%s (%d bytes)",
+ approximate,
+ highestUnit.getUnits()[1],
+ bytes);
+ }
+ }
+
+ @Override
+ public int compareTo(MemorySize that) {
+ return Long.compare(this.bytes, that.bytes);
+ }
+
+ // ------------------------------------------------------------------------
+ // Calculations
+ // ------------------------------------------------------------------------
+
+ public MemorySize add(MemorySize that) {
+ return new MemorySize(Math.addExact(this.bytes, that.bytes));
+ }
+
+ public MemorySize subtract(MemorySize that) {
+ return new MemorySize(Math.subtractExact(this.bytes, that.bytes));
+ }
+
+ public MemorySize multiply(double multiplier) {
+ checkArgument(multiplier >= 0, "multiplier must be >= 0");
+
+ BigDecimal product =
+ BigDecimal.valueOf(this.bytes).multiply(BigDecimal.valueOf(multiplier));
+ if (product.compareTo(BigDecimal.valueOf(Long.MAX_VALUE)) > 0) {
+ throw new ArithmeticException("long overflow");
+ }
+ return new MemorySize(product.longValue());
+ }
+
+ public MemorySize divide(long by) {
+ checkArgument(by >= 0, "divisor must be >= 0");
+ return new MemorySize(bytes / by);
+ }
+
+ // ------------------------------------------------------------------------
+ // Parsing
+ // ------------------------------------------------------------------------
+
+ /**
+ * Parses the given string as as MemorySize.
+ *
+ * @param text The string to parse
+ * @return The parsed MemorySize
+ * @throws IllegalArgumentException Thrown, if the expression cannot be parsed.
+ */
+ public static MemorySize parse(String text) throws IllegalArgumentException {
+ return new MemorySize(parseBytes(text));
+ }
+
+ /**
+ * Parses the given string with a default unit.
+ *
+ * @param text The string to parse.
+ * @param defaultUnit specify the default unit.
+ * @return The parsed MemorySize.
+ * @throws IllegalArgumentException Thrown, if the expression cannot be parsed.
+ */
+ public static MemorySize parse(String text, MemoryUnit defaultUnit)
+ throws IllegalArgumentException {
+ if (!hasUnit(text)) {
+ return parse(text + defaultUnit.getUnits()[0]);
+ }
+
+ return parse(text);
+ }
+
+ /**
+ * Parses the given string as bytes. The supported expressions are listed under {@link
+ * MemorySize}.
+ *
+ * @param text The string to parse
+ * @return The parsed size, in bytes.
+ * @throws IllegalArgumentException Thrown, if the expression cannot be parsed.
+ */
+ public static long parseBytes(String text) throws IllegalArgumentException {
+ checkNotNull(text, "text");
+
+ final String trimmed = text.trim();
+ checkArgument(!trimmed.isEmpty(), "argument is an empty- or whitespace-only string");
+
+ final int len = trimmed.length();
+ int pos = 0;
+
+ char current;
+ while (pos < len && (current = trimmed.charAt(pos)) >= '0' && current <= '9') {
+ pos++;
+ }
+
+ final String number = trimmed.substring(0, pos);
+ final String unit = trimmed.substring(pos).trim().toLowerCase(Locale.US);
+
+ if (number.isEmpty()) {
+ throw new NumberFormatException("text does not start with a number");
+ }
+
+ final long value;
+ try {
+ value = Long.parseLong(number); // this throws a NumberFormatException on overflow
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException(
+ "The value '"
+ + number
+ + "' cannot be re represented as 64bit number (numeric overflow).");
+ }
+
+ final long multiplier = parseUnit(unit).map(MemoryUnit::getMultiplier).orElse(1L);
+ final long result = value * multiplier;
+
+ // check for overflow
+ if (result / multiplier != value) {
+ throw new IllegalArgumentException(
+ "The value '"
+ + text
+ + "' cannot be re represented as 64bit number of bytes (numeric overflow).");
+ }
+
+ return result;
+ }
+
+ private static Optional<MemoryUnit> parseUnit(String unit) {
+ if (matchesAny(unit, BYTES)) {
+ return Optional.of(BYTES);
+ } else if (matchesAny(unit, KILO_BYTES)) {
+ return Optional.of(KILO_BYTES);
+ } else if (matchesAny(unit, MEGA_BYTES)) {
+ return Optional.of(MEGA_BYTES);
+ } else if (matchesAny(unit, GIGA_BYTES)) {
+ return Optional.of(GIGA_BYTES);
+ } else if (matchesAny(unit, TERA_BYTES)) {
+ return Optional.of(TERA_BYTES);
+ } else if (!unit.isEmpty()) {
+ throw new IllegalArgumentException(
+ "Memory size unit '"
+ + unit
+ + "' does not match any of the recognized units: "
+ + MemoryUnit.getAllUnits());
+ }
+
+ return Optional.empty();
+ }
+
+ private static boolean matchesAny(String str, MemoryUnit unit) {
+ for (String s : unit.getUnits()) {
+ if (s.equals(str)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Enum which defines memory unit, mostly used to parse value from configuration file.
+ *
+ * <p>To make larger values more compact, the common size suffixes are supported:
+ *
+ * <ul>
+ * <li>1b or 1bytes (bytes)
+ * <li>1k or 1kb or 1kibibytes (interpreted as kibibytes = 1024 bytes)
+ * <li>1m or 1mb or 1mebibytes (interpreted as mebibytes = 1024 kibibytes)
+ * <li>1g or 1gb or 1gibibytes (interpreted as gibibytes = 1024 mebibytes)
+ * <li>1t or 1tb or 1tebibytes (interpreted as tebibytes = 1024 gibibytes)
+ * </ul>
+ */
+ public enum MemoryUnit {
+ BYTES(new String[] {"b", "bytes"}, 1L),
+ KILO_BYTES(new String[] {"k", "kb", "kibibytes"}, 1024L),
+ MEGA_BYTES(new String[] {"m", "mb", "mebibytes"}, 1024L * 1024L),
+ GIGA_BYTES(new String[] {"g", "gb", "gibibytes"}, 1024L * 1024L * 1024L),
+ TERA_BYTES(new String[] {"t", "tb", "tebibytes"}, 1024L * 1024L * 1024L * 1024L);
+
+ private final String[] units;
+
+ private final long multiplier;
+
+ MemoryUnit(String[] units, long multiplier) {
+ this.units = units;
+ this.multiplier = multiplier;
+ }
+
+ public String[] getUnits() {
+ return units;
+ }
+
+ public long getMultiplier() {
+ return multiplier;
+ }
+
+ public static String getAllUnits() {
+ return concatenateUnits(
+ BYTES.getUnits(),
+ KILO_BYTES.getUnits(),
+ MEGA_BYTES.getUnits(),
+ GIGA_BYTES.getUnits(),
+ TERA_BYTES.getUnits());
+ }
+
+ public static boolean hasUnit(String text) {
+ checkNotNull(text, "text");
+
+ final String trimmed = text.trim();
+ checkArgument(!trimmed.isEmpty(), "argument is an empty- or whitespace-only string");
+
+ final int len = trimmed.length();
+ int pos = 0;
+
+ char current;
+ while (pos < len && (current = trimmed.charAt(pos)) >= '0' && current <= '9') {
+ pos++;
+ }
+
+ final String unit = trimmed.substring(pos).trim().toLowerCase(Locale.US);
+
+ return unit.length() > 0;
+ }
+
+ private static String concatenateUnits(final String[]... allUnits) {
+ final StringBuilder builder = new StringBuilder(128);
+
+ for (String[] units : allUnits) {
+ builder.append('(');
+
+ for (String unit : units) {
+ builder.append(unit);
+ builder.append(" | ");
+ }
+
+ builder.setLength(builder.length() - 3);
+ builder.append(") / ");
+ }
+
+ builder.setLength(builder.length() - 3);
+ return builder.toString();
+ }
+ }
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/Options.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/Options.java
index 5f54b9a8..bf8dc1ca 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/Options.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/Options.java
@@ -18,15 +18,19 @@
package org.apache.flink.table.store.options;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.Configuration;
-
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.Properties;
import java.util.Set;
+import java.util.function.BiFunction;
+
+import static org.apache.flink.table.store.options.OptionsUtils.canBePrefixMap;
+import static org.apache.flink.table.store.options.OptionsUtils.containsPrefixMap;
+import static org.apache.flink.table.store.options.OptionsUtils.convertToPropertiesPrefixed;
+import static org.apache.flink.table.store.options.OptionsUtils.removePrefixMap;
/** Options which stores key/value pairs. */
public class Options implements Serializable {
@@ -57,43 +61,163 @@ public class Options implements Serializable {
* @param key the key of the key/value pair to be added
* @param value the value of the key/value pair to be added
*/
- public void setString(String key, String value) {
+ public synchronized void setString(String key, String value) {
data.put(key, value);
}
- public void set(String key, String value) {
+ public synchronized void set(String key, String value) {
data.put(key, value);
}
- public <T> void set(ConfigOption<T> key, T value) {
- Configuration conf = Configuration.fromMap(data);
- conf.set(key, value);
- data.clear();
- data.putAll(conf.toMap());
+ public synchronized <T> Options set(ConfigOption<T> option, T value) {
+ final boolean canBePrefixMap = OptionsUtils.canBePrefixMap(option);
+ setValueInternal(option.key(), value, canBePrefixMap);
+ return this;
+ }
+
+ private <T> void setValueInternal(String key, T value, boolean canBePrefixMap) {
+ if (key == null) {
+ throw new NullPointerException("Key must not be null.");
+ }
+ if (value == null) {
+ throw new NullPointerException("Value must not be null.");
+ }
+
+ synchronized (this.data) {
+ if (canBePrefixMap) {
+ removePrefixMap(this.data, key);
+ }
+ this.data.put(key, OptionsUtils.convertToString(value));
+ }
}
- public <T> T get(ConfigOption<T> option) {
+ public synchronized <T> T get(ConfigOption<T> option) {
return getOptional(option).orElseGet(option::defaultValue);
}
- public String get(String key) {
+ public synchronized String get(String key) {
return data.get(key);
}
- public <T> Optional<T> getOptional(ConfigOption<T> option) {
- return Configuration.fromMap(data).getOptional(option);
+ public synchronized <T> Optional<T> getOptional(ConfigOption<T> option) {
+ Optional<Object> rawValue = getRawValueFromOption(option);
+ Class<?> clazz = option.getClazz();
+
+ try {
+ if (option.isList()) {
+ return rawValue.map(v -> OptionsUtils.convertToList(v, clazz));
+ } else {
+ return rawValue.map(v -> OptionsUtils.convertValue(v, clazz));
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException(
+ String.format(
+ "Could not parse value '%s' for key '%s'.",
+ rawValue.map(Object::toString).orElse(""), option.key()),
+ e);
+ }
+ }
+
+ private Optional<Object> getRawValueFromOption(ConfigOption<?> configOption) {
+ return applyWithOption(configOption, this::getRawValue);
+ }
+
+ private Optional<Object> getRawValue(String key) {
+ return getRawValue(key, false);
+ }
+
+ private Optional<Object> getRawValue(String key, boolean canBePrefixMap) {
+ if (key == null) {
+ throw new NullPointerException("Key must not be null.");
+ }
+
+ synchronized (this.data) {
+ final Object valueFromExactKey = this.data.get(key);
+ if (!canBePrefixMap || valueFromExactKey != null) {
+ return Optional.ofNullable(valueFromExactKey);
+ }
+ final Map<String, String> valueFromPrefixMap = convertToPropertiesPrefixed(data, key);
+ if (valueFromPrefixMap.isEmpty()) {
+ return Optional.empty();
+ }
+ return Optional.of(valueFromPrefixMap);
+ }
+ }
+
+ /**
+ * Checks whether there is an entry for the given config option.
+ *
+ * @param configOption The configuration option
+ * @return <tt>true</tt> if a valid (current or deprecated) key of the config option is stored,
+ * <tt>false</tt> otherwise
+ */
+ public synchronized boolean contains(ConfigOption<?> configOption) {
+ synchronized (this.data) {
+ final BiFunction<String, Boolean, Optional<Boolean>> applier =
+ (key, canBePrefixMap) -> {
+ if (canBePrefixMap && containsPrefixMap(this.data, key)
+ || this.data.containsKey(key)) {
+ return Optional.of(true);
+ }
+ return Optional.empty();
+ };
+ return applyWithOption(configOption, applier).orElse(false);
+ }
+ }
+
+ private <T> Optional<T> applyWithOption(
+ ConfigOption<?> option, BiFunction<String, Boolean, Optional<T>> applier) {
+ final boolean canBePrefixMap = canBePrefixMap(option);
+ final Optional<T> valueFromExactKey = applier.apply(option.key(), canBePrefixMap);
+ if (valueFromExactKey.isPresent()) {
+ return valueFromExactKey;
+ } else if (option.hasFallbackKeys()) {
+ // try the fallback keys
+ for (FallbackKey fallbackKey : option.fallbackKeys()) {
+ final Optional<T> valueFromFallbackKey =
+ applier.apply(fallbackKey.getKey(), canBePrefixMap);
+ if (valueFromFallbackKey.isPresent()) {
+ return valueFromFallbackKey;
+ }
+ }
+ }
+ return Optional.empty();
}
- public Set<String> keySet() {
+ public synchronized Set<String> keySet() {
return data.keySet();
}
- public Map<String, String> toMap() {
+ public synchronized Map<String, String> toMap() {
return data;
}
+ public synchronized Options removePrefix(String prefix) {
+ Map<String, String> newData = new HashMap<>();
+ data.forEach(
+ (k, v) -> {
+ if (k.startsWith(prefix)) {
+ newData.put(k.substring(prefix.length()), v);
+ }
+ });
+ return new Options(newData);
+ }
+
+ public synchronized boolean containsKey(String key) {
+ return data.containsKey(key);
+ }
+
+ /** Adds all entries in this options to the given {@link Properties}. */
+ public synchronized void addAllToProperties(Properties props) {
+ props.putAll(this.data);
+ }
+
+ public synchronized String getString(ConfigOption<String> option) {
+ return get(option);
+ }
+
@Override
- public boolean equals(Object o) {
+ public synchronized boolean equals(Object o) {
if (this == o) {
return true;
}
@@ -105,7 +229,31 @@ public class Options implements Serializable {
}
@Override
- public int hashCode() {
+ public synchronized int hashCode() {
return Objects.hash(data);
}
+
+ public synchronized boolean getBoolean(String key, boolean defaultValue) {
+ return getRawValue(key).map(OptionsUtils::convertToBoolean).orElse(defaultValue);
+ }
+
+ public synchronized int getInteger(String key, int defaultValue) {
+ return getRawValue(key).map(OptionsUtils::convertToInt).orElse(defaultValue);
+ }
+
+ public synchronized String getString(String key, String defaultValue) {
+ return getRawValue(key).map(OptionsUtils::convertToString).orElse(defaultValue);
+ }
+
+ public synchronized void setInteger(String key, int value) {
+ setValueInternal(key, value);
+ }
+
+ private <T> void setValueInternal(String key, T value) {
+ setValueInternal(key, value, false);
+ }
+
+ public synchronized long getLong(String key, long defaultValue) {
+ return getRawValue(key).map(OptionsUtils::convertToLong).orElse(defaultValue);
+ }
}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/OptionsUtils.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/OptionsUtils.java
new file mode 100644
index 00000000..a94b7282
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/OptionsUtils.java
@@ -0,0 +1,358 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options;
+
+import org.apache.flink.table.store.utils.TimeUtils;
+
+import javax.annotation.Nonnull;
+
+import java.io.File;
+import java.time.Duration;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.table.store.options.StructuredOptionsSplitter.escapeWithSingleQuote;
+
+/** Utility class for {@link Options} related helper functions. */
+public class OptionsUtils {
+
+ private static final String[] EMPTY = new String[0];
+
+ /**
+ * Parses a string as a map of strings. The expected format of the map is:
+ *
+ * <pre>
+ * key1:value1,key2:value2
+ * </pre>
+ *
+ * <p>Parts of the string can be escaped by wrapping with single or double quotes.
+ *
+ * @param stringSerializedMap a string to parse
+ * @return parsed map
+ */
+ public static Map<String, String> parseMap(String stringSerializedMap) {
+ return StructuredOptionsSplitter.splitEscaped(stringSerializedMap, ',').stream()
+ .map(p -> StructuredOptionsSplitter.splitEscaped(p, ':'))
+ .collect(
+ Collectors.toMap(
+ arr -> arr.get(0), // key name
+ arr -> arr.get(1) // value
+ ));
+ }
+
+ @Nonnull
+ public static String[] splitPaths(@Nonnull String separatedPaths) {
+ return separatedPaths.length() > 0
+ ? separatedPaths.split(",|" + File.pathSeparator)
+ : EMPTY;
+ }
+
+ /**
+ * Extract and parse Flink configuration properties with a given name prefix and return the
+ * result as a Map.
+ */
+ public static Map<String, String> getPrefixedKeyValuePairs(
+ String prefix, Options configuration) {
+ Map<String, String> result = new HashMap<>();
+ for (Map.Entry<String, String> entry : configuration.toMap().entrySet()) {
+ if (entry.getKey().startsWith(prefix) && entry.getKey().length() > prefix.length()) {
+ String key = entry.getKey().substring(prefix.length());
+ result.put(key, entry.getValue());
+ }
+ }
+ return result;
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Type conversion
+ // --------------------------------------------------------------------------------------------
+
+ /**
+ * Tries to convert the raw value into the provided type.
+ *
+ * @param rawValue rawValue to convert into the provided type clazz
+ * @param clazz clazz specifying the target type
+ * @param <T> type of the result
+ * @return the converted value if rawValue is of type clazz
+ * @throws IllegalArgumentException if the rawValue cannot be converted in the specified target
+ * type clazz
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T convertValue(Object rawValue, Class<?> clazz) {
+ if (Integer.class.equals(clazz)) {
+ return (T) convertToInt(rawValue);
+ } else if (Long.class.equals(clazz)) {
+ return (T) convertToLong(rawValue);
+ } else if (Boolean.class.equals(clazz)) {
+ return (T) convertToBoolean(rawValue);
+ } else if (Float.class.equals(clazz)) {
+ return (T) convertToFloat(rawValue);
+ } else if (Double.class.equals(clazz)) {
+ return (T) convertToDouble(rawValue);
+ } else if (String.class.equals(clazz)) {
+ return (T) convertToString(rawValue);
+ } else if (clazz.isEnum()) {
+ return (T) convertToEnum(rawValue, (Class<? extends Enum<?>>) clazz);
+ } else if (clazz == Duration.class) {
+ return (T) convertToDuration(rawValue);
+ } else if (clazz == MemorySize.class) {
+ return (T) convertToMemorySize(rawValue);
+ } else if (clazz == Map.class) {
+ return (T) convertToProperties(rawValue);
+ }
+
+ throw new IllegalArgumentException("Unsupported type: " + clazz);
+ }
+
+ @SuppressWarnings("unchecked")
+ static <T> T convertToList(Object rawValue, Class<?> atomicClass) {
+ if (rawValue instanceof List) {
+ return (T) rawValue;
+ } else {
+ return (T)
+ StructuredOptionsSplitter.splitEscaped(rawValue.toString(), ';').stream()
+ .map(s -> convertValue(s, atomicClass))
+ .collect(Collectors.toList());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ static Map<String, String> convertToProperties(Object o) {
+ if (o instanceof Map) {
+ return (Map<String, String>) o;
+ } else {
+ List<String> listOfRawProperties =
+ StructuredOptionsSplitter.splitEscaped(o.toString(), ',');
+ return listOfRawProperties.stream()
+ .map(s -> StructuredOptionsSplitter.splitEscaped(s, ':'))
+ .peek(
+ pair -> {
+ if (pair.size() != 2) {
+ throw new IllegalArgumentException(
+ "Map item is not a key-value pair (missing ':'?)");
+ }
+ })
+ .collect(Collectors.toMap(a -> a.get(0), a -> a.get(1)));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <E extends Enum<?>> E convertToEnum(Object o, Class<E> clazz) {
+ if (o.getClass().equals(clazz)) {
+ return (E) o;
+ }
+
+ return Arrays.stream(clazz.getEnumConstants())
+ .filter(
+ e ->
+ e.toString()
+ .toUpperCase(Locale.ROOT)
+ .equals(o.toString().toUpperCase(Locale.ROOT)))
+ .findAny()
+ .orElseThrow(
+ () ->
+ new IllegalArgumentException(
+ String.format(
+ "Could not parse value for enum %s. Expected one of: [%s]",
+ clazz, Arrays.toString(clazz.getEnumConstants()))));
+ }
+
+ static Duration convertToDuration(Object o) {
+ if (o.getClass() == Duration.class) {
+ return (Duration) o;
+ }
+
+ return TimeUtils.parseDuration(o.toString());
+ }
+
+ static MemorySize convertToMemorySize(Object o) {
+ if (o.getClass() == MemorySize.class) {
+ return (MemorySize) o;
+ }
+
+ return MemorySize.parse(o.toString());
+ }
+
+ static String convertToString(Object o) {
+ if (o.getClass() == String.class) {
+ return (String) o;
+ } else if (o.getClass() == Duration.class) {
+ Duration duration = (Duration) o;
+ return TimeUtils.formatWithHighestUnit(duration);
+ } else if (o instanceof List) {
+ return ((List<?>) o)
+ .stream()
+ .map(e -> escapeWithSingleQuote(convertToString(e), ";"))
+ .collect(Collectors.joining(";"));
+ } else if (o instanceof Map) {
+ return ((Map<?, ?>) o)
+ .entrySet().stream()
+ .map(
+ e -> {
+ String escapedKey =
+ escapeWithSingleQuote(e.getKey().toString(), ":");
+ String escapedValue =
+ escapeWithSingleQuote(e.getValue().toString(), ":");
+
+ return escapeWithSingleQuote(
+ escapedKey + ":" + escapedValue, ",");
+ })
+ .collect(Collectors.joining(","));
+ }
+
+ return o.toString();
+ }
+
+ static Integer convertToInt(Object o) {
+ if (o.getClass() == Integer.class) {
+ return (Integer) o;
+ } else if (o.getClass() == Long.class) {
+ long value = (Long) o;
+ if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
+ return (int) value;
+ } else {
+ throw new IllegalArgumentException(
+ String.format(
+ "Configuration value %s overflows/underflows the integer type.",
+ value));
+ }
+ }
+
+ return Integer.parseInt(o.toString());
+ }
+
+ static Long convertToLong(Object o) {
+ if (o.getClass() == Long.class) {
+ return (Long) o;
+ } else if (o.getClass() == Integer.class) {
+ return ((Integer) o).longValue();
+ }
+
+ return Long.parseLong(o.toString());
+ }
+
+ static Boolean convertToBoolean(Object o) {
+ if (o.getClass() == Boolean.class) {
+ return (Boolean) o;
+ }
+
+ switch (o.toString().toUpperCase()) {
+ case "TRUE":
+ return true;
+ case "FALSE":
+ return false;
+ default:
+ throw new IllegalArgumentException(
+ String.format(
+ "Unrecognized option for boolean: %s. Expected either true or false(case insensitive)",
+ o));
+ }
+ }
+
+ static Float convertToFloat(Object o) {
+ if (o.getClass() == Float.class) {
+ return (Float) o;
+ } else if (o.getClass() == Double.class) {
+ double value = ((Double) o);
+ if (value == 0.0
+ || (value >= Float.MIN_VALUE && value <= Float.MAX_VALUE)
+ || (value >= -Float.MAX_VALUE && value <= -Float.MIN_VALUE)) {
+ return (float) value;
+ } else {
+ throw new IllegalArgumentException(
+ String.format(
+ "Configuration value %s overflows/underflows the float type.",
+ value));
+ }
+ }
+
+ return Float.parseFloat(o.toString());
+ }
+
+ static Double convertToDouble(Object o) {
+ if (o.getClass() == Double.class) {
+ return (Double) o;
+ } else if (o.getClass() == Float.class) {
+ return ((Float) o).doubleValue();
+ }
+
+ return Double.parseDouble(o.toString());
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Prefix map handling
+ // --------------------------------------------------------------------------------------------
+
+ /**
+ * Maps can be represented in two ways.
+ *
+ * <p>With constant key space:
+ *
+ * <pre>
+ * avro-confluent.properties = schema: 1, other-prop: 2
+ * </pre>
+ *
+ * <p>Or with variable key space (i.e. prefix notation):
+ *
+ * <pre>
+ * avro-confluent.properties.schema = 1
+ * avro-confluent.properties.other-prop = 2
+ * </pre>
+ */
+ public static boolean canBePrefixMap(ConfigOption<?> configOption) {
+ return configOption.getClazz() == Map.class && !configOption.isList();
+ }
+
+ /** Filter condition for prefix map keys. */
+ public static boolean filterPrefixMapKey(String key, String candidate) {
+ final String prefixKey = key + ".";
+ return candidate.startsWith(prefixKey);
+ }
+
+ static Map<String, String> convertToPropertiesPrefixed(
+ Map<String, String> confData, String key) {
+ final String prefixKey = key + ".";
+ return confData.keySet().stream()
+ .filter(k -> k.startsWith(prefixKey))
+ .collect(
+ Collectors.toMap(
+ k -> k.substring(prefixKey.length()),
+ k -> convertToString(confData.get(k))));
+ }
+
+ static boolean containsPrefixMap(Map<String, String> confData, String key) {
+ return confData.keySet().stream().anyMatch(candidate -> filterPrefixMapKey(key, candidate));
+ }
+
+ static boolean removePrefixMap(Map<String, String> confData, String key) {
+ final List<String> prefixKeys =
+ confData.keySet().stream()
+ .filter(candidate -> filterPrefixMapKey(key, candidate))
+ .collect(Collectors.toList());
+ prefixKeys.forEach(confData::remove);
+ return !prefixKeys.isEmpty();
+ }
+
+ // Make sure that we cannot instantiate this class
+ private OptionsUtils() {}
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/StructuredOptionsSplitter.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/StructuredOptionsSplitter.java
new file mode 100644
index 00000000..1d96bf0e
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/StructuredOptionsSplitter.java
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.apache.flink.table.store.utils.Preconditions.checkNotNull;
+
+/** Helper class for splitting a string on a given delimiter with quoting logic. */
+class StructuredOptionsSplitter {
+
+ /**
+ * Splits the given string on the given delimiter. It supports quoting parts of the string with
+ * either single (') or double quotes ("). Quotes can be escaped by doubling the quotes.
+ *
+ * <p>Examples:
+ *
+ * <ul>
+ * <li>'A;B';C => [A;B], [C]
+ * <li>"AB'D";B;C => [AB'D], [B], [C]
+ * <li>"AB'""D;B";C => [AB'\"D;B], [C]
+ * </ul>
+ *
+ * <p>For more examples check the tests.
+ *
+ * @param string a string to split
+ * @param delimiter delimiter to split on
+ * @return a list of splits
+ */
+ static List<String> splitEscaped(String string, char delimiter) {
+ List<Token> tokens = tokenize(checkNotNull(string), delimiter);
+ return processTokens(tokens);
+ }
+
+ /**
+ * Escapes the given string with single quotes, if the input string contains a double quote or
+ * any of the given {@code charsToEscape}. Any single quotes in the input string will be escaped
+ * by doubling.
+ *
+ * <p>Given that the escapeChar is (;)
+ *
+ * <p>Examples:
+ *
+ * <ul>
+ * <li>A,B,C,D => A,B,C,D
+ * <li>A'B'C'D => 'A''B''C''D'
+ * <li>A;BCD => 'A;BCD'
+ * <li>AB"C"D => 'AB"C"D'
+ * <li>AB'"D:B => 'AB''"D:B'
+ * </ul>
+ *
+ * @param string a string which needs to be escaped
+ * @param charsToEscape escape chars for the escape conditions
+ * @return escaped string by single quote
+ */
+ static String escapeWithSingleQuote(String string, String... charsToEscape) {
+ boolean escape =
+ Arrays.stream(charsToEscape).anyMatch(string::contains)
+ || string.contains("\"")
+ || string.contains("'");
+
+ if (escape) {
+ return "'" + string.replaceAll("'", "''") + "'";
+ }
+
+ return string;
+ }
+
+ private static List<String> processTokens(List<Token> tokens) {
+ final List<String> splits = new ArrayList<>();
+ for (int i = 0; i < tokens.size(); i++) {
+ Token token = tokens.get(i);
+ switch (token.getTokenType()) {
+ case DOUBLE_QUOTED:
+ case SINGLE_QUOTED:
+ if (i + 1 < tokens.size()
+ && tokens.get(i + 1).getTokenType() != TokenType.DELIMITER) {
+ int illegalPosition = tokens.get(i + 1).getPosition() - 1;
+ throw new IllegalArgumentException(
+ "Could not split string. Illegal quoting at position: "
+ + illegalPosition);
+ }
+ splits.add(token.getString());
+ break;
+ case UNQUOTED:
+ splits.add(token.getString());
+ break;
+ case DELIMITER:
+ if (i + 1 < tokens.size()
+ && tokens.get(i + 1).getTokenType() == TokenType.DELIMITER) {
+ splits.add("");
+ }
+ break;
+ }
+ }
+
+ return splits;
+ }
+
+ private static List<Token> tokenize(String string, char delimiter) {
+ final List<Token> tokens = new ArrayList<>();
+ final StringBuilder builder = new StringBuilder();
+ for (int cursor = 0; cursor < string.length(); ) {
+ final char c = string.charAt(cursor);
+
+ int nextChar = cursor + 1;
+ if (c == '\'') {
+ nextChar = consumeInQuotes(string, '\'', cursor, builder);
+ tokens.add(new Token(TokenType.SINGLE_QUOTED, builder.toString(), cursor));
+ } else if (c == '"') {
+ nextChar = consumeInQuotes(string, '"', cursor, builder);
+ tokens.add(new Token(TokenType.DOUBLE_QUOTED, builder.toString(), cursor));
+ } else if (c == delimiter) {
+ tokens.add(new Token(TokenType.DELIMITER, String.valueOf(c), cursor));
+ } else if (!Character.isWhitespace(c)) {
+ nextChar = consumeUnquoted(string, delimiter, cursor, builder);
+ tokens.add(new Token(TokenType.UNQUOTED, builder.toString().trim(), cursor));
+ }
+ builder.setLength(0);
+ cursor = nextChar;
+ }
+
+ return tokens;
+ }
+
+ private static int consumeInQuotes(
+ String string, char quote, int cursor, StringBuilder builder) {
+ for (int i = cursor + 1; i < string.length(); i++) {
+ char c = string.charAt(i);
+ if (c == quote) {
+ if (i + 1 < string.length() && string.charAt(i + 1) == quote) {
+ builder.append(c);
+ i += 1;
+ } else {
+ return i + 1;
+ }
+ } else {
+ builder.append(c);
+ }
+ }
+
+ throw new IllegalArgumentException(
+ "Could not split string. Quoting was not closed properly.");
+ }
+
+ private static int consumeUnquoted(
+ String string, char delimiter, int cursor, StringBuilder builder) {
+ int i;
+ for (i = cursor; i < string.length(); i++) {
+ char c = string.charAt(i);
+ if (c == delimiter) {
+ return i;
+ }
+
+ builder.append(c);
+ }
+
+ return i;
+ }
+
+ private enum TokenType {
+ DOUBLE_QUOTED,
+ SINGLE_QUOTED,
+ UNQUOTED,
+ DELIMITER
+ }
+
+ private static class Token {
+ private final TokenType tokenType;
+ private final String string;
+ private final int position;
+
+ private Token(TokenType tokenType, String string, int position) {
+ this.tokenType = tokenType;
+ this.string = string;
+ this.position = position;
+ }
+
+ public TokenType getTokenType() {
+ return tokenType;
+ }
+
+ public String getString() {
+ return string;
+ }
+
+ public int getPosition() {
+ return position;
+ }
+ }
+
+ private StructuredOptionsSplitter() {}
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/BlockElement.java
similarity index 71%
copy from flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
copy to flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/BlockElement.java
index f0ff0c01..bcbeee4a 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/BlockElement.java
@@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,14 +16,7 @@
* limitations under the License.
*/
-package org.apache.flink.table.store.format;
+package org.apache.flink.table.store.options.description;
-import org.apache.flink.configuration.Configuration;
-
-/** Factory to create {@link FileFormat}. */
-public interface FileFormatFactory {
-
- String identifier();
-
- FileFormat create(Configuration formatOptions);
-}
+/** Part of description that represents a block e.g. some text, linebreak or a list. */
+public interface BlockElement extends DescriptionElement {}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/DescribedEnum.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/DescribedEnum.java
new file mode 100644
index 00000000..9f222859
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/DescribedEnum.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options.description;
+
+import org.apache.flink.table.store.options.ConfigOption;
+
+/**
+ * Describe enum constants used in {@link ConfigOption}s.
+ *
+ * <p>For enums used as config options, this interface can be implemented to provide a {@link
+ * Description} for each enum constant. This will be used when generating documentation for config
+ * options to include a list of available values alongside their respective descriptions.
+ *
+ * <p>More precisely, only an {@link InlineElement} can be returned as block elements cannot be
+ * nested into a list.
+ */
+public interface DescribedEnum {
+
+ /**
+ * Returns the description for the enum constant.
+ *
+ * <p>If you want to include links or code blocks, use {@link
+ * TextElement#wrap(InlineElement...)} to wrap multiple inline elements into a single one.
+ */
+ InlineElement getDescription();
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/Description.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/Description.java
new file mode 100644
index 00000000..f1fd62ae
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/Description.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options.description;
+
+import org.apache.flink.annotation.PublicEvolving;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Description for {@link org.apache.flink.table.store.options.ConfigOption}. Allows providing
+ * multiple rich formats.
+ */
+public class Description {
+
+ private final List<BlockElement> blocks;
+
+ public static DescriptionBuilder builder() {
+ return new DescriptionBuilder();
+ }
+
+ public List<BlockElement> getBlocks() {
+ return blocks;
+ }
+
+ /**
+ * Builder for {@link Description}. Allows adding a rich formatting like lists, links,
+ * linebreaks etc. For example:
+ *
+ * <pre>{@code
+ * Description description = Description.builder()
+ * .text("This is some list: ")
+ * .list(
+ * text("this is first element of list"),
+ * text("this is second element of list with a %s", link("https://link")))
+ * .build();
+ * }</pre>
+ */
+ @PublicEvolving
+ public static class DescriptionBuilder {
+
+ private final List<BlockElement> blocks = new ArrayList<>();
+
+ /**
+ * Adds a block of text with placeholders ("%s") that will be replaced with proper string
+ * representation of given {@link InlineElement}. For example:
+ *
+ * <p>{@code text("This is a text with a link %s", link("https://somepage", "to here"))}
+ *
+ * @param format text with placeholders for elements
+ * @param elements elements to be put in the text
+ * @return description with added block of text
+ */
+ public DescriptionBuilder text(String format, InlineElement... elements) {
+ blocks.add(TextElement.text(format, elements));
+ return this;
+ }
+
+ /**
+ * Creates a simple block of text.
+ *
+ * @param text a simple block of text
+ * @return block of text
+ */
+ public DescriptionBuilder text(String text) {
+ blocks.add(TextElement.text(text));
+ return this;
+ }
+
+ /**
+ * Block of description add.
+ *
+ * @param block block of description to add
+ * @return block of description
+ */
+ public DescriptionBuilder add(BlockElement block) {
+ blocks.add(block);
+ return this;
+ }
+
+ /** Creates a line break in the description. */
+ public DescriptionBuilder linebreak() {
+ blocks.add(LineBreakElement.linebreak());
+ return this;
+ }
+
+ /** Adds a bulleted list to the description. */
+ public DescriptionBuilder list(InlineElement... elements) {
+ blocks.add(ListElement.list(elements));
+ return this;
+ }
+
+ /** Creates description representation. */
+ public Description build() {
+ return new Description(blocks);
+ }
+ }
+
+ private Description(List<BlockElement> blocks) {
+ this.blocks = blocks;
+ }
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/DescriptionElement.java
similarity index 65%
copy from flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
copy to flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/DescriptionElement.java
index f0ff0c01..356d8bb3 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/DescriptionElement.java
@@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,14 +16,14 @@
* limitations under the License.
*/
-package org.apache.flink.table.store.format;
+package org.apache.flink.table.store.options.description;
-import org.apache.flink.configuration.Configuration;
-
-/** Factory to create {@link FileFormat}. */
-public interface FileFormatFactory {
-
- String identifier();
-
- FileFormat create(Configuration formatOptions);
+/** Part of a {@link Description} that can be converted into String representation. */
+interface DescriptionElement {
+ /**
+ * Transforms itself into String representation using given format.
+ *
+ * @param formatter formatter to use.
+ */
+ void format(Formatter formatter);
}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/Formatter.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/Formatter.java
new file mode 100644
index 00000000..74012dc6
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/Formatter.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options.description;
+
+import java.util.EnumSet;
+
+/**
+ * Allows providing multiple formatters for the description. E.g. Html formatter, Markdown formatter
+ * etc.
+ */
+public abstract class Formatter {
+
+ private final StringBuilder state = new StringBuilder();
+
+ /**
+ * Formats the description into a String using format specific tags.
+ *
+ * @param description description to be formatted
+ * @return string representation of the description
+ */
+ public String format(Description description) {
+ for (BlockElement blockElement : description.getBlocks()) {
+ blockElement.format(this);
+ }
+ return finalizeFormatting();
+ }
+
+ public void format(LinkElement element) {
+ formatLink(state, element.getLink(), element.getText());
+ }
+
+ public void format(TextElement element) {
+ String[] inlineElements =
+ element.getElements().stream()
+ .map(
+ el -> {
+ Formatter formatter = newInstance();
+ el.format(formatter);
+ return formatter.finalizeFormatting();
+ })
+ .toArray(String[]::new);
+ formatText(
+ state,
+ escapeFormatPlaceholder(element.getFormat()),
+ inlineElements,
+ element.getStyles());
+ }
+
+ public void format(LineBreakElement element) {
+ formatLineBreak(state);
+ }
+
+ public void format(ListElement element) {
+ String[] inlineElements =
+ element.getEntries().stream()
+ .map(
+ el -> {
+ Formatter formatter = newInstance();
+ el.format(formatter);
+ return formatter.finalizeFormatting();
+ })
+ .toArray(String[]::new);
+ formatList(state, inlineElements);
+ }
+
+ private String finalizeFormatting() {
+ String result = state.toString();
+ state.setLength(0);
+ return result.replaceAll("%%", "%");
+ }
+
+ protected abstract void formatLink(StringBuilder state, String link, String description);
+
+ protected abstract void formatLineBreak(StringBuilder state);
+
+ protected abstract void formatText(
+ StringBuilder state,
+ String format,
+ String[] elements,
+ EnumSet<TextElement.TextStyle> styles);
+
+ protected abstract void formatList(StringBuilder state, String[] entries);
+
+ protected abstract Formatter newInstance();
+
+ private static final String TEMPORARY_PLACEHOLDER = "randomPlaceholderForStringFormat";
+
+ private static String escapeFormatPlaceholder(String value) {
+ return value.replaceAll("%s", TEMPORARY_PLACEHOLDER)
+ .replaceAll("%", "%%")
+ .replaceAll(TEMPORARY_PLACEHOLDER, "%s");
+ }
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/HtmlFormatter.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/HtmlFormatter.java
new file mode 100644
index 00000000..6cad7b0e
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/HtmlFormatter.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options.description;
+
+import java.util.EnumSet;
+
+/** Formatter that transforms {@link Description} into Html representation. */
+public class HtmlFormatter extends Formatter {
+
+ @Override
+ protected void formatLink(StringBuilder state, String link, String description) {
+ state.append(String.format("<a href=\"%s\">%s</a>", link, description));
+ }
+
+ @Override
+ protected void formatLineBreak(StringBuilder state) {
+ state.append("<br />");
+ }
+
+ @Override
+ protected void formatText(
+ StringBuilder state,
+ String format,
+ String[] elements,
+ EnumSet<TextElement.TextStyle> styles) {
+ String escapedFormat = escapeCharacters(format);
+
+ String prefix = "";
+ String suffix = "";
+ if (styles.contains(TextElement.TextStyle.CODE)) {
+ prefix = "<code class=\"highlighter-rouge\">";
+ suffix = "</code>";
+ }
+ state.append(prefix);
+ state.append(String.format(escapedFormat, (Object[]) elements));
+ state.append(suffix);
+ }
+
+ @Override
+ protected void formatList(StringBuilder state, String[] entries) {
+ state.append("<ul>");
+ for (String entry : entries) {
+ state.append(String.format("<li>%s</li>", entry));
+ }
+ state.append("</ul>");
+ }
+
+ @Override
+ protected Formatter newInstance() {
+ return new HtmlFormatter();
+ }
+
+ private static String escapeCharacters(String value) {
+ return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
+ }
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/InlineElement.java
similarity index 71%
copy from flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
copy to flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/InlineElement.java
index f0ff0c01..20a8f77b 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/format/FileFormatFactory.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/InlineElement.java
@@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,14 +16,7 @@
* limitations under the License.
*/
-package org.apache.flink.table.store.format;
+package org.apache.flink.table.store.options.description;
-import org.apache.flink.configuration.Configuration;
-
-/** Factory to create {@link FileFormat}. */
-public interface FileFormatFactory {
-
- String identifier();
-
- FileFormat create(Configuration formatOptions);
-}
+/** Part of description that represents an element inside a block e.g. a link. */
+public interface InlineElement extends DescriptionElement {}
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormatFactory.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/LineBreakElement.java
similarity index 60%
copy from flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormatFactory.java
copy to flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/LineBreakElement.java
index ee89402a..0172ff12 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormatFactory.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/LineBreakElement.java
@@ -16,22 +16,20 @@
* limitations under the License.
*/
-package org.apache.flink.table.store.file.format;
+package org.apache.flink.table.store.options.description;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.table.store.format.FileFormat;
-import org.apache.flink.table.store.format.FileFormatFactory;
+/** Represents a line break in the {@link Description}. */
+public class LineBreakElement implements InlineElement, BlockElement {
-/** Factory to create {@link FileStatsExtractingAvroFormat}. */
-public class FileStatsExtractingAvroFormatFactory implements FileFormatFactory {
-
- @Override
- public String identifier() {
- return "avro-extract";
+ /** Creates a line break in the description. */
+ public static LineBreakElement linebreak() {
+ return new LineBreakElement();
}
+ private LineBreakElement() {}
+
@Override
- public FileFormat create(Configuration formatOptions) {
- return new FileStatsExtractingAvroFormat();
+ public void format(Formatter formatter) {
+ formatter.format(this);
}
}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/LinkElement.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/LinkElement.java
new file mode 100644
index 00000000..ca2f2427
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/LinkElement.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options.description;
+
+/** Element that represents a link in the {@link Description}. */
+public class LinkElement implements InlineElement {
+ private final String link;
+ private final String text;
+
+ /**
+ * Creates a link with a given url and description.
+ *
+ * @param link address that this link should point to
+ * @param text a description for that link, that should be used in text
+ * @return link representation
+ */
+ public static LinkElement link(String link, String text) {
+ return new LinkElement(link, text);
+ }
+
+ /**
+ * Creates a link with a given url. This url will be used as a description for that link.
+ *
+ * @param link address that this link should point to
+ * @return link representation
+ */
+ public static LinkElement link(String link) {
+ return new LinkElement(link, link);
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ private LinkElement(String link, String text) {
+ this.link = link;
+ this.text = text;
+ }
+
+ @Override
+ public void format(Formatter formatter) {
+ formatter.format(this);
+ }
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/ListElement.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/ListElement.java
new file mode 100644
index 00000000..b3ca330e
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/ListElement.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options.description;
+
+import java.util.Arrays;
+import java.util.List;
+
+/** Represents a list in the {@link Description}. */
+public class ListElement implements BlockElement {
+
+ private final List<InlineElement> entries;
+
+ /**
+ * Creates a list with blocks of text. For example:
+ *
+ * <pre>{@code
+ * .list(
+ * text("this is first element of list"),
+ * text("this is second element of list with a %s", link("https://link"))
+ * )
+ * }</pre>
+ *
+ * @param elements list of this list entries
+ * @return list representation
+ */
+ public static ListElement list(InlineElement... elements) {
+ return new ListElement(Arrays.asList(elements));
+ }
+
+ public List<InlineElement> getEntries() {
+ return entries;
+ }
+
+ private ListElement(List<InlineElement> entries) {
+ this.entries = entries;
+ }
+
+ @Override
+ public void format(Formatter formatter) {
+ formatter.format(this);
+ }
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/TextElement.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/TextElement.java
new file mode 100644
index 00000000..0264cb54
--- /dev/null
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/options/description/TextElement.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.store.options.description;
+
+import org.apache.flink.shaded.guava30.com.google.common.base.Strings;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.List;
+
+/** Represents a text block in the {@link Description}. */
+public class TextElement implements BlockElement, InlineElement {
+ private final String format;
+ private final List<InlineElement> elements;
+ private final EnumSet<TextStyle> textStyles = EnumSet.noneOf(TextStyle.class);
+
+ /**
+ * Creates a block of text with placeholders ("%s") that will be replaced with proper string
+ * representation of given {@link InlineElement}. For example:
+ *
+ * <p>{@code text("This is a text with a link %s", link("https://somepage", "to here"))}
+ *
+ * @param format text with placeholders for elements
+ * @param elements elements to be put in the text
+ * @return block of text
+ */
+ public static TextElement text(String format, InlineElement... elements) {
+ return new TextElement(format, Arrays.asList(elements));
+ }
+
+ /**
+ * Creates a simple block of text.
+ *
+ * @param text a simple block of text
+ * @return block of text
+ */
+ public static TextElement text(String text) {
+ return new TextElement(text, Collections.emptyList());
+ }
+
+ /** Wraps a list of {@link InlineElement}s into a single {@link TextElement}. */
+ public static InlineElement wrap(InlineElement... elements) {
+ return text(Strings.repeat("%s", elements.length), elements);
+ }
+
+ /**
+ * Creates a block of text formatted as code.
+ *
+ * @param text a block of text that will be formatted as code
+ * @return block of text formatted as code
+ */
+ public static TextElement code(String text) {
+ TextElement element = text(text);
+ element.textStyles.add(TextStyle.CODE);
+ return element;
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public List<InlineElement> getElements() {
+ return elements;
+ }
+
+ public EnumSet<TextStyle> getStyles() {
+ return textStyles;
+ }
+
+ private TextElement(String format, List<InlineElement> elements) {
+ this.format = format;
+ this.elements = elements;
+ }
+
+ @Override
+ public void format(Formatter formatter) {
+ formatter.format(this);
+ }
+
+ /** Styles that can be applied to {@link TextElement} e.g. code, bold etc. */
+ public enum TextStyle {
+ CODE
+ }
+}
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/plugin/PluginLoader.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/plugin/PluginLoader.java
index d8af9ec1..753c9ed9 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/plugin/PluginLoader.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/plugin/PluginLoader.java
@@ -18,8 +18,6 @@
package org.apache.flink.table.store.plugin;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.ConfigurationUtils;
import org.apache.flink.table.store.utils.IOUtils;
import org.apache.flink.table.store.utils.LocalFileUtils;
@@ -67,8 +65,7 @@ public class PluginLoader {
public PluginLoader(String jarName) {
try {
ClassLoader ownerClassLoader = PluginLoader.class.getClassLoader();
- Path tmpDirectory =
- Paths.get(ConfigurationUtils.parseTempDirectories(new Configuration())[0]);
+ Path tmpDirectory = Paths.get(System.getProperty("java.io.tmpdir"));
Files.createDirectories(
LocalFileUtils.getTargetPathIfContainsSymbolicPath(tmpDirectory));
Path delegateJar =
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/table/TableType.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/table/TableType.java
index 0e984bd7..f46b55a9 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/table/TableType.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/table/TableType.java
@@ -18,10 +18,10 @@
package org.apache.flink.table.store.table;
-import org.apache.flink.configuration.DescribedEnum;
-import org.apache.flink.configuration.description.InlineElement;
+import org.apache.flink.table.store.options.description.DescribedEnum;
+import org.apache.flink.table.store.options.description.InlineElement;
-import static org.apache.flink.configuration.description.TextElement.text;
+import static org.apache.flink.table.store.options.description.TextElement.text;
/** Enum of catalog table type. */
public enum TableType implements DescribedEnum {
diff --git a/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/DataGenVisitorBase.java b/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/DataGenVisitorBase.java
index a97be0e4..b63f59e9 100644
--- a/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/DataGenVisitorBase.java
+++ b/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/DataGenVisitorBase.java
@@ -18,8 +18,7 @@
package org.apache.flink.table.store.datagen;
-import org.apache.flink.annotation.Internal;
-import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.DataType;
import org.apache.flink.table.store.types.DataTypeDefaultVisitor;
import org.apache.flink.table.store.types.DateType;
@@ -33,14 +32,13 @@ import java.util.function.Supplier;
import static java.time.temporal.ChronoField.MILLI_OF_DAY;
/** Base class for translating {@link DataType} to {@link DataGeneratorContainer}'s. */
-@Internal
public abstract class DataGenVisitorBase extends DataTypeDefaultVisitor<DataGeneratorContainer> {
protected final String name;
- protected final ReadableConfig config;
+ protected final Options config;
- protected DataGenVisitorBase(String name, ReadableConfig config) {
+ protected DataGenVisitorBase(String name, Options config) {
this.name = name;
this.config = config;
}
diff --git a/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/DataGeneratorContainer.java b/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/DataGeneratorContainer.java
index f107ea84..491a9c52 100644
--- a/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/DataGeneratorContainer.java
+++ b/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/DataGeneratorContainer.java
@@ -19,7 +19,7 @@
package org.apache.flink.table.store.datagen;
import org.apache.flink.annotation.Internal;
-import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOption;
import java.util.Arrays;
import java.util.HashSet;
diff --git a/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/RandomGeneratorVisitor.java b/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/RandomGeneratorVisitor.java
index 86eb7e25..eca47d72 100644
--- a/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/RandomGeneratorVisitor.java
+++ b/flink-table-store-common/src/test/java/org/apache/flink/table/store/datagen/RandomGeneratorVisitor.java
@@ -19,14 +19,14 @@
package org.apache.flink.table.store.datagen;
import org.apache.flink.annotation.Internal;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
-import org.apache.flink.configuration.ReadableConfig;
import org.apache.flink.table.store.data.BinaryString;
import org.apache.flink.table.store.data.Decimal;
import org.apache.flink.table.store.data.GenericArray;
import org.apache.flink.table.store.data.GenericMap;
import org.apache.flink.table.store.data.Timestamp;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOptions;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.ArrayType;
import org.apache.flink.table.store.types.BigIntType;
import org.apache.flink.table.store.types.BinaryType;
@@ -59,7 +59,7 @@ import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
-import static org.apache.flink.configuration.ConfigOptions.key;
+import static org.apache.flink.table.store.options.ConfigOptions.key;
/** Creates a random {@link DataGeneratorContainer} for a particular logical type. */
@Internal
@@ -85,7 +85,7 @@ public class RandomGeneratorVisitor extends DataGenVisitorBase {
private final ConfigOptions.OptionBuilder maxPastKey;
- public RandomGeneratorVisitor(String name, ReadableConfig config) {
+ public RandomGeneratorVisitor(String name, Options config) {
super(name, config);
this.minKey = key(FIELDS + "." + name + "." + MIN);
diff --git a/flink-table-store-common/src/test/java/org/apache/flink/table/store/utils/RowDataUtilsTest.java b/flink-table-store-common/src/test/java/org/apache/flink/table/store/utils/RowDataUtilsTest.java
index 157e712a..12bbe8d8 100644
--- a/flink-table-store-common/src/test/java/org/apache/flink/table/store/utils/RowDataUtilsTest.java
+++ b/flink-table-store-common/src/test/java/org/apache/flink/table/store/utils/RowDataUtilsTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.utils;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.data.BinaryRow;
import org.apache.flink.table.store.data.Decimal;
import org.apache.flink.table.store.data.InternalRow;
@@ -27,6 +26,7 @@ import org.apache.flink.table.store.data.serializer.InternalRowSerializer;
import org.apache.flink.table.store.datagen.DataGenerator;
import org.apache.flink.table.store.datagen.RandomGeneratorVisitor;
import org.apache.flink.table.store.datagen.RowDataGenerator;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.DataTypeRoot;
import org.apache.flink.table.store.types.DataTypes;
import org.apache.flink.table.store.types.RowType;
@@ -76,7 +76,7 @@ public class RowDataUtilsTest {
field.type()
.accept(
new RandomGeneratorVisitor(
- field.name(), new Configuration()))
+ field.name(), new Options()))
.getGenerator())
.toArray(DataGenerator[]::new);
this.rowDataGenerator = new RowDataGenerator(generators);
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/AbstractTableStoreFactory.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/AbstractTableStoreFactory.java
index c3819016..0b02cc9d 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/AbstractTableStoreFactory.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/AbstractTableStoreFactory.java
@@ -21,7 +21,6 @@ package org.apache.flink.table.store.connector;
import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.ExecutionOptions;
import org.apache.flink.table.api.ValidationException;
import org.apache.flink.table.catalog.CatalogTable;
@@ -30,7 +29,6 @@ import org.apache.flink.table.connector.source.DynamicTableSource;
import org.apache.flink.table.factories.DynamicTableFactory;
import org.apache.flink.table.factories.DynamicTableSinkFactory;
import org.apache.flink.table.factories.DynamicTableSourceFactory;
-import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.CoreOptions.LogChangelogMode;
import org.apache.flink.table.store.CoreOptions.LogConsistency;
import org.apache.flink.table.store.connector.sink.TableStoreSink;
@@ -40,6 +38,7 @@ import org.apache.flink.table.store.file.schema.TableSchema;
import org.apache.flink.table.store.file.schema.UpdateSchema;
import org.apache.flink.table.store.log.LogStoreTableFactory;
import org.apache.flink.table.store.options.CatalogOptions;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.FileStoreTable;
import org.apache.flink.table.store.table.FileStoreTableFactory;
import org.apache.flink.table.store.utils.Preconditions;
@@ -97,10 +96,7 @@ public abstract class AbstractTableStoreFactory
@Override
public Set<ConfigOption<?>> optionalOptions() {
- Set<ConfigOption<?>> options = new HashSet<>();
- options.addAll(FlinkConnectorOptions.getOptions());
- options.addAll(CoreOptions.getOptions());
- return options;
+ return new HashSet<>();
}
// ~ Tools ------------------------------------------------------------------
@@ -113,7 +109,7 @@ public abstract class AbstractTableStoreFactory
static Optional<LogStoreTableFactory> createOptionalLogStoreFactory(
ClassLoader classLoader, Map<String, String> options) {
- Configuration configOptions = new Configuration();
+ Options configOptions = new Options();
options.forEach(configOptions::setString);
if (configOptions.get(LOG_SYSTEM).equalsIgnoreCase(NONE)) {
@@ -125,7 +121,7 @@ public abstract class AbstractTableStoreFactory
return Optional.of(discoverLogStoreFactory(classLoader, configOptions.get(LOG_SYSTEM)));
}
- private static void validateFileStoreContinuous(Configuration options) {
+ private static void validateFileStoreContinuous(Options options) {
LogChangelogMode changelogMode = options.get(LOG_CHANGELOG_MODE);
if (changelogMode == LogChangelogMode.UPSERT) {
throw new ValidationException(
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/FlinkCatalogFactory.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/FlinkCatalogFactory.java
index 63925407..7d8605cd 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/FlinkCatalogFactory.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/FlinkCatalogFactory.java
@@ -18,11 +18,11 @@
package org.apache.flink.table.store.connector;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
import org.apache.flink.table.store.file.catalog.Catalog;
import org.apache.flink.table.store.file.catalog.CatalogFactory;
import org.apache.flink.table.store.options.CatalogOptions;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOptions;
import java.util.Collections;
import java.util.Set;
@@ -43,12 +43,12 @@ public class FlinkCatalogFactory implements org.apache.flink.table.factories.Cat
}
@Override
- public Set<ConfigOption<?>> requiredOptions() {
+ public Set<org.apache.flink.configuration.ConfigOption<?>> requiredOptions() {
return Collections.emptySet();
}
@Override
- public Set<ConfigOption<?>> optionalOptions() {
+ public Set<org.apache.flink.configuration.ConfigOption<?>> optionalOptions() {
return Collections.emptySet();
}
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/FlinkConnectorOptions.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/FlinkConnectorOptions.java
index 2bf58bac..127269e2 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/FlinkConnectorOptions.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/FlinkConnectorOptions.java
@@ -18,12 +18,10 @@
package org.apache.flink.table.store.connector;
-import org.apache.flink.annotation.Internal;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
-import org.apache.flink.configuration.description.Description;
-import org.apache.flink.configuration.description.TextElement;
-import org.apache.flink.table.factories.FactoryUtil;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOptions;
+import org.apache.flink.table.store.options.description.Description;
+import org.apache.flink.table.store.options.description.TextElement;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -55,7 +53,14 @@ public class FlinkConnectorOptions {
+ " store and kafka, and the streaming read will be read from kafka."))
.build());
- public static final ConfigOption<Integer> SINK_PARALLELISM = FactoryUtil.SINK_PARALLELISM;
+ public static final ConfigOption<Integer> SINK_PARALLELISM =
+ ConfigOptions.key("sink.parallelism")
+ .intType()
+ .noDefaultValue()
+ .withDescription(
+ "Defines a custom parallelism for the sink. "
+ + "By default, if this option is not defined, the planner will derive the parallelism "
+ + "for each statement individually by also considering the global configuration.");
public static final ConfigOption<Integer> SCAN_PARALLELISM =
ConfigOptions.key("scan.parallelism")
@@ -66,7 +71,6 @@ public class FlinkConnectorOptions {
+ "By default, if this option is not defined, the planner will derive the parallelism "
+ "for each statement individually by also considering the global configuration.");
- @Internal
public static List<ConfigOption<?>> getOptions() {
final Field[] fields = FlinkConnectorOptions.class.getFields();
final List<ConfigOption<?>> list = new ArrayList<>(fields.length);
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/RocksDBOptions.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/RocksDBOptions.java
index ee46f416..74d700cc 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/RocksDBOptions.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/RocksDBOptions.java
@@ -18,11 +18,11 @@
package org.apache.flink.table.store.connector;
-import org.apache.flink.annotation.docs.Documentation;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.MemorySize;
-import org.apache.flink.configuration.description.Description;
+import org.apache.flink.table.store.annotation.Documentation;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.MemorySize;
+import org.apache.flink.table.store.options.Options;
+import org.apache.flink.table.store.options.description.Description;
import org.rocksdb.BlockBasedTableConfig;
import org.rocksdb.BloomFilter;
@@ -36,9 +36,9 @@ import org.rocksdb.TableFormatConfig;
import java.io.File;
-import static org.apache.flink.configuration.ConfigOptions.key;
-import static org.apache.flink.configuration.description.LinkElement.link;
-import static org.apache.flink.configuration.description.TextElement.code;
+import static org.apache.flink.table.store.options.ConfigOptions.key;
+import static org.apache.flink.table.store.options.description.LinkElement.link;
+import static org.apache.flink.table.store.options.description.TextElement.code;
import static org.rocksdb.CompactionStyle.FIFO;
import static org.rocksdb.CompactionStyle.LEVEL;
import static org.rocksdb.CompactionStyle.NONE;
@@ -262,7 +262,7 @@ public class RocksDBOptions {
"If true, RocksDB will use block-based filter instead of full filter, this only take effect when bloom filter is used. "
+ "The default value is 'false'.");
- public static DBOptions createDBOptions(DBOptions currentOptions, Configuration options) {
+ public static DBOptions createDBOptions(DBOptions currentOptions, Options options) {
currentOptions.setMaxBackgroundJobs(options.get(MAX_BACKGROUND_THREADS));
currentOptions.setMaxOpenFiles(options.get(MAX_OPEN_FILES));
currentOptions.setInfoLogLevel(options.get(LOG_LEVEL));
@@ -307,7 +307,7 @@ public class RocksDBOptions {
}
public static ColumnFamilyOptions createColumnOptions(
- ColumnFamilyOptions currentOptions, Configuration options) {
+ ColumnFamilyOptions currentOptions, Options options) {
currentOptions.setCompressionType(options.get(COMPRESSION_TYPE));
currentOptions.setCompactionStyle(options.get(COMPACTION_STYLE));
currentOptions.setLevelCompactionDynamicLevelBytes(options.get(USE_DYNAMIC_LEVEL_SIZE));
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/TableStoreConnectorFactory.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/TableStoreConnectorFactory.java
index 4bb7affd..e36c59fb 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/TableStoreConnectorFactory.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/TableStoreConnectorFactory.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.connector;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.catalog.ResolvedCatalogTable;
import org.apache.flink.table.connector.sink.DynamicTableSink;
import org.apache.flink.table.connector.source.DynamicTableSource;
@@ -30,6 +29,7 @@ import org.apache.flink.table.store.file.catalog.CatalogLock;
import org.apache.flink.table.store.file.schema.SchemaManager;
import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.Path;
+import org.apache.flink.table.store.options.Options;
import javax.annotation.Nullable;
@@ -90,7 +90,7 @@ public class TableStoreConnectorFactory extends AbstractTableStoreFactory {
private void createTableIfNeeded(Context context) {
ResolvedCatalogTable table = context.getCatalogTable();
- Configuration options = Configuration.fromMap(table.getOptions());
+ Options options = Options.fromMap(table.getOptions());
if (options.get(AUTO_CREATE)) {
try {
Path tablePath = CoreOptions.path(table.getOptions());
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/lookup/FileStoreLookupFunction.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/lookup/FileStoreLookupFunction.java
index e4d220b3..ac77d254 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/lookup/FileStoreLookupFunction.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/lookup/FileStoreLookupFunction.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.connector.lookup;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.operators.StreamingRuntimeContext;
import org.apache.flink.table.data.GenericRowData;
import org.apache.flink.table.functions.FunctionContext;
@@ -30,6 +29,7 @@ import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.file.predicate.Predicate;
import org.apache.flink.table.store.file.predicate.PredicateFilter;
import org.apache.flink.table.store.file.schema.TableSchema;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.FileStoreTable;
import org.apache.flink.table.store.table.source.TableStreamingReader;
import org.apache.flink.table.store.table.source.snapshot.ContinuousDataFileSnapshotEnumerator;
@@ -119,7 +119,7 @@ public class FileStoreLookupFunction extends TableFunction<org.apache.flink.tabl
String tmpDirectory = getTmpDirectory(context);
this.path = new File(tmpDirectory, "lookup-" + UUID.randomUUID());
- Configuration options = Configuration.fromMap(table.schema().options());
+ Options options = Options.fromMap(table.schema().options());
this.refreshInterval = options.get(CoreOptions.CONTINUOUS_DISCOVERY_INTERVAL);
this.stateFactory = new RocksDBStateFactory(path.toString(), options);
@@ -135,7 +135,7 @@ public class FileStoreLookupFunction extends TableFunction<org.apache.flink.tabl
table.schema().primaryKeys(),
joinKeys,
recordFilter,
- options.getLong(LOOKUP_CACHE_ROWS));
+ options.get(LOOKUP_CACHE_ROWS));
this.nextLoadTime = -1;
this.streamingReader = new TableStreamingReader(table, projection, this.predicate);
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/lookup/RocksDBStateFactory.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/lookup/RocksDBStateFactory.java
index b7cb31dc..bd23d027 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/lookup/RocksDBStateFactory.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/lookup/RocksDBStateFactory.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.connector.lookup;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.connector.RocksDBOptions;
import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.data.serializer.Serializer;
@@ -42,7 +41,8 @@ public class RocksDBStateFactory implements Closeable {
private final ColumnFamilyOptions columnFamilyOptions;
- public RocksDBStateFactory(String path, Configuration conf) throws IOException {
+ public RocksDBStateFactory(String path, org.apache.flink.table.store.options.Options conf)
+ throws IOException {
DBOptions dbOptions =
RocksDBOptions.createDBOptions(
new DBOptions()
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/TableStoreSink.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/TableStoreSink.java
index 4abf0ee6..156476e0 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/TableStoreSink.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/TableStoreSink.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.connector.sink;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.connector.ChangelogMode;
@@ -35,6 +34,7 @@ import org.apache.flink.table.store.file.catalog.CatalogLock;
import org.apache.flink.table.store.file.operation.Lock;
import org.apache.flink.table.store.log.LogSinkProvider;
import org.apache.flink.table.store.log.LogStoreTableFactory;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.AppendOnlyFileStoreTable;
import org.apache.flink.table.store.table.ChangelogValueCountFileStoreTable;
import org.apache.flink.table.store.table.ChangelogWithKeyFileStoreTable;
@@ -83,7 +83,7 @@ public class TableStoreSink implements DynamicTableSink, SupportsOverwrite, Supp
// no primary key, sink all changelogs
return requestedMode;
} else if (table instanceof ChangelogWithKeyFileStoreTable) {
- Configuration options = Configuration.fromMap(table.schema().options());
+ Options options = Options.fromMap(table.schema().options());
if (options.get(CHANGELOG_PRODUCER) == ChangelogProducer.INPUT) {
return requestedMode;
}
@@ -118,7 +118,7 @@ public class TableStoreSink implements DynamicTableSink, SupportsOverwrite, Supp
logSinkProvider = logStoreTableFactory.createSinkProvider(this.context, context);
}
- Configuration conf = Configuration.fromMap(table.schema().options());
+ Options conf = Options.fromMap(table.schema().options());
// Do not sink to log store when overwrite mode
final LogSinkFunction logSinkFunction =
overwrite ? null : (logSinkProvider == null ? null : logSinkProvider.createSink());
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/source/FlinkSourceBuilder.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/source/FlinkSourceBuilder.java
index f2dd44c1..1018c001 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/source/FlinkSourceBuilder.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/source/FlinkSourceBuilder.java
@@ -21,7 +21,6 @@ package org.apache.flink.table.store.connector.source;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.api.connector.source.Boundedness;
import org.apache.flink.api.connector.source.Source;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.connector.base.source.hybrid.HybridSource;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -33,6 +32,7 @@ import org.apache.flink.table.store.CoreOptions.StartupMode;
import org.apache.flink.table.store.connector.Projection;
import org.apache.flink.table.store.file.predicate.Predicate;
import org.apache.flink.table.store.log.LogSourceProvider;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.FileStoreTable;
import org.apache.flink.table.store.table.source.snapshot.ContinuousDataFileSnapshotEnumerator;
import org.apache.flink.table.types.logical.LogicalType;
@@ -52,7 +52,7 @@ public class FlinkSourceBuilder {
private final ObjectIdentifier tableIdentifier;
private final FileStoreTable table;
- private final Configuration conf;
+ private final Options conf;
private boolean isContinuous = false;
private StreamExecutionEnvironment env;
@@ -66,7 +66,7 @@ public class FlinkSourceBuilder {
public FlinkSourceBuilder(ObjectIdentifier tableIdentifier, FileStoreTable table) {
this.tableIdentifier = tableIdentifier;
this.table = table;
- this.conf = Configuration.fromMap(table.schema().options());
+ this.conf = Options.fromMap(table.schema().options());
}
public FlinkSourceBuilder withContinuousMode(boolean isContinuous) {
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/source/TableStoreSource.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/source/TableStoreSource.java
index 77d7b460..b120cec7 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/source/TableStoreSource.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/source/TableStoreSource.java
@@ -19,7 +19,6 @@
package org.apache.flink.table.store.connector.source;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.connector.ChangelogMode;
import org.apache.flink.table.connector.source.DynamicTableSource;
@@ -37,6 +36,7 @@ import org.apache.flink.table.store.connector.lookup.FileStoreLookupFunction;
import org.apache.flink.table.store.file.predicate.Predicate;
import org.apache.flink.table.store.log.LogSourceProvider;
import org.apache.flink.table.store.log.LogStoreTableFactory;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.AppendOnlyFileStoreTable;
import org.apache.flink.table.store.table.ChangelogValueCountFileStoreTable;
import org.apache.flink.table.store.table.ChangelogWithKeyFileStoreTable;
@@ -122,7 +122,7 @@ public class TableStoreSource extends FlinkTableSource
} else if (table instanceof ChangelogValueCountFileStoreTable) {
return ChangelogMode.all();
} else if (table instanceof ChangelogWithKeyFileStoreTable) {
- Configuration options = Configuration.fromMap(table.schema().options());
+ Options options = Options.fromMap(table.schema().options());
if (options.get(LOG_SCAN_REMOVE_NORMALIZE)) {
return ChangelogMode.all();
@@ -163,7 +163,7 @@ public class TableStoreSource extends FlinkTableSource
.withPredicate(predicate)
.withLimit(limit)
.withParallelism(
- Configuration.fromMap(table.schema().options())
+ Options.fromMap(table.schema().options())
.get(FlinkConnectorOptions.SCAN_PARALLELISM))
.withWatermarkStrategy(watermarkStrategy);
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/kafka/KafkaLogOptions.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/kafka/KafkaLogOptions.java
index e7259f92..3f5c8e00 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/kafka/KafkaLogOptions.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/kafka/KafkaLogOptions.java
@@ -18,8 +18,8 @@
package org.apache.flink.table.store.kafka;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOptions;
/** Options for kafka log. */
public class KafkaLogOptions {
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/kafka/KafkaLogStoreFactory.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/kafka/KafkaLogStoreFactory.java
index cd577a94..bdea7f9b 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/kafka/KafkaLogStoreFactory.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/kafka/KafkaLogStoreFactory.java
@@ -31,6 +31,7 @@ import org.apache.flink.table.data.RowData;
import org.apache.flink.table.factories.FactoryUtil;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.log.LogStoreTableFactory;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.types.DataType;
import org.apache.flink.table.types.utils.DataTypeUtils;
@@ -47,7 +48,6 @@ import static org.apache.flink.table.store.CoreOptions.LOG_CHANGELOG_MODE;
import static org.apache.flink.table.store.CoreOptions.LOG_CONSISTENCY;
import static org.apache.flink.table.store.CoreOptions.LogConsistency;
import static org.apache.flink.table.store.CoreOptions.SCAN_TIMESTAMP_MILLIS;
-import static org.apache.flink.table.store.kafka.KafkaLogOptions.BOOTSTRAP_SERVERS;
import static org.apache.flink.table.store.kafka.KafkaLogOptions.TOPIC;
import static org.apache.kafka.clients.consumer.ConsumerConfig.ISOLATION_LEVEL_CONFIG;
@@ -65,9 +65,7 @@ public class KafkaLogStoreFactory implements LogStoreTableFactory {
@Override
public Set<ConfigOption<?>> requiredOptions() {
- Set<ConfigOption<?>> options = new HashSet<>();
- options.add(BOOTSTRAP_SERVERS);
- return options;
+ return new HashSet<>();
}
@Override
@@ -98,18 +96,19 @@ public class KafkaLogStoreFactory implements LogStoreTableFactory {
DeserializationSchema<RowData> valueDeserializer =
LogStoreTableFactory.getValueDecodingFormat(helper)
.createRuntimeDecoder(sourceContext, physicalType);
+ Options options = toOptions(helper.getOptions());
return new KafkaLogSourceProvider(
topic(context),
- toKafkaProperties(helper.getOptions()),
+ toKafkaProperties(options),
physicalType,
primaryKey,
primaryKeyDeserializer,
valueDeserializer,
projectFields,
- helper.getOptions().get(LOG_CONSISTENCY),
+ options.get(LOG_CONSISTENCY),
// TODO visit all options through CoreOptions
- CoreOptions.startupMode(helper.getOptions()),
- helper.getOptions().get(SCAN_TIMESTAMP_MILLIS));
+ CoreOptions.startupMode(options),
+ options.get(SCAN_TIMESTAMP_MILLIS));
}
@Override
@@ -129,13 +128,14 @@ public class KafkaLogStoreFactory implements LogStoreTableFactory {
SerializationSchema<RowData> valueSerializer =
LogStoreTableFactory.getValueEncodingFormat(helper)
.createRuntimeEncoder(sinkContext, physicalType);
+ Options options = toOptions(helper.getOptions());
return new KafkaLogSinkProvider(
topic(context),
- toKafkaProperties(helper.getOptions()),
+ toKafkaProperties(options),
primaryKeySerializer,
valueSerializer,
- helper.getOptions().get(LOG_CONSISTENCY),
- helper.getOptions().get(LOG_CHANGELOG_MODE));
+ options.get(LOG_CONSISTENCY),
+ options.get(LOG_CHANGELOG_MODE));
}
private int[] getPrimaryKeyIndexes(ResolvedSchema schema) {
@@ -146,9 +146,9 @@ public class KafkaLogStoreFactory implements LogStoreTableFactory {
.orElseGet(() -> new int[] {});
}
- public static Properties toKafkaProperties(ReadableConfig options) {
+ public static Properties toKafkaProperties(Options options) {
Properties properties = new Properties();
- Map<String, String> optionMap = ((Configuration) options).toMap();
+ Map<String, String> optionMap = options.toMap();
optionMap.keySet().stream()
.filter(key -> key.startsWith(KAFKA_PREFIX))
.forEach(
@@ -163,4 +163,10 @@ public class KafkaLogStoreFactory implements LogStoreTableFactory {
}
return properties;
}
+
+ private Options toOptions(ReadableConfig config) {
+ Options options = new Options();
+ ((Configuration) config).toMap().forEach(options::setString);
+ return options;
+ }
}
diff --git a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/log/LogStoreTableFactory.java b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/log/LogStoreTableFactory.java
index 21b2ce08..0e26efb2 100644
--- a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/log/LogStoreTableFactory.java
+++ b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/log/LogStoreTableFactory.java
@@ -20,6 +20,8 @@ package org.apache.flink.table.store.log;
import org.apache.flink.api.common.serialization.DeserializationSchema;
import org.apache.flink.api.common.serialization.SerializationSchema;
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.configuration.ConfigOptions;
import org.apache.flink.table.api.ValidationException;
import org.apache.flink.table.catalog.CatalogTable;
import org.apache.flink.table.connector.ChangelogMode;
@@ -67,6 +69,18 @@ public interface LogStoreTableFactory extends DynamicTableFactory {
// --------------------------------------------------------------------------------------------
+ static ConfigOption<String> logKeyFormat() {
+ return ConfigOptions.key(LOG_KEY_FORMAT.key())
+ .stringType()
+ .defaultValue(LOG_KEY_FORMAT.defaultValue());
+ }
+
+ static ConfigOption<String> logFormat() {
+ return ConfigOptions.key(LOG_FORMAT.key())
+ .stringType()
+ .defaultValue(LOG_FORMAT.defaultValue());
+ }
+
static LogStoreTableFactory discoverLogStoreFactory(ClassLoader cl, String identifier) {
return FactoryUtil.discoverFactory(cl, LogStoreTableFactory.class, identifier);
}
@@ -74,32 +88,32 @@ public interface LogStoreTableFactory extends DynamicTableFactory {
static DecodingFormat<DeserializationSchema<RowData>> getKeyDecodingFormat(
TableFactoryHelper helper) {
DecodingFormat<DeserializationSchema<RowData>> format =
- helper.discoverDecodingFormat(DeserializationFormatFactory.class, LOG_KEY_FORMAT);
- validateKeyFormat(format, helper.getOptions().get(LOG_KEY_FORMAT));
+ helper.discoverDecodingFormat(DeserializationFormatFactory.class, logKeyFormat());
+ validateKeyFormat(format, helper.getOptions().get(logKeyFormat()));
return format;
}
static EncodingFormat<SerializationSchema<RowData>> getKeyEncodingFormat(
TableFactoryHelper helper) {
EncodingFormat<SerializationSchema<RowData>> format =
- helper.discoverEncodingFormat(SerializationFormatFactory.class, LOG_KEY_FORMAT);
- validateKeyFormat(format, helper.getOptions().get(LOG_KEY_FORMAT));
+ helper.discoverEncodingFormat(SerializationFormatFactory.class, logKeyFormat());
+ validateKeyFormat(format, helper.getOptions().get(logKeyFormat()));
return format;
}
static DecodingFormat<DeserializationSchema<RowData>> getValueDecodingFormat(
TableFactoryHelper helper) {
DecodingFormat<DeserializationSchema<RowData>> format =
- helper.discoverDecodingFormat(DeserializationFormatFactory.class, LOG_FORMAT);
- validateValueFormat(format, helper.getOptions().get(LOG_FORMAT));
+ helper.discoverDecodingFormat(DeserializationFormatFactory.class, logFormat());
+ validateValueFormat(format, helper.getOptions().get(logFormat()));
return format;
}
static EncodingFormat<SerializationSchema<RowData>> getValueEncodingFormat(
TableFactoryHelper helper) {
EncodingFormat<SerializationSchema<RowData>> format =
- helper.discoverEncodingFormat(SerializationFormatFactory.class, LOG_FORMAT);
- validateValueFormat(format, helper.getOptions().get(LOG_FORMAT));
+ helper.discoverEncodingFormat(SerializationFormatFactory.class, logFormat());
+ validateValueFormat(format, helper.getOptions().get(logFormat()));
return format;
}
diff --git a/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/ChangelogModeTest.java b/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/ChangelogModeTest.java
index e4f122c3..6cdc5888 100644
--- a/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/ChangelogModeTest.java
+++ b/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/ChangelogModeTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.connector;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.connector.ChangelogMode;
import org.apache.flink.table.store.CoreOptions;
@@ -30,6 +29,7 @@ import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
import org.apache.flink.table.store.kafka.KafkaLogStoreFactory;
import org.apache.flink.table.store.log.LogStoreTableFactory;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.FileStoreTable;
import org.apache.flink.table.store.table.FileStoreTableFactory;
import org.apache.flink.table.store.types.IntType;
@@ -59,13 +59,13 @@ public class ChangelogModeTest {
path = new Path(temp.toUri().toString());
}
- private void test(Configuration options, ChangelogMode expectSource, ChangelogMode expectSink)
+ private void test(Options options, ChangelogMode expectSource, ChangelogMode expectSink)
throws Exception {
test(options, expectSource, expectSink, null);
}
private void test(
- Configuration options,
+ Options options,
ChangelogMode expectSource,
ChangelogMode expectSink,
@Nullable LogStoreTableFactory logStoreTableFactory)
@@ -90,26 +90,26 @@ public class ChangelogModeTest {
@Test
public void testDefault() throws Exception {
- test(new Configuration(), ChangelogMode.upsert(), ChangelogMode.upsert());
+ test(new Options(), ChangelogMode.upsert(), ChangelogMode.upsert());
}
@Test
public void testInputChangelogProducer() throws Exception {
- Configuration options = new Configuration();
+ Options options = new Options();
options.set(CoreOptions.CHANGELOG_PRODUCER, CoreOptions.ChangelogProducer.INPUT);
test(options, ChangelogMode.all(), ChangelogMode.all());
}
@Test
public void testChangelogModeAll() throws Exception {
- Configuration options = new Configuration();
+ Options options = new Options();
options.set(CoreOptions.LOG_CHANGELOG_MODE, CoreOptions.LogChangelogMode.ALL);
test(options, ChangelogMode.all(), ChangelogMode.all());
}
@Test
public void testInputChangelogProducerWithLog() throws Exception {
- Configuration options = new Configuration();
+ Options options = new Options();
options.set(CoreOptions.CHANGELOG_PRODUCER, CoreOptions.ChangelogProducer.INPUT);
test(options, ChangelogMode.upsert(), ChangelogMode.all(), new KafkaLogStoreFactory());
}
diff --git a/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/ForceCompactionITCase.java b/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/ForceCompactionITCase.java
index 20942356..1e4e308f 100644
--- a/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/ForceCompactionITCase.java
+++ b/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/ForceCompactionITCase.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.connector;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.file.Snapshot;
import org.apache.flink.table.store.file.manifest.ManifestFileMeta;
@@ -27,6 +26,7 @@ import org.apache.flink.table.store.file.stats.BinaryTableStats;
import org.apache.flink.table.store.file.utils.FileStorePathFactory;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.DataType;
import org.apache.flink.table.store.types.RowType;
import org.apache.flink.table.store.types.VarCharType;
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/** ITCase for auto-enabling commit.force-compact under batch mode. */
public class ForceCompactionITCase extends CatalogITCaseBase {
- private final FileFormat avro = FileFormat.fromIdentifier("avro", new Configuration());
+ private final FileFormat avro = FileFormat.fromIdentifier("avro", new Options());
@Override
protected List<String> ddl() {
diff --git a/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/lookup/LookupTableTest.java b/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/lookup/LookupTableTest.java
index 56aa64ab..9bae2205 100644
--- a/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/lookup/LookupTableTest.java
+++ b/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/lookup/LookupTableTest.java
@@ -18,9 +18,9 @@
package org.apache.flink.table.store.connector.lookup;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.data.GenericRow;
import org.apache.flink.table.store.data.InternalRow;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.IntType;
import org.apache.flink.table.store.types.RowKind;
import org.apache.flink.table.store.types.RowType;
@@ -49,7 +49,7 @@ public class LookupTableTest {
@BeforeEach
public void before() throws IOException {
- this.stateFactory = new RocksDBStateFactory(tempDir.toString(), new Configuration());
+ this.stateFactory = new RocksDBStateFactory(tempDir.toString(), new Options());
this.rowType = RowType.of(new IntType(), new IntType(), new IntType());
}
diff --git a/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/source/TestChangelogDataReadWrite.java b/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/source/TestChangelogDataReadWrite.java
index 97c412ea..0570035d 100644
--- a/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/source/TestChangelogDataReadWrite.java
+++ b/flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/source/TestChangelogDataReadWrite.java
@@ -19,7 +19,6 @@
package org.apache.flink.table.store.connector.source;
import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.data.BinaryRow;
import org.apache.flink.table.store.data.GenericRow;
@@ -42,6 +41,7 @@ import org.apache.flink.table.store.file.utils.SnapshotManager;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.source.KeyValueTableRead;
import org.apache.flink.table.store.table.source.TableRead;
import org.apache.flink.table.store.table.source.ValueContentRowDataRecordIterator;
@@ -101,7 +101,7 @@ public class TestChangelogDataReadWrite {
private final String commitUser;
public TestChangelogDataReadWrite(String root, ExecutorService service) {
- this.avro = FileFormat.fromIdentifier("avro", new Configuration());
+ this.avro = FileFormat.fromIdentifier("avro", new Options());
this.tablePath = new Path(root);
this.pathFactory =
new FileStorePathFactory(
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/CoreOptions.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/CoreOptions.java
index fb01c4a3..5e7ff1cb 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/CoreOptions.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/CoreOptions.java
@@ -18,28 +18,21 @@
package org.apache.flink.table.store;
-import org.apache.flink.annotation.Internal;
-import org.apache.flink.annotation.docs.Documentation;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.DescribedEnum;
-import org.apache.flink.configuration.MemorySize;
-import org.apache.flink.configuration.ReadableConfig;
-import org.apache.flink.configuration.description.Description;
-import org.apache.flink.configuration.description.InlineElement;
+import org.apache.flink.table.store.annotation.Documentation.ExcludeFromDocumentation;
+import org.apache.flink.table.store.annotation.Documentation.Immutable;
import org.apache.flink.table.store.file.WriteMode;
import org.apache.flink.table.store.file.schema.TableSchema;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.fs.Path;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.MemorySize;
import org.apache.flink.table.store.options.Options;
+import org.apache.flink.table.store.options.description.DescribedEnum;
+import org.apache.flink.table.store.options.description.Description;
+import org.apache.flink.table.store.options.description.InlineElement;
import org.apache.flink.table.store.utils.Preconditions;
import java.io.Serializable;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.time.Duration;
import java.util.ArrayList;
@@ -50,25 +43,25 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-import static org.apache.flink.configuration.ConfigOptions.key;
-import static org.apache.flink.configuration.description.TextElement.text;
import static org.apache.flink.table.store.file.WriteMode.APPEND_ONLY;
import static org.apache.flink.table.store.file.schema.TableSchema.KEY_FIELD_PREFIX;
import static org.apache.flink.table.store.file.schema.TableSchema.SYSTEM_FIELD_NAMES;
+import static org.apache.flink.table.store.options.ConfigOptions.key;
+import static org.apache.flink.table.store.options.description.TextElement.text;
import static org.apache.flink.table.store.utils.Preconditions.checkState;
/** Core options for table store. */
public class CoreOptions implements Serializable {
public static final ConfigOption<Integer> BUCKET =
- ConfigOptions.key("bucket")
+ key("bucket")
.intType()
.defaultValue(1)
.withDescription("Bucket number for file store.");
@Immutable
public static final ConfigOption<String> BUCKET_KEY =
- ConfigOptions.key("bucket-key")
+ key("bucket-key")
.stringType()
.noDefaultValue()
.withDescription(
@@ -84,48 +77,47 @@ public class CoreOptions implements Serializable {
+ "if there is no primary key, the full row will be used.")
.build());
- @Internal
- @Documentation.ExcludeFromDocumentation("Internal use only")
+ @ExcludeFromDocumentation("Internal use only")
public static final ConfigOption<String> PATH =
- ConfigOptions.key("path")
+ key("path")
.stringType()
.noDefaultValue()
.withDescription("The file path of this table in the filesystem.");
public static final ConfigOption<String> FILE_FORMAT =
- ConfigOptions.key("file.format")
+ key("file.format")
.stringType()
.defaultValue("orc")
.withDescription("Specify the message format of data files.");
public static final ConfigOption<String> ORC_BLOOM_FILTER_COLUMNS =
- ConfigOptions.key("orc.bloom.filter.columns")
+ key("orc.bloom.filter.columns")
.stringType()
.noDefaultValue()
.withDescription(
"A comma-separated list of columns for which to create a bloon filter when writing.");
public static final ConfigOption<Double> ORC_BLOOM_FILTER_FPP =
- ConfigOptions.key("orc.bloom.filter.fpp")
+ key("orc.bloom.filter.fpp")
.doubleType()
.defaultValue(0.05)
.withDescription(
"Define the default false positive probability for bloom filters.");
public static final ConfigOption<String> MANIFEST_FORMAT =
- ConfigOptions.key("manifest.format")
+ key("manifest.format")
.stringType()
.defaultValue("avro")
.withDescription("Specify the message format of manifest files.");
public static final ConfigOption<MemorySize> MANIFEST_TARGET_FILE_SIZE =
- ConfigOptions.key("manifest.target-file-size")
+ key("manifest.target-file-size")
.memoryType()
.defaultValue(MemorySize.ofMebiBytes(8))
.withDescription("Suggested file size of a manifest file.");
public static final ConfigOption<Integer> MANIFEST_MERGE_MIN_COUNT =
- ConfigOptions.key("manifest.merge-min-count")
+ key("manifest.merge-min-count")
.intType()
.defaultValue(30)
.withDescription(
@@ -141,51 +133,51 @@ public class CoreOptions implements Serializable {
+ " column value is null/empty string.");
public static final ConfigOption<Integer> SNAPSHOT_NUM_RETAINED_MIN =
- ConfigOptions.key("snapshot.num-retained.min")
+ key("snapshot.num-retained.min")
.intType()
.defaultValue(10)
.withDescription("The minimum number of completed snapshots to retain.");
public static final ConfigOption<Integer> SNAPSHOT_NUM_RETAINED_MAX =
- ConfigOptions.key("snapshot.num-retained.max")
+ key("snapshot.num-retained.max")
.intType()
.defaultValue(Integer.MAX_VALUE)
.withDescription("The maximum number of completed snapshots to retain.");
public static final ConfigOption<Duration> SNAPSHOT_TIME_RETAINED =
- ConfigOptions.key("snapshot.time-retained")
+ key("snapshot.time-retained")
.durationType()
.defaultValue(Duration.ofHours(1))
.withDescription("The maximum time of completed snapshots to retain.");
public static final ConfigOption<Duration> CONTINUOUS_DISCOVERY_INTERVAL =
- ConfigOptions.key("continuous.discovery-interval")
+ key("continuous.discovery-interval")
.durationType()
.defaultValue(Duration.ofSeconds(1))
.withDescription("The discovery interval of continuous reading.");
@Immutable
public static final ConfigOption<MergeEngine> MERGE_ENGINE =
- ConfigOptions.key("merge-engine")
+ key("merge-engine")
.enumType(MergeEngine.class)
.defaultValue(MergeEngine.DEDUPLICATE)
.withDescription("Specify the merge engine for table with primary key.");
public static final ConfigOption<Boolean> PARTIAL_UPDATE_IGNORE_DELETE =
- ConfigOptions.key("partial-update.ignore-delete")
+ key("partial-update.ignore-delete")
.booleanType()
.defaultValue(false)
.withDescription("Whether to ignore delete records in partial-update mode.");
@Immutable
public static final ConfigOption<WriteMode> WRITE_MODE =
- ConfigOptions.key("write-mode")
+ key("write-mode")
.enumType(WriteMode.class)
.defaultValue(WriteMode.CHANGE_LOG)
.withDescription("Specify the write mode for table.");
public static final ConfigOption<Boolean> WRITE_ONLY =
- ConfigOptions.key("write-only")
+ key("write-only")
.booleanType()
.defaultValue(false)
.withDeprecatedKeys("write.compaction-skip")
@@ -194,13 +186,13 @@ public class CoreOptions implements Serializable {
+ "This option is used along with dedicated compact jobs.");
public static final ConfigOption<MemorySize> SOURCE_SPLIT_TARGET_SIZE =
- ConfigOptions.key("source.split.target-size")
+ key("source.split.target-size")
.memoryType()
.defaultValue(MemorySize.ofMebiBytes(128))
.withDescription("Target size of a source split when scanning a bucket.");
public static final ConfigOption<MemorySize> SOURCE_SPLIT_OPEN_FILE_COST =
- ConfigOptions.key("source.split.open-file-cost")
+ key("source.split.open-file-cost")
.memoryType()
.defaultValue(MemorySize.ofMebiBytes(4))
.withDescription(
@@ -208,21 +200,21 @@ public class CoreOptions implements Serializable {
+ " too many files with a source split, which can be very slow.");
public static final ConfigOption<MemorySize> WRITE_BUFFER_SIZE =
- ConfigOptions.key("write-buffer-size")
+ key("write-buffer-size")
.memoryType()
.defaultValue(MemorySize.parse("256 mb"))
.withDescription(
"Amount of data to build up in memory before converting to a sorted on-disk file.");
public static final ConfigOption<Boolean> WRITE_BUFFER_SPILLABLE =
- ConfigOptions.key("write-buffer-spillable")
+ key("write-buffer-spillable")
.booleanType()
.noDefaultValue()
.withDescription(
"Whether the write buffer can be spillable. Enabled by default when using object storage.");
public static final ConfigOption<Integer> LOCAL_SORT_MAX_NUM_FILE_HANDLES =
- ConfigOptions.key("local-sort.max-num-file-handles")
+ key("local-sort.max-num-file-handles")
.intType()
.defaultValue(128)
.withDescription(
@@ -231,19 +223,19 @@ public class CoreOptions implements Serializable {
+ "it will cause too many files opened at the same time, consume memory and lead to random reading.");
public static final ConfigOption<MemorySize> PAGE_SIZE =
- ConfigOptions.key("page-size")
+ key("page-size")
.memoryType()
.defaultValue(MemorySize.parse("64 kb"))
.withDescription("Memory page size.");
public static final ConfigOption<MemorySize> TARGET_FILE_SIZE =
- ConfigOptions.key("target-file-size")
+ key("target-file-size")
.memoryType()
.defaultValue(MemorySize.ofMebiBytes(128))
.withDescription("Target size of a file.");
public static final ConfigOption<Integer> NUM_SORTED_RUNS_COMPACTION_TRIGGER =
- ConfigOptions.key("num-sorted-run.compaction-trigger")
+ key("num-sorted-run.compaction-trigger")
.intType()
.defaultValue(5)
.withDescription(
@@ -251,7 +243,7 @@ public class CoreOptions implements Serializable {
+ "high-level runs (one level one sorted run).");
public static final ConfigOption<Integer> NUM_SORTED_RUNS_STOP_TRIGGER =
- ConfigOptions.key("num-sorted-run.stop-trigger")
+ key("num-sorted-run.stop-trigger")
.intType()
.noDefaultValue()
.withDescription(
@@ -259,20 +251,20 @@ public class CoreOptions implements Serializable {
+ " the default value is 'num-sorted-run.compaction-trigger' + 1.");
public static final ConfigOption<Integer> NUM_LEVELS =
- ConfigOptions.key("num-levels")
+ key("num-levels")
.intType()
.noDefaultValue()
.withDescription(
"Total level number, for example, there are 3 levels, including 0,1,2 levels.");
public static final ConfigOption<Boolean> COMMIT_FORCE_COMPACT =
- ConfigOptions.key("commit.force-compact")
+ key("commit.force-compact")
.booleanType()
.defaultValue(false)
.withDescription("Whether to force a compaction before commit.");
public static final ConfigOption<Integer> COMPACTION_MAX_SIZE_AMPLIFICATION_PERCENT =
- ConfigOptions.key("compaction.max-size-amplification-percent")
+ key("compaction.max-size-amplification-percent")
.intType()
.defaultValue(200)
.withDescription(
@@ -280,7 +272,7 @@ public class CoreOptions implements Serializable {
+ "needed to store a single byte of data in the merge tree for changelog mode table.");
public static final ConfigOption<Integer> COMPACTION_SIZE_RATIO =
- ConfigOptions.key("compaction.size-ratio")
+ key("compaction.size-ratio")
.intType()
.defaultValue(1)
.withDescription(
@@ -289,7 +281,7 @@ public class CoreOptions implements Serializable {
+ "into this candidate set.");
public static final ConfigOption<Integer> COMPACTION_MIN_FILE_NUM =
- ConfigOptions.key("compaction.min.file-num")
+ key("compaction.min.file-num")
.intType()
.defaultValue(5)
.withDescription(
@@ -299,7 +291,7 @@ public class CoreOptions implements Serializable {
+ "which is not cost-effective.");
public static final ConfigOption<Integer> COMPACTION_MAX_FILE_NUM =
- ConfigOptions.key("compaction.early-max.file-num")
+ key("compaction.early-max.file-num")
.intType()
.defaultValue(50)
.withDescription(
@@ -308,7 +300,7 @@ public class CoreOptions implements Serializable {
+ "avoids pending too much small files, which slows down the performance.");
public static final ConfigOption<Integer> COMPACTION_MAX_SORTED_RUN_NUM =
- ConfigOptions.key("compaction.max-sorted-run-num")
+ key("compaction.max-sorted-run-num")
.intType()
.defaultValue(Integer.MAX_VALUE)
.withDescription(
@@ -317,7 +309,7 @@ public class CoreOptions implements Serializable {
+ "which may lead to OutOfMemoryError.");
public static final ConfigOption<ChangelogProducer> CHANGELOG_PRODUCER =
- ConfigOptions.key("changelog-producer")
+ key("changelog-producer")
.enumType(ChangelogProducer.class)
.defaultValue(ChangelogProducer.NONE)
.withDescription(
@@ -326,7 +318,7 @@ public class CoreOptions implements Serializable {
+ "it can be read directly during stream reads.");
public static final ConfigOption<Duration> CHANGELOG_PRODUCER_FULL_COMPACTION_TRIGGER_INTERVAL =
- ConfigOptions.key("changelog-producer.compaction-interval")
+ key("changelog-producer.compaction-interval")
.durationType()
.defaultValue(Duration.ofMinutes(30))
.withDescription(
@@ -338,7 +330,7 @@ public class CoreOptions implements Serializable {
@Immutable
public static final ConfigOption<String> SEQUENCE_FIELD =
- ConfigOptions.key("sequence.field")
+ key("sequence.field")
.stringType()
.noDefaultValue()
.withDescription(
@@ -346,14 +338,14 @@ public class CoreOptions implements Serializable {
+ " the sequence number determines which data is the most recent.");
public static final ConfigOption<StartupMode> SCAN_MODE =
- ConfigOptions.key("scan.mode")
+ key("scan.mode")
.enumType(StartupMode.class)
.defaultValue(StartupMode.DEFAULT)
.withDeprecatedKeys("log.scan")
.withDescription("Specify the scanning behavior of the source.");
public static final ConfigOption<Long> SCAN_TIMESTAMP_MILLIS =
- ConfigOptions.key("scan.timestamp-millis")
+ key("scan.timestamp-millis")
.longType()
.noDefaultValue()
.withDeprecatedKeys("log.scan.timestamp-millis")
@@ -361,33 +353,33 @@ public class CoreOptions implements Serializable {
"Optional timestamp used in case of \"from-timestamp\" scan mode.");
public static final ConfigOption<Long> SCAN_SNAPSHOT_ID =
- ConfigOptions.key("scan.snapshot-id")
+ key("scan.snapshot-id")
.longType()
.noDefaultValue()
.withDescription(
"Optional snapshot id used in case of \"from-snapshot\" scan mode");
public static final ConfigOption<Duration> LOG_RETENTION =
- ConfigOptions.key("log.retention")
+ key("log.retention")
.durationType()
.noDefaultValue()
.withDescription(
"It means how long changes log will be kept. The default value is from the log system cluster.");
public static final ConfigOption<LogConsistency> LOG_CONSISTENCY =
- ConfigOptions.key("log.consistency")
+ key("log.consistency")
.enumType(LogConsistency.class)
.defaultValue(LogConsistency.TRANSACTIONAL)
.withDescription("Specify the log consistency mode for table.");
public static final ConfigOption<LogChangelogMode> LOG_CHANGELOG_MODE =
- ConfigOptions.key("log.changelog-mode")
+ key("log.changelog-mode")
.enumType(LogChangelogMode.class)
.defaultValue(LogChangelogMode.AUTO)
.withDescription("Specify the log changelog mode for table.");
public static final ConfigOption<Boolean> LOG_SCAN_REMOVE_NORMALIZE =
- ConfigOptions.key("log.scan.remove-normalize")
+ key("log.scan.remove-normalize")
.booleanType()
.defaultValue(false)
.withDescription(
@@ -396,27 +388,27 @@ public class CoreOptions implements Serializable {
+ " is used to calculate aggregation and the input is not complete changelog.");
public static final ConfigOption<String> LOG_KEY_FORMAT =
- ConfigOptions.key("log.key.format")
+ key("log.key.format")
.stringType()
.defaultValue("json")
.withDescription(
"Specify the key message format of log system with primary key.");
public static final ConfigOption<String> LOG_FORMAT =
- ConfigOptions.key("log.format")
+ key("log.format")
.stringType()
.defaultValue("debezium-json")
.withDescription("Specify the message format of log system.");
public static final ConfigOption<Boolean> AUTO_CREATE =
- ConfigOptions.key("auto-create")
+ key("auto-create")
.booleanType()
.defaultValue(false)
.withDescription(
"Whether to create underlying storage when reading and writing the table.");
public static final ConfigOption<Boolean> STREAMING_READ_OVERWRITE =
- ConfigOptions.key("streaming-read-overwrite")
+ key("streaming-read-overwrite")
.booleanType()
.defaultValue(false)
.withDescription(
@@ -477,17 +469,17 @@ public class CoreOptions implements Serializable {
+ "$hour:00:00'."))
.build());
- private final Configuration options;
+ private final Options options;
public CoreOptions(Map<String, String> options) {
- this(Configuration.fromMap(options));
+ this(Options.fromMap(options));
}
- public CoreOptions(Configuration options) {
+ public CoreOptions(Options options) {
this.options = options;
}
- public Configuration toConfiguration() {
+ public Options toConfiguration() {
return options;
}
@@ -507,10 +499,6 @@ public class CoreOptions implements Serializable {
return new Path(options.get(PATH.key()));
}
- public static Path path(Configuration options) {
- return new Path(options.get(PATH));
- }
-
public static Path path(Options options) {
return new Path(options.get(PATH));
}
@@ -647,7 +635,7 @@ public class CoreOptions implements Serializable {
return startupMode(options);
}
- public static StartupMode startupMode(ReadableConfig options) {
+ public static StartupMode startupMode(Options options) {
StartupMode mode = options.get(SCAN_MODE);
if (mode == StartupMode.DEFAULT) {
if (options.getOptional(SCAN_TIMESTAMP_MILLIS).isPresent()) {
@@ -890,11 +878,11 @@ public class CoreOptions implements Serializable {
}
/**
- * Set the default values of the {@link CoreOptions} via the given {@link Configuration}.
+ * Set the default values of the {@link CoreOptions} via the given {@link Options}.
*
* @param options the options to set default values
*/
- public static void setDefaultValues(Configuration options) {
+ public static void setDefaultValues(Options options) {
if (options.contains(SCAN_TIMESTAMP_MILLIS) && !options.contains(SCAN_MODE)) {
options.set(SCAN_MODE, StartupMode.FROM_TIMESTAMP);
}
@@ -999,7 +987,6 @@ public class CoreOptions implements Serializable {
"%s must be null when you set %s", illegalOption.key(), legalOption.key()));
}
- @Internal
public static List<ConfigOption<?>> getOptions() {
final Field[] fields = CoreOptions.class.getFields();
final List<ConfigOption<?>> list = new ArrayList<>(fields.length);
@@ -1015,7 +1002,6 @@ public class CoreOptions implements Serializable {
return list;
}
- @Internal
public static Set<String> getImmutableOptionKeys() {
final Field[] fields = CoreOptions.class.getFields();
final Set<String> immutableKeys = new HashSet<>(fields.length);
@@ -1031,10 +1017,4 @@ public class CoreOptions implements Serializable {
}
return immutableKeys;
}
-
- /** Annotation used on {@link ConfigOption} fields to exclude it from schema change. */
- @Internal
- @Target(ElementType.FIELD)
- @Retention(RetentionPolicy.RUNTIME)
- public @interface Immutable {}
}
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/WriteMode.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/WriteMode.java
index 5fa868f8..dfbc7df8 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/WriteMode.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/WriteMode.java
@@ -18,10 +18,10 @@
package org.apache.flink.table.store.file;
-import org.apache.flink.configuration.DescribedEnum;
-import org.apache.flink.configuration.description.InlineElement;
+import org.apache.flink.table.store.options.description.DescribedEnum;
+import org.apache.flink.table.store.options.description.InlineElement;
-import static org.apache.flink.configuration.description.TextElement.text;
+import static org.apache.flink.table.store.options.description.TextElement.text;
/** Defines the write mode for flink table store. */
public enum WriteMode implements DescribedEnum {
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/mergetree/compact/aggregate/AggregateMergeFunction.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/mergetree/compact/aggregate/AggregateMergeFunction.java
index b93072f8..06920682 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/mergetree/compact/aggregate/AggregateMergeFunction.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/mergetree/compact/aggregate/AggregateMergeFunction.java
@@ -18,12 +18,12 @@
package org.apache.flink.table.store.file.mergetree.compact.aggregate;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.data.GenericRow;
import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.file.KeyValue;
import org.apache.flink.table.store.file.mergetree.compact.MergeFunction;
import org.apache.flink.table.store.file.mergetree.compact.MergeFunctionFactory;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.DataType;
import org.apache.flink.table.store.types.RowKind;
import org.apache.flink.table.store.utils.Projection;
@@ -33,7 +33,7 @@ import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.List;
-import static org.apache.flink.configuration.ConfigOptions.key;
+import static org.apache.flink.table.store.options.ConfigOptions.key;
import static org.apache.flink.table.store.utils.Preconditions.checkArgument;
import static org.apache.flink.table.store.utils.Preconditions.checkNotNull;
import static org.apache.flink.table.store.utils.RowDataUtils.createFieldGetters;
@@ -99,7 +99,7 @@ public class AggregateMergeFunction implements MergeFunction<KeyValue> {
private final FieldAggregator[] fieldAggregators;
public RowAggregator(
- Configuration sqlConf,
+ Options sqlConf,
List<String> fieldNames,
List<DataType> fieldTypes,
List<String> primaryKeys) {
@@ -127,7 +127,7 @@ public class AggregateMergeFunction implements MergeFunction<KeyValue> {
}
public static MergeFunctionFactory<KeyValue> factory(
- Configuration conf,
+ Options conf,
List<String> tableNames,
List<DataType> tableTypes,
List<String> primaryKeys) {
@@ -138,13 +138,13 @@ public class AggregateMergeFunction implements MergeFunction<KeyValue> {
private static final long serialVersionUID = 1L;
- private final Configuration conf;
+ private final Options conf;
private final List<String> tableNames;
private final List<DataType> tableTypes;
private final List<String> primaryKeys;
private Factory(
- Configuration conf,
+ Options conf,
List<String> tableNames,
List<DataType> tableTypes,
List<String> primaryKeys) {
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/operation/FileStoreCommitImpl.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/operation/FileStoreCommitImpl.java
index aa5c0834..9fd6c3f2 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/operation/FileStoreCommitImpl.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/operation/FileStoreCommitImpl.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.file.operation;
-import org.apache.flink.configuration.MemorySize;
import org.apache.flink.table.store.data.BinaryRow;
import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.file.Snapshot;
@@ -35,6 +34,7 @@ import org.apache.flink.table.store.file.utils.FileStorePathFactory;
import org.apache.flink.table.store.file.utils.SnapshotManager;
import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.Path;
+import org.apache.flink.table.store.options.MemorySize;
import org.apache.flink.table.store.table.sink.FileCommittable;
import org.apache.flink.table.store.types.RowType;
import org.apache.flink.table.store.utils.RowDataToObjectArrayConverter;
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/sort/BinaryExternalSortBuffer.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/sort/BinaryExternalSortBuffer.java
index efd3586c..a635998d 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/sort/BinaryExternalSortBuffer.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/sort/BinaryExternalSortBuffer.java
@@ -19,7 +19,6 @@
package org.apache.flink.table.store.file.sort;
import org.apache.flink.annotation.VisibleForTesting;
-import org.apache.flink.configuration.MemorySize;
import org.apache.flink.table.store.codegen.RecordComparator;
import org.apache.flink.table.store.data.BinaryRow;
import org.apache.flink.table.store.data.InternalRow;
@@ -32,6 +31,7 @@ import org.apache.flink.table.store.file.disk.FileChannelUtil;
import org.apache.flink.table.store.file.disk.FileIOChannel;
import org.apache.flink.table.store.file.disk.IOManager;
import org.apache.flink.table.store.file.utils.MutableObjectIterator;
+import org.apache.flink.table.store.options.MemorySize;
import java.io.IOException;
import java.util.ArrayList;
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/FileStorePathFactory.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/FileStorePathFactory.java
index ff1dc66d..34c87409 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/FileStorePathFactory.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/FileStorePathFactory.java
@@ -19,11 +19,11 @@
package org.apache.flink.table.store.file.utils;
import org.apache.flink.annotation.VisibleForTesting;
-import org.apache.flink.configuration.ConfigOption;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.data.BinaryRow;
import org.apache.flink.table.store.file.io.DataFilePathFactory;
import org.apache.flink.table.store.fs.Path;
+import org.apache.flink.table.store.options.ConfigOption;
import org.apache.flink.table.store.types.RowType;
import org.apache.flink.table.store.utils.Preconditions;
@@ -32,7 +32,7 @@ import javax.annotation.concurrent.ThreadSafe;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.apache.flink.configuration.ConfigOptions.key;
+import static org.apache.flink.table.store.options.ConfigOptions.key;
/** Factory which produces {@link Path}s for manifest files. */
@ThreadSafe
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/AbstractFileStoreTable.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/AbstractFileStoreTable.java
index 5aee2f94..425871dd 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/AbstractFileStoreTable.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/AbstractFileStoreTable.java
@@ -19,7 +19,6 @@
package org.apache.flink.table.store.table;
import org.apache.flink.annotation.VisibleForTesting;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.file.FileStore;
import org.apache.flink.table.store.file.schema.SchemaManager;
@@ -27,6 +26,7 @@ import org.apache.flink.table.store.file.schema.TableSchema;
import org.apache.flink.table.store.file.utils.SnapshotManager;
import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.Path;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.sink.TableCommit;
import java.util.Map;
@@ -65,7 +65,7 @@ public abstract class AbstractFileStoreTable implements FileStoreTable {
}
});
- Configuration newOptions = Configuration.fromMap(options);
+ Options newOptions = Options.fromMap(options);
// merge dynamic options into schema.options
dynamicOptions.forEach(newOptions::setString);
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/ChangelogWithKeyFileStoreTable.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/ChangelogWithKeyFileStoreTable.java
index 00a68d60..af11341d 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/ChangelogWithKeyFileStoreTable.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/ChangelogWithKeyFileStoreTable.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.table;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.file.KeyValue;
@@ -36,6 +35,7 @@ import org.apache.flink.table.store.file.utils.FileStorePathFactory;
import org.apache.flink.table.store.file.utils.RecordReader;
import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.Path;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.sink.SequenceGenerator;
import org.apache.flink.table.store.table.sink.SinkRecordConverter;
import org.apache.flink.table.store.table.sink.TableWrite;
@@ -77,7 +77,7 @@ public class ChangelogWithKeyFileStoreTable extends AbstractFileStoreTable {
public KeyValueFileStore store() {
if (lazyStore == null) {
RowType rowType = tableSchema.logicalRowType();
- Configuration conf = Configuration.fromMap(tableSchema.options());
+ Options conf = Options.fromMap(tableSchema.options());
CoreOptions.MergeEngine mergeEngine = conf.get(CoreOptions.MERGE_ENGINE);
MergeFunctionFactory<KeyValue> mfFactory;
switch (mergeEngine) {
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/FileStoreTableFactory.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/FileStoreTableFactory.java
index 5cc92b1d..11365b83 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/FileStoreTableFactory.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/FileStoreTableFactory.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.table;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.file.WriteMode;
import org.apache.flink.table.store.file.schema.SchemaManager;
@@ -73,7 +72,7 @@ public class FileStoreTableFactory {
public static FileStoreTable create(
FileIO fileIO, Path tablePath, TableSchema tableSchema, Options dynamicOptions) {
FileStoreTable table;
- if (Configuration.fromMap(tableSchema.options()).get(CoreOptions.WRITE_MODE)
+ if (Options.fromMap(tableSchema.options()).get(CoreOptions.WRITE_MODE)
== WriteMode.APPEND_ONLY) {
table = new AppendOnlyFileStoreTable(fileIO, tablePath, tableSchema);
} else {
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/CoreOptionsTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/CoreOptionsTest.java
index 1bc2f11a..7683e2ea 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/CoreOptionsTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/CoreOptionsTest.java
@@ -18,7 +18,7 @@
package org.apache.flink.table.store;
-import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.store.options.Options;
import org.junit.jupiter.api.Test;
@@ -29,12 +29,12 @@ public class CoreOptionsTest {
@Test
public void testDefaultStartupMode() {
- Configuration conf = new Configuration();
+ Options conf = new Options();
assertThat(conf.get(CoreOptions.SCAN_MODE)).isEqualTo(CoreOptions.StartupMode.DEFAULT);
assertThat(new CoreOptions(conf).startupMode())
.isEqualTo(CoreOptions.StartupMode.LATEST_FULL);
- conf = new Configuration();
+ conf = new Options();
conf.set(CoreOptions.SCAN_TIMESTAMP_MILLIS, System.currentTimeMillis());
assertThat(new CoreOptions(conf).startupMode())
.isEqualTo(CoreOptions.StartupMode.FROM_TIMESTAMP);
@@ -42,11 +42,11 @@ public class CoreOptionsTest {
@Test
public void testStartupModeCompatibility() {
- Configuration conf = new Configuration();
+ Options conf = new Options();
conf.setString("log.scan", "latest");
assertThat(new CoreOptions(conf).startupMode()).isEqualTo(CoreOptions.StartupMode.LATEST);
- conf = new Configuration();
+ conf = new Options();
conf.setString("log.scan.timestamp-millis", String.valueOf(System.currentTimeMillis()));
assertThat(new CoreOptions(conf).startupMode())
.isEqualTo(CoreOptions.StartupMode.FROM_TIMESTAMP);
@@ -54,7 +54,7 @@ public class CoreOptionsTest {
@Test
public void testDeprecatedStartupMode() {
- Configuration conf = new Configuration();
+ Options conf = new Options();
conf.set(CoreOptions.SCAN_MODE, CoreOptions.StartupMode.FULL);
assertThat(new CoreOptions(conf).startupMode())
.isEqualTo(CoreOptions.StartupMode.LATEST_FULL);
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/FileFormatTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/FileFormatTest.java
index ed2debcc..ace46a90 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/FileFormatTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/FileFormatTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.file;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.data.GenericRow;
import org.apache.flink.table.store.data.InternalRow;
@@ -30,6 +29,7 @@ import org.apache.flink.table.store.format.FormatWriterFactory;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.PositionOutputStream;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.IntType;
import org.apache.flink.table.store.types.RowType;
@@ -88,7 +88,7 @@ public class FileFormatTest {
}
public FileFormat createFileFormat(String codec) {
- Configuration tableOptions = new Configuration();
+ Options tableOptions = new Options();
tableOptions.set(CoreOptions.FILE_FORMAT, "avro");
tableOptions.setString("avro.codec", codec);
return FileFormat.fromTableOptions(tableOptions, CoreOptions.FILE_FORMAT);
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/TestFileStore.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/TestFileStore.java
index d407af3d..26208a9a 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/TestFileStore.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/TestFileStore.java
@@ -18,8 +18,6 @@
package org.apache.flink.table.store.file;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.MemorySize;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.data.BinaryRow;
import org.apache.flink.table.store.data.serializer.InternalRowSerializer;
@@ -47,6 +45,8 @@ import org.apache.flink.table.store.file.utils.SnapshotManager;
import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.FileIOFinder;
import org.apache.flink.table.store.fs.Path;
+import org.apache.flink.table.store.options.MemorySize;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.sink.FileCommittable;
import org.apache.flink.table.store.table.source.DataSplit;
import org.apache.flink.table.store.types.RowType;
@@ -516,7 +516,7 @@ public class TestFileStore extends KeyValueFileStore {
}
public TestFileStore build() {
- Configuration conf = new Configuration();
+ Options conf = new Options();
conf.set(CoreOptions.WRITE_BUFFER_SIZE, WRITE_BUFFER_SIZE);
conf.set(CoreOptions.PAGE_SIZE, PAGE_SIZE);
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/append/AppendOnlyWriterTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/append/AppendOnlyWriterTest.java
index b0dbcb10..cff50609 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/append/AppendOnlyWriterTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/append/AppendOnlyWriterTest.java
@@ -20,7 +20,6 @@
package org.apache.flink.table.store.file.append;
import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.data.BinaryRow;
import org.apache.flink.table.store.data.BinaryString;
@@ -35,6 +34,7 @@ import org.apache.flink.table.store.format.FieldStats;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.DataType;
import org.apache.flink.table.store.types.IntType;
import org.apache.flink.table.store.types.RowType;
@@ -303,7 +303,7 @@ public class AppendOnlyWriterTest {
private Tuple2<AppendOnlyWriter, LinkedList<DataFileMeta>> createWriter(
long targetFileSize, boolean forceCompact, List<DataFileMeta> scannedFiles) {
- FileFormat fileFormat = FileFormat.fromIdentifier(AVRO, new Configuration());
+ FileFormat fileFormat = FileFormat.fromIdentifier(AVRO, new Options());
LinkedList<DataFileMeta> toCompact = new LinkedList<>(scannedFiles);
return new Tuple2<>(
new AppendOnlyWriter(
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileFormatSuffixTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileFormatSuffixTest.java
index 8177f461..8a1707e2 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileFormatSuffixTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileFormatSuffixTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.file.format;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.data.BinaryString;
import org.apache.flink.table.store.data.GenericRow;
import org.apache.flink.table.store.file.append.AppendOnlyCompactManager;
@@ -31,6 +30,7 @@ import org.apache.flink.table.store.file.utils.RecordWriter;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.DataType;
import org.apache.flink.table.store.types.IntType;
import org.apache.flink.table.store.types.RowType;
@@ -59,7 +59,7 @@ public class FileFormatSuffixTest extends KeyValueFileReadWriteTest {
DataFilePathFactory dataFilePathFactory =
new DataFilePathFactory(new Path(tempDir.toString()), "dt=1", 1, format);
- FileFormat fileFormat = FileFormat.fromIdentifier(format, new Configuration());
+ FileFormat fileFormat = FileFormat.fromIdentifier(format, new Options());
LinkedList<DataFileMeta> toCompact = new LinkedList<>();
AppendOnlyWriter appendOnlyWriter =
new AppendOnlyWriter(
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormat.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormat.java
index fa47aba7..c9f46517 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormat.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormat.java
@@ -18,13 +18,13 @@
package org.apache.flink.table.store.file.format;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.file.predicate.Predicate;
import org.apache.flink.table.store.file.stats.TestFileStatsExtractor;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.format.FileStatsExtractor;
import org.apache.flink.table.store.format.FormatReaderFactory;
import org.apache.flink.table.store.format.FormatWriterFactory;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.RowType;
import javax.annotation.Nullable;
@@ -39,7 +39,7 @@ public class FileStatsExtractingAvroFormat extends FileFormat {
public FileStatsExtractingAvroFormat() {
super("avro");
- avro = FileFormat.fromIdentifier("avro", new Configuration());
+ avro = FileFormat.fromIdentifier("avro", new Options());
}
@Override
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormatFactory.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormatFactory.java
index ee89402a..e955ba0a 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormatFactory.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FileStatsExtractingAvroFormatFactory.java
@@ -18,9 +18,9 @@
package org.apache.flink.table.store.file.format;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.format.FileFormatFactory;
+import org.apache.flink.table.store.options.Options;
/** Factory to create {@link FileStatsExtractingAvroFormat}. */
public class FileStatsExtractingAvroFormatFactory implements FileFormatFactory {
@@ -31,7 +31,7 @@ public class FileStatsExtractingAvroFormatFactory implements FileFormatFactory {
}
@Override
- public FileFormat create(Configuration formatOptions) {
+ public FileFormat create(Options formatOptions) {
return new FileStatsExtractingAvroFormat();
}
}
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FlushingFileFormat.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FlushingFileFormat.java
index 0dd529ac..e8c07a53 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FlushingFileFormat.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/format/FlushingFileFormat.java
@@ -18,13 +18,13 @@
package org.apache.flink.table.store.file.format;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.file.predicate.Predicate;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.format.FormatReaderFactory;
import org.apache.flink.table.store.format.FormatWriter;
import org.apache.flink.table.store.format.FormatWriterFactory;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.RowType;
import javax.annotation.Nullable;
@@ -39,7 +39,7 @@ public class FlushingFileFormat extends FileFormat {
public FlushingFileFormat(String identifier) {
super(identifier);
- this.format = FileFormat.fromIdentifier(identifier, new Configuration());
+ this.format = FileFormat.fromIdentifier(identifier, new Options());
}
@Override
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/io/RollingFileWriterTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/io/RollingFileWriterTest.java
index 64dfc591..0323ca90 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/io/RollingFileWriterTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/io/RollingFileWriterTest.java
@@ -19,13 +19,13 @@
package org.apache.flink.table.store.file.io;
import org.apache.flink.api.common.accumulators.LongCounter;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.data.GenericRow;
import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.DataType;
import org.apache.flink.table.store.types.IntType;
import org.apache.flink.table.store.types.RowType;
@@ -57,7 +57,7 @@ public class RollingFileWriterTest {
@BeforeEach
public void beforeEach() {
- FileFormat fileFormat = FileFormat.fromIdentifier("avro", new Configuration());
+ FileFormat fileFormat = FileFormat.fromIdentifier("avro", new Options());
rollingFileWriter =
new RollingFileWriter<>(
() ->
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestFileMetaTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestFileMetaTest.java
index 463f506d..ff6e646a 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestFileMetaTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestFileMetaTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.file.manifest;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.data.BinaryRow;
import org.apache.flink.table.store.data.BinaryRowWriter;
@@ -32,6 +31,7 @@ import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.FileIOFinder;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.IntType;
import org.apache.flink.table.store.types.RowType;
@@ -64,7 +64,7 @@ public class ManifestFileMetaTest {
private ManifestFile manifestFile;
public ManifestFileMetaTest() {
- this.avro = FileFormat.fromIdentifier("avro", new Configuration());
+ this.avro = FileFormat.fromIdentifier("avro", new Options());
}
@BeforeEach
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestFileTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestFileTest.java
index 04b12aa8..58770e5f 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestFileTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestFileTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.file.manifest;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.file.schema.SchemaManager;
import org.apache.flink.table.store.file.stats.StatsTestUtils;
@@ -29,6 +28,7 @@ import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.FileIOFinder;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.io.TempDir;
@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ManifestFileTest {
private final ManifestTestDataGenerator gen = ManifestTestDataGenerator.builder().build();
- private final FileFormat avro = FileFormat.fromIdentifier("avro", new Configuration());
+ private final FileFormat avro = FileFormat.fromIdentifier("avro", new Options());
@TempDir java.nio.file.Path tempDir;
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestListTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestListTest.java
index 00c5b948..79835c76 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestListTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/manifest/ManifestListTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.file.manifest;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.file.TestKeyValueGenerator;
import org.apache.flink.table.store.file.utils.FailingFileIO;
@@ -27,6 +26,7 @@ import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.fs.FileIOFinder;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.io.TempDir;
@@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ManifestListTest {
private final ManifestTestDataGenerator gen = ManifestTestDataGenerator.builder().build();
- private final FileFormat avro = FileFormat.fromIdentifier("avro", new Configuration());
+ private final FileFormat avro = FileFormat.fromIdentifier("avro", new Options());
@TempDir java.nio.file.Path tempDir;
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/mergetree/MergeTreeTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/mergetree/MergeTreeTest.java
index 41752006..9a42b22e 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/mergetree/MergeTreeTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/mergetree/MergeTreeTest.java
@@ -18,8 +18,6 @@
package org.apache.flink.table.store.file.mergetree;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.MemorySize;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.CoreOptions.ChangelogProducer;
import org.apache.flink.table.store.data.BinaryRow;
@@ -50,6 +48,8 @@ import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.fs.FileStatus;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.MemorySize;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.SchemaEvolutionTableTestBase;
import org.apache.flink.table.store.types.DataField;
import org.apache.flink.table.store.types.IntType;
@@ -126,7 +126,7 @@ public class MergeTreeTest {
}
private void recreateMergeTree(long targetFileSize) {
- Configuration configuration = new Configuration();
+ Options configuration = new Options();
configuration.set(CoreOptions.WRITE_BUFFER_SIZE, new MemorySize(4096 * 3));
configuration.set(CoreOptions.PAGE_SIZE, new MemorySize(4096));
configuration.set(CoreOptions.TARGET_FILE_SIZE, new MemorySize(targetFileSize));
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/table/SchemaEvolutionTableTestBase.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/table/SchemaEvolutionTableTestBase.java
index 4aac301c..ec59c3fe 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/table/SchemaEvolutionTableTestBase.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/table/SchemaEvolutionTableTestBase.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.table;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.data.BinaryString;
import org.apache.flink.table.store.data.Decimal;
@@ -37,6 +36,7 @@ import org.apache.flink.table.store.file.utils.TraceableFileIO;
import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.FileIOFinder;
import org.apache.flink.table.store.fs.Path;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.sink.TableCommit;
import org.apache.flink.table.store.table.sink.TableWrite;
import org.apache.flink.table.store.table.source.DataTableScan;
@@ -120,7 +120,7 @@ public abstract class SchemaEvolutionTableTestBase {
protected Path tablePath;
protected FileIO fileIO;
protected String commitUser;
- protected final Configuration tableConfig = new Configuration();
+ protected final Options tableConfig = new Options();
@TempDir java.nio.file.Path tempDir;
@@ -152,7 +152,7 @@ public abstract class SchemaEvolutionTableTestBase {
Function<Map<Long, TableSchema>, R> firstChecker,
BiConsumer<R, Map<Long, TableSchema>> secondChecker,
List<String> primaryKeyNames,
- Configuration tableConfig,
+ Options tableConfig,
Function<Map<Long, TableSchema>, FileStoreTable> createFileStoreTable)
throws Exception {
Map<Long, TableSchema> tableSchemas = new HashMap<>();
@@ -227,7 +227,7 @@ public abstract class SchemaEvolutionTableTestBase {
Function<Map<Long, TableSchema>, R> firstChecker,
BiConsumer<R, Map<Long, TableSchema>> secondChecker,
List<String> primaryKeyNames,
- Configuration tableConfig,
+ Options tableConfig,
Function<Map<Long, TableSchema>, FileStoreTable> createFileStoreTable)
throws Exception {
Map<Long, TableSchema> tableSchemas = new HashMap<>();
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/table/WritePreemptMemoryTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/table/WritePreemptMemoryTest.java
index 39f2e855..d89b42a6 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/table/WritePreemptMemoryTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/table/WritePreemptMemoryTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.table;
-import org.apache.flink.configuration.MemorySize;
import org.apache.flink.table.store.CoreOptions;
import org.apache.flink.table.store.data.GenericRow;
import org.apache.flink.table.store.file.WriteMode;
@@ -26,6 +25,7 @@ import org.apache.flink.table.store.file.schema.SchemaManager;
import org.apache.flink.table.store.file.schema.TableSchema;
import org.apache.flink.table.store.file.schema.UpdateSchema;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.MemorySize;
import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.table.sink.TableCommit;
import org.apache.flink.table.store.table.sink.TableWrite;
diff --git a/flink-table-store-docs/src/main/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocGenerator.java b/flink-table-store-docs/src/main/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocGenerator.java
index b0556745..21149289 100644
--- a/flink-table-store-docs/src/main/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocGenerator.java
+++ b/flink-table-store-docs/src/main/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocGenerator.java
@@ -19,17 +19,17 @@
package org.apache.flink.table.store.docs.configuration;
import org.apache.flink.annotation.VisibleForTesting;
-import org.apache.flink.annotation.docs.ConfigGroup;
-import org.apache.flink.annotation.docs.ConfigGroups;
-import org.apache.flink.annotation.docs.Documentation;
import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.DescribedEnum;
-import org.apache.flink.configuration.description.Description;
-import org.apache.flink.configuration.description.Formatter;
-import org.apache.flink.configuration.description.HtmlFormatter;
-import org.apache.flink.configuration.description.InlineElement;
-import org.apache.flink.configuration.description.TextElement;
+import org.apache.flink.table.store.annotation.ConfigGroup;
+import org.apache.flink.table.store.annotation.ConfigGroups;
+import org.apache.flink.table.store.annotation.Documentation;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.description.DescribedEnum;
+import org.apache.flink.table.store.options.description.Description;
+import org.apache.flink.table.store.options.description.Formatter;
+import org.apache.flink.table.store.options.description.HtmlFormatter;
+import org.apache.flink.table.store.options.description.InlineElement;
+import org.apache.flink.table.store.options.description.TextElement;
import org.apache.flink.table.store.utils.ThrowingConsumer;
import org.apache.flink.table.store.utils.TimeUtils;
@@ -61,8 +61,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import static org.apache.flink.configuration.description.TextElement.text;
import static org.apache.flink.table.store.docs.util.Utils.escapeCharacters;
+import static org.apache.flink.table.store.options.description.TextElement.text;
/** Class used for generating code based documentation of configuration parameters. */
public class ConfigOptionsDocGenerator {
diff --git a/flink-table-store-docs/src/main/java/org/apache/flink/table/store/docs/configuration/OptionsClassLocation.java b/flink-table-store-docs/src/main/java/org/apache/flink/table/store/docs/configuration/OptionsClassLocation.java
index 5a6df0ff..bcc0c20b 100644
--- a/flink-table-store-docs/src/main/java/org/apache/flink/table/store/docs/configuration/OptionsClassLocation.java
+++ b/flink-table-store-docs/src/main/java/org/apache/flink/table/store/docs/configuration/OptionsClassLocation.java
@@ -18,7 +18,7 @@
package org.apache.flink.table.store.docs.configuration;
-import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOption;
/** Simple descriptor for the location of a class containing {@link ConfigOption ConfigOptions}. */
class OptionsClassLocation {
diff --git a/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocGeneratorTest.java b/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocGeneratorTest.java
index c6be5575..d3d9a6dc 100644
--- a/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocGeneratorTest.java
+++ b/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocGeneratorTest.java
@@ -18,18 +18,18 @@
package org.apache.flink.table.store.docs.configuration;
-import org.apache.flink.annotation.docs.ConfigGroup;
-import org.apache.flink.annotation.docs.ConfigGroups;
-import org.apache.flink.annotation.docs.Documentation;
import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
-import org.apache.flink.configuration.DescribedEnum;
-import org.apache.flink.configuration.MemorySize;
-import org.apache.flink.configuration.description.Formatter;
-import org.apache.flink.configuration.description.HtmlFormatter;
-import org.apache.flink.configuration.description.InlineElement;
+import org.apache.flink.table.store.annotation.ConfigGroup;
+import org.apache.flink.table.store.annotation.ConfigGroups;
+import org.apache.flink.table.store.annotation.Documentation;
import org.apache.flink.table.store.docs.configuration.data.TestCommonOptions;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOptions;
+import org.apache.flink.table.store.options.MemorySize;
+import org.apache.flink.table.store.options.description.DescribedEnum;
+import org.apache.flink.table.store.options.description.Formatter;
+import org.apache.flink.table.store.options.description.HtmlFormatter;
+import org.apache.flink.table.store.options.description.InlineElement;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -43,7 +43,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.apache.flink.configuration.description.TextElement.text;
+import static org.apache.flink.table.store.options.description.TextElement.text;
import static org.assertj.core.api.Assertions.assertThat;
/** Tests for the {@link ConfigOptionsDocGenerator}. */
diff --git a/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocsCompletenessITCase.java b/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocsCompletenessITCase.java
index 7697e106..f76b2161 100644
--- a/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocsCompletenessITCase.java
+++ b/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/ConfigOptionsDocsCompletenessITCase.java
@@ -18,9 +18,9 @@
package org.apache.flink.table.store.docs.configuration;
-import org.apache.flink.annotation.docs.Documentation;
import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.table.store.annotation.Documentation;
+import org.apache.flink.table.store.options.ConfigOption;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
diff --git a/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/data/TestCommonOptions.java b/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/data/TestCommonOptions.java
index 79443cc4..13071313 100644
--- a/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/data/TestCommonOptions.java
+++ b/flink-table-store-docs/src/test/java/org/apache/flink/table/store/docs/configuration/data/TestCommonOptions.java
@@ -18,9 +18,9 @@
package org.apache.flink.table.store.docs.configuration.data;
-import org.apache.flink.annotation.docs.Documentation;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
+import org.apache.flink.table.store.annotation.Documentation;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOptions;
/** Collection of test {@link ConfigOptions ConfigOptions}. */
@SuppressWarnings("unused") // this class is only accessed reflectively
diff --git a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/avro/AvroFileFormat.java b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/avro/AvroFileFormat.java
index b209650a..8152cf99 100644
--- a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/avro/AvroFileFormat.java
+++ b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/avro/AvroFileFormat.java
@@ -18,10 +18,6 @@
package org.apache.flink.table.store.format.avro;
-import org.apache.flink.api.common.serialization.BulkWriter;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
-import org.apache.flink.configuration.ReadableConfig;
import org.apache.flink.table.store.data.GenericRow;
import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.file.predicate.Predicate;
@@ -30,6 +26,9 @@ import org.apache.flink.table.store.format.FormatReaderFactory;
import org.apache.flink.table.store.format.FormatWriter;
import org.apache.flink.table.store.format.FormatWriterFactory;
import org.apache.flink.table.store.fs.PositionOutputStream;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOptions;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.DataType;
import org.apache.flink.table.store.types.RowType;
import org.apache.flink.table.store.utils.Projection;
@@ -61,9 +60,9 @@ public class AvroFileFormat extends FileFormat {
.defaultValue(SNAPPY_CODEC)
.withDescription("The compression codec for avro");
- private final ReadableConfig formatOptions;
+ private final Options formatOptions;
- public AvroFileFormat(ReadableConfig formatOptions) {
+ public AvroFileFormat(Options formatOptions) {
super(IDENTIFIER);
this.formatOptions = formatOptions;
}
@@ -111,8 +110,8 @@ public class AvroFileFormat extends FileFormat {
}
/**
- * A {@link BulkWriter.Factory} to convert {@link InternalRow} to {@link GenericRecord} and wrap
- * {@link AvroWriterFactory}.
+ * A {@link FormatWriterFactory} to convert {@link InternalRow} to {@link GenericRecord} and
+ * wrap {@link AvroWriterFactory}.
*/
private static class RowDataAvroWriterFactory implements FormatWriterFactory {
diff --git a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/avro/AvroFileFormatFactory.java b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/avro/AvroFileFormatFactory.java
index c541eaa7..fb190a92 100644
--- a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/avro/AvroFileFormatFactory.java
+++ b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/avro/AvroFileFormatFactory.java
@@ -18,9 +18,9 @@
package org.apache.flink.table.store.format.avro;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.format.FileFormatFactory;
+import org.apache.flink.table.store.options.Options;
/** Factory to create {@link AvroFileFormat}. */
public class AvroFileFormatFactory implements FileFormatFactory {
@@ -31,7 +31,7 @@ public class AvroFileFormatFactory implements FileFormatFactory {
}
@Override
- public FileFormat create(Configuration formatOptions) {
+ public FileFormat create(Options formatOptions) {
return new AvroFileFormat(formatOptions);
}
}
diff --git a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/orc/OrcFileFormat.java b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/orc/OrcFileFormat.java
index 604ada39..18a4c827 100644
--- a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/orc/OrcFileFormat.java
+++ b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/orc/OrcFileFormat.java
@@ -20,8 +20,6 @@ package org.apache.flink.table.store.format.orc;
import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.api.common.serialization.BulkWriter;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.ReadableConfig;
import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.file.predicate.Predicate;
import org.apache.flink.table.store.format.FileFormat;
@@ -34,6 +32,7 @@ import org.apache.flink.table.store.format.orc.filter.OrcPredicateFunctionVisito
import org.apache.flink.table.store.format.orc.reader.OrcSplitReaderUtil;
import org.apache.flink.table.store.format.orc.writer.RowDataVectorizer;
import org.apache.flink.table.store.format.orc.writer.Vectorizer;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.ArrayType;
import org.apache.flink.table.store.types.DataField;
import org.apache.flink.table.store.types.DataType;
@@ -65,7 +64,7 @@ public class OrcFileFormat extends FileFormat {
private final org.apache.hadoop.conf.Configuration readerConf;
private final org.apache.hadoop.conf.Configuration writerConf;
- public OrcFileFormat(Configuration formatOptions) {
+ public OrcFileFormat(Options formatOptions) {
super(IDENTIFIER);
this.orcProperties = getOrcProperties(formatOptions);
this.readerConf = new org.apache.hadoop.conf.Configuration();
@@ -126,10 +125,10 @@ public class OrcFileFormat extends FileFormat {
return new OrcWriterFactory(vectorizer, orcProperties, writerConf);
}
- private static Properties getOrcProperties(ReadableConfig options) {
+ private static Properties getOrcProperties(Options options) {
Properties orcProperties = new Properties();
Properties properties = new Properties();
- ((org.apache.flink.configuration.Configuration) options).addAllToProperties(properties);
+ options.addAllToProperties(properties);
properties.forEach((k, v) -> orcProperties.put(IDENTIFIER + "." + k, v));
return orcProperties;
}
diff --git a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/orc/OrcFileFormatFactory.java b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/orc/OrcFileFormatFactory.java
index d580ce61..e16b0315 100644
--- a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/orc/OrcFileFormatFactory.java
+++ b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/orc/OrcFileFormatFactory.java
@@ -18,8 +18,8 @@
package org.apache.flink.table.store.format.orc;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.format.FileFormatFactory;
+import org.apache.flink.table.store.options.Options;
import java.util.Properties;
@@ -34,16 +34,16 @@ public class OrcFileFormatFactory implements FileFormatFactory {
}
@Override
- public OrcFileFormat create(Configuration formatOptions) {
+ public OrcFileFormat create(Options formatOptions) {
return new OrcFileFormat(supplyDefaultOptions(formatOptions));
}
- private Configuration supplyDefaultOptions(Configuration options) {
+ private Options supplyDefaultOptions(Options options) {
if (!options.containsKey("compress")) {
Properties properties = new Properties();
options.addAllToProperties(properties);
properties.setProperty("compress", "lz4");
- Configuration newOptions = new Configuration();
+ Options newOptions = new Options();
properties.forEach((k, v) -> newOptions.setString(k.toString(), v.toString()));
return newOptions;
}
diff --git a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetFileFormat.java b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetFileFormat.java
index 071e2165..864dfd19 100644
--- a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetFileFormat.java
+++ b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetFileFormat.java
@@ -19,13 +19,13 @@
package org.apache.flink.table.store.format.parquet;
import org.apache.flink.annotation.VisibleForTesting;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.file.predicate.Predicate;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.format.FileStatsExtractor;
import org.apache.flink.table.store.format.FormatReaderFactory;
import org.apache.flink.table.store.format.FormatWriterFactory;
import org.apache.flink.table.store.format.parquet.writer.RowDataParquetBuilder;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.RowType;
import org.apache.flink.table.store.utils.Projection;
@@ -37,15 +37,15 @@ import static org.apache.flink.table.store.format.parquet.ParquetFileFormatFacto
/** Parquet {@link FileFormat}. */
public class ParquetFileFormat extends FileFormat {
- private final Configuration formatOptions;
+ private final Options formatOptions;
- public ParquetFileFormat(Configuration formatOptions) {
+ public ParquetFileFormat(Options formatOptions) {
super(IDENTIFIER);
this.formatOptions = formatOptions;
}
@VisibleForTesting
- Configuration formatOptions() {
+ Options formatOptions() {
return formatOptions;
}
@@ -68,8 +68,8 @@ public class ParquetFileFormat extends FileFormat {
return Optional.of(new ParquetFileStatsExtractor(type));
}
- public static Configuration getParquetConfiguration(Configuration options) {
- Configuration conf = new Configuration();
+ public static Options getParquetConfiguration(Options options) {
+ Options conf = new Options();
options.toMap().forEach((key, value) -> conf.setString(IDENTIFIER + "." + key, value));
return conf;
}
diff --git a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetFileFormatFactory.java b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetFileFormatFactory.java
index 7b7c60f5..c8673fc2 100644
--- a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetFileFormatFactory.java
+++ b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetFileFormatFactory.java
@@ -18,8 +18,8 @@
package org.apache.flink.table.store.format.parquet;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.format.FileFormatFactory;
+import org.apache.flink.table.store.options.Options;
import org.apache.parquet.hadoop.ParquetOutputFormat;
import org.apache.parquet.hadoop.metadata.CompressionCodecName;
@@ -36,18 +36,18 @@ public class ParquetFileFormatFactory implements FileFormatFactory {
}
@Override
- public ParquetFileFormat create(Configuration formatOptions) {
+ public ParquetFileFormat create(Options formatOptions) {
return new ParquetFileFormat(supplyDefaultOptions(formatOptions));
}
- private Configuration supplyDefaultOptions(Configuration options) {
+ private Options supplyDefaultOptions(Options options) {
String compression =
ParquetOutputFormat.COMPRESSION.replaceFirst(String.format("^%s.", IDENTIFIER), "");
if (!options.containsKey(compression)) {
Properties properties = new Properties();
options.addAllToProperties(properties);
properties.setProperty(compression, CompressionCodecName.SNAPPY.name());
- Configuration newOptions = new Configuration();
+ Options newOptions = new Options();
properties.forEach((k, v) -> newOptions.setString(k.toString(), v.toString()));
return newOptions;
}
diff --git a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetReaderFactory.java b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetReaderFactory.java
index ec0def56..444d7062 100644
--- a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetReaderFactory.java
+++ b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/ParquetReaderFactory.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.format.parquet;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.data.columnar.ColumnVector;
import org.apache.flink.table.store.data.columnar.ColumnarRow;
@@ -32,6 +31,7 @@ import org.apache.flink.table.store.format.parquet.reader.ColumnReader;
import org.apache.flink.table.store.format.parquet.reader.ParquetDecimalVector;
import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.Path;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.DataType;
import org.apache.flink.table.store.types.DataTypeRoot;
import org.apache.flink.table.store.types.RowType;
@@ -75,17 +75,17 @@ public class ParquetReaderFactory implements FormatReaderFactory {
private static final int BATCH_SIZE = 2048;
- private final Configuration conf;
+ private final Options conf;
private final String[] projectedFields;
private final DataType[] projectedTypes;
private final int batchSize;
private final Set<Integer> unknownFieldsIndices = new HashSet<>();
- public ParquetReaderFactory(Configuration formatConfig, RowType projectedType) {
+ public ParquetReaderFactory(Options formatConfig, RowType projectedType) {
this(formatConfig, projectedType, BATCH_SIZE);
}
- public ParquetReaderFactory(Configuration conf, RowType projectedType, int batchSize) {
+ public ParquetReaderFactory(Options conf, RowType projectedType, int batchSize) {
this.conf = conf;
this.projectedFields = projectedType.getFieldNames().toArray(new String[0]);
this.projectedTypes = projectedType.getFieldTypes().toArray(new DataType[0]);
diff --git a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/writer/RowDataParquetBuilder.java b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/writer/RowDataParquetBuilder.java
index d1c1408d..b2b4fa0f 100644
--- a/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/writer/RowDataParquetBuilder.java
+++ b/flink-table-store-format/src/main/java/org/apache/flink/table/store/format/parquet/writer/RowDataParquetBuilder.java
@@ -18,8 +18,8 @@
package org.apache.flink.table.store.format.parquet.writer;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.data.InternalRow;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.RowType;
import org.apache.parquet.column.ParquetProperties;
@@ -34,9 +34,9 @@ import java.io.IOException;
public class RowDataParquetBuilder implements ParquetBuilder<InternalRow> {
private final RowType rowType;
- private final Configuration conf;
+ private final Options conf;
- public RowDataParquetBuilder(RowType rowType, Configuration conf) {
+ public RowDataParquetBuilder(RowType rowType, Options conf) {
this.rowType = rowType;
this.conf = conf;
}
diff --git a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/BulkFileFormatTest.java b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/BulkFileFormatTest.java
index 79408af1..d0a613e6 100644
--- a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/BulkFileFormatTest.java
+++ b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/BulkFileFormatTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.format;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.data.GenericRow;
import org.apache.flink.table.store.data.InternalRow;
import org.apache.flink.table.store.file.utils.RecordReader;
@@ -26,6 +25,7 @@ import org.apache.flink.table.store.file.utils.RecordReaderUtils;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.PositionOutputStream;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.IntType;
import org.apache.flink.table.store.types.RowType;
@@ -53,7 +53,7 @@ public class BulkFileFormatTest {
}
public FileFormat createFileFormat(String format, String codec) {
- Configuration tableOptions = new Configuration();
+ Options tableOptions = new Options();
tableOptions.setString(format + ".codec", codec);
return FileFormat.fromIdentifier(format, tableOptions);
}
diff --git a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/orc/OrcFileFormatTest.java b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/orc/OrcFileFormatTest.java
index ba1dbacb..003948cd 100644
--- a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/orc/OrcFileFormatTest.java
+++ b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/orc/OrcFileFormatTest.java
@@ -18,7 +18,7 @@
package org.apache.flink.table.store.format.orc;
-import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.store.options.Options;
import org.junit.jupiter.api.Test;
@@ -30,7 +30,7 @@ public class OrcFileFormatTest {
@Test
public void testAbsent() {
- Configuration options = new Configuration();
+ Options options = new Options();
options.setString("haha", "1");
OrcFileFormat orc = new OrcFileFormatFactory().create(options);
assertThat(orc.orcProperties().getProperty(IDENTIFIER + ".haha", "")).isEqualTo("1");
@@ -39,7 +39,7 @@ public class OrcFileFormatTest {
@Test
public void testPresent() {
- Configuration options = new Configuration();
+ Options options = new Options();
options.setString("haha", "1");
options.setString("compress", "zlib");
OrcFileFormat orc = new OrcFileFormatFactory().create(options);
diff --git a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/orc/OrcFileStatsExtractorTest.java b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/orc/OrcFileStatsExtractorTest.java
index 840faf29..6c712620 100644
--- a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/orc/OrcFileStatsExtractorTest.java
+++ b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/orc/OrcFileStatsExtractorTest.java
@@ -18,10 +18,10 @@
package org.apache.flink.table.store.format.orc;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.format.FileStatsExtractorTestBase;
import org.apache.flink.table.store.format.orc.filter.OrcFileStatsExtractor;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.ArrayType;
import org.apache.flink.table.store.types.BigIntType;
import org.apache.flink.table.store.types.BinaryType;
@@ -46,7 +46,7 @@ public class OrcFileStatsExtractorTest extends FileStatsExtractorTestBase {
@Override
protected FileFormat createFormat() {
- return FileFormat.fromIdentifier("orc", new Configuration());
+ return FileFormat.fromIdentifier("orc", new Options());
}
@Override
diff --git a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetFileFormatTest.java b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetFileFormatTest.java
index 20fb7367..eaab79f3 100644
--- a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetFileFormatTest.java
+++ b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetFileFormatTest.java
@@ -18,10 +18,9 @@
package org.apache.flink.table.store.format.parquet;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.DelegatingConfiguration;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOptions;
+import org.apache.flink.table.store.options.Options;
import org.apache.parquet.format.CompressionCodec;
import org.apache.parquet.hadoop.ParquetOutputFormat;
@@ -38,14 +37,14 @@ public class ParquetFileFormatTest {
@Test
public void testAbsent() {
- Configuration options = new Configuration();
+ Options options = new Options();
ParquetFileFormat parquet = new ParquetFileFormatFactory().create(options);
assertThat(parquet.formatOptions().getString(KEY1)).isEqualTo("absent");
}
@Test
public void testPresent() {
- Configuration options = new Configuration();
+ Options options = new Options();
options.setString(KEY1.key(), "v1");
ParquetFileFormat parquet = new ParquetFileFormatFactory().create(options);
assertThat(parquet.formatOptions().getString(KEY1)).isEqualTo("v1");
@@ -53,20 +52,20 @@ public class ParquetFileFormatTest {
@Test
public void testDefaultCompressionCodecName() {
- Configuration conf = new Configuration();
+ Options conf = new Options();
assertThat(getCompressionCodec(conf)).isEqualTo(CompressionCodec.SNAPPY.name());
}
@Test
public void testSpecifiedCompressionCodecName() {
String lz4 = CompressionCodec.LZ4.name();
- Configuration conf = new Configuration();
+ Options conf = new Options();
conf.setString(ParquetOutputFormat.COMPRESSION, lz4);
assertThat(getCompressionCodec(conf)).isEqualTo(lz4);
}
- private String getCompressionCodec(Configuration conf) {
- DelegatingConfiguration formatOptions = new DelegatingConfiguration(conf, IDENTIFIER + ".");
+ private String getCompressionCodec(Options conf) {
+ Options formatOptions = conf.removePrefix(IDENTIFIER + ".");
ParquetFileFormat parquet = new ParquetFileFormatFactory().create(formatOptions);
return getParquetConfiguration(parquet.formatOptions())
.getString(ParquetOutputFormat.COMPRESSION, null);
diff --git a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetFileStatsExtractorTest.java b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetFileStatsExtractorTest.java
index cb0765f1..36bf3761 100644
--- a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetFileStatsExtractorTest.java
+++ b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetFileStatsExtractorTest.java
@@ -18,9 +18,9 @@
package org.apache.flink.table.store.format.parquet;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.format.FileFormat;
import org.apache.flink.table.store.format.FileStatsExtractorTestBase;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.BigIntType;
import org.apache.flink.table.store.types.BooleanType;
import org.apache.flink.table.store.types.CharType;
@@ -39,7 +39,7 @@ public class ParquetFileStatsExtractorTest extends FileStatsExtractorTestBase {
@Override
protected FileFormat createFormat() {
- return FileFormat.fromIdentifier("parquet", new Configuration());
+ return FileFormat.fromIdentifier("parquet", new Options());
}
@Override
diff --git a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetReadWriteTest.java b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetReadWriteTest.java
index c98d7926..b619a712 100644
--- a/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetReadWriteTest.java
+++ b/flink-table-store-format/src/test/java/org/apache/flink/table/store/format/parquet/ParquetReadWriteTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.table.store.format.parquet;
-import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.store.data.BinaryString;
import org.apache.flink.table.store.data.Decimal;
import org.apache.flink.table.store.data.GenericArray;
@@ -31,6 +30,7 @@ import org.apache.flink.table.store.format.FormatWriter;
import org.apache.flink.table.store.format.parquet.writer.RowDataParquetBuilder;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.fs.local.LocalFileIO;
+import org.apache.flink.table.store.options.Options;
import org.apache.flink.table.store.types.ArrayType;
import org.apache.flink.table.store.types.BigIntType;
import org.apache.flink.table.store.types.BooleanType;
@@ -223,7 +223,7 @@ public class ParquetReadWriteTest {
DataType[] fieldTypes = new DataType[] {new DoubleType(), new TinyIntType(), new IntType()};
ParquetReaderFactory format =
new ParquetReaderFactory(
- new Configuration(),
+ new Options(),
RowType.builder()
.fields(fieldTypes, new String[] {"f7", "f2", "f4"})
.build(),
@@ -260,7 +260,7 @@ public class ParquetReadWriteTest {
};
ParquetReaderFactory format =
new ParquetReaderFactory(
- new Configuration(),
+ new Options(),
// f99 not exist in parquet file.
RowType.builder()
.fields(fieldTypes, new String[] {"f7", "f2", "f4", "f99"})
@@ -292,7 +292,7 @@ public class ParquetReadWriteTest {
throws IOException {
// write data
Path path = new Path(folder.getPath(), UUID.randomUUID().toString());
- Configuration conf = new Configuration();
+ Options conf = new Options();
conf.setInteger("parquet.block.size", rowGroupSize);
ParquetWriterFactory factory =
new ParquetWriterFactory(new RowDataParquetBuilder(ROW_TYPE, conf));
@@ -307,7 +307,7 @@ public class ParquetReadWriteTest {
}
private int testReadingFile(List<Integer> expected, Path path) throws IOException {
- ParquetReaderFactory format = new ParquetReaderFactory(new Configuration(), ROW_TYPE, 500);
+ ParquetReaderFactory format = new ParquetReaderFactory(new Options(), ROW_TYPE, 500);
// validate java serialization
try {
diff --git a/flink-table-store-hive/flink-table-store-hive-catalog/src/main/java/org/apache/flink/table/store/hive/HiveCatalogFactory.java b/flink-table-store-hive/flink-table-store-hive-catalog/src/main/java/org/apache/flink/table/store/hive/HiveCatalogFactory.java
index 18a36580..bb7dd2b8 100644
--- a/flink-table-store-hive/flink-table-store-hive-catalog/src/main/java/org/apache/flink/table/store/hive/HiveCatalogFactory.java
+++ b/flink-table-store-hive/flink-table-store-hive-catalog/src/main/java/org/apache/flink/table/store/hive/HiveCatalogFactory.java
@@ -18,13 +18,13 @@
package org.apache.flink.table.store.hive;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
import org.apache.flink.table.store.file.catalog.Catalog;
import org.apache.flink.table.store.file.catalog.CatalogFactory;
import org.apache.flink.table.store.fs.FileIO;
import org.apache.flink.table.store.fs.Path;
import org.apache.flink.table.store.options.CatalogOptions;
+import org.apache.flink.table.store.options.ConfigOption;
+import org.apache.flink.table.store.options.ConfigOptions;
import org.apache.flink.table.store.utils.Preconditions;
import org.apache.hadoop.conf.Configuration;