You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tw...@apache.org on 2018/10/30 10:26:16 UTC
[flink] 06/07: [FLINK-10687] [table] Move format factories to
flink-table-common
This is an automated email from the ASF dual-hosted git repository.
twalthr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 95b40868ef19a38353ecbb84ea3946e90e2e38e3
Author: Timo Walther <tw...@apache.org>
AuthorDate: Sat Oct 27 07:45:41 2018 +0200
[FLINK-10687] [table] Move format factories to flink-table-common
---
.../factories/DeserializationSchemaFactory.java} | 32 ++++----
.../factories/SerializationSchemaFactory.java} | 32 ++++----
.../apache/flink/table/factories/TableFactory.java | 83 +++++++++++++++++++++
.../flink/table/factories/TableFormatFactory.java | 65 +++++++++++++++++
.../flink/table/factories/TableFactory.scala | 85 ----------------------
.../flink/table/factories/TableFormatFactory.scala | 65 -----------------
6 files changed, 180 insertions(+), 182 deletions(-)
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/DeserializationSchemaFactory.scala b/flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/DeserializationSchemaFactory.java
similarity index 56%
rename from flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/DeserializationSchemaFactory.scala
rename to flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/DeserializationSchemaFactory.java
index 92aa8c9..12af6ce 100644
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/DeserializationSchemaFactory.scala
+++ b/flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/DeserializationSchemaFactory.java
@@ -16,26 +16,26 @@
* limitations under the License.
*/
-package org.apache.flink.table.factories
+package org.apache.flink.table.factories;
-import java.util
+import org.apache.flink.api.common.serialization.DeserializationSchema;
-import org.apache.flink.api.common.serialization.DeserializationSchema
+import java.util.Map;
/**
- * Factory for creating configured instances of [[DeserializationSchema]].
- *
- * @tparam T record type that the format produces or consumes
- */
-trait DeserializationSchemaFactory[T] extends TableFormatFactory[T] {
+ * Factory for creating configured instances of {@link DeserializationSchema}.
+ *
+ * @param <T> record type that the format produces or consumes.
+ */
+public interface DeserializationSchemaFactory<T> extends TableFormatFactory<T> {
- /**
- * Creates and configures a [[DeserializationSchema]] using the given properties.
- *
- * @param properties normalized properties describing the format
- * @return the configured serialization schema or null if the factory cannot provide an
- * instance of this class
- */
- def createDeserializationSchema(properties: util.Map[String, String]): DeserializationSchema[T]
+ /**
+ * Creates and configures a {@link DeserializationSchema} using the given properties.
+ *
+ * @param properties normalized properties describing the format
+ * @return the configured serialization schema or null if the factory cannot provide an
+ * instance of this class
+ */
+ DeserializationSchema<T> createDeserializationSchema(Map<String, String> properties);
}
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/SerializationSchemaFactory.scala b/flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/SerializationSchemaFactory.java
similarity index 56%
rename from flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/SerializationSchemaFactory.scala
rename to flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/SerializationSchemaFactory.java
index 1f6b6bf..20c8296 100644
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/SerializationSchemaFactory.scala
+++ b/flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/SerializationSchemaFactory.java
@@ -16,26 +16,26 @@
* limitations under the License.
*/
-package org.apache.flink.table.factories
+package org.apache.flink.table.factories;
-import java.util
+import org.apache.flink.api.common.serialization.SerializationSchema;
-import org.apache.flink.api.common.serialization.SerializationSchema
+import java.util.Map;
/**
- * Factory for creating configured instances of [[SerializationSchema]].
- *
- * @tparam T record type that the format produces or consumes
- */
-trait SerializationSchemaFactory[T] extends TableFormatFactory[T] {
+ * Factory for creating configured instances of {@link SerializationSchema}.
+ *
+ * @param <T> record type that the format produces or consumes.
+ */
+public interface SerializationSchemaFactory<T> extends TableFormatFactory<T> {
- /**
- * Creates and configures a [[SerializationSchema]] using the given properties.
- *
- * @param properties normalized properties describing the format
- * @return the configured serialization schema or null if the factory cannot provide an
- * instance of this class
- */
- def createSerializationSchema(properties: util.Map[String, String]): SerializationSchema[T]
+ /**
+ * Creates and configures a [[SerializationSchema]] using the given properties.
+ *
+ * @param properties normalized properties describing the format
+ * @return the configured serialization schema or null if the factory cannot provide an
+ * instance of this class
+ */
+ SerializationSchema<T> createSerializationSchema(Map<String, String> properties);
}
diff --git a/flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/TableFactory.java b/flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/TableFactory.java
new file mode 100644
index 0000000..647feb5
--- /dev/null
+++ b/flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/TableFactory.java
@@ -0,0 +1,83 @@
+/*
+ * 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.factories;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A factory to create different table-related instances from string-based properties. This
+ * factory is used with Java's Service Provider Interfaces (SPI) for discovering. A factory is
+ * called with a set of normalized properties that describe the desired configuration. The factory
+ * allows for matching to the given set of properties.
+ *
+ * <p>Classes that implement this interface can be added to the
+ * "META_INF/services/org.apache.flink.table.factories.TableFactory" file of a JAR file in
+ * the current classpath to be found.
+ *
+ * @see TableFormatFactory
+ */
+public interface TableFactory {
+
+ /**
+ * Specifies the context that this factory has been implemented for. The framework guarantees to
+ * only match for this factory if the specified set of properties and values are met.
+ *
+ * <p>Typical properties might be:
+ * - connector.type
+ * - format.type
+ *
+ * <p>Specified property versions allow the framework to provide backwards compatible properties
+ * in case of string format changes:
+ * - connector.property-version
+ * - format.property-version
+ *
+ * <p>An empty context means that the factory matches for all requests.
+ */
+ Map<String, String> requiredContext();
+
+
+ /**
+ * List of property keys that this factory can handle. This method will be used for validation.
+ * If a property is passed that this factory cannot handle, an exception will be thrown. The
+ * list must not contain the keys that are specified by the context.
+ *
+ * <p>Example properties might be:
+ * - schema.#.type
+ * - schema.#.name
+ * - connector.topic
+ * - format.line-delimiter
+ * - format.ignore-parse-errors
+ * - format.fields.#.type
+ * - format.fields.#.name
+ *
+ * <p>Note: Use "#" to denote an array of values where "#" represents one or more digits. Property
+ * versions like "format.property-version" must not be part of the supported properties.
+ *
+ * <p>In some cases it might be useful to declare wildcards "*". Wildcards can only be declared at
+ * the end of a property key.
+ *
+ * <p>For example, if an arbitrary format should be supported:
+ * - format.*
+ *
+ * <p>Note: Wildcards should be used with caution as they might swallow unsupported properties
+ * and thus might lead to undesired behavior.
+ */
+ List<String> supportedProperties();
+}
diff --git a/flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/TableFormatFactory.java b/flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/TableFormatFactory.java
new file mode 100644
index 0000000..da298f2
--- /dev/null
+++ b/flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/factories/TableFormatFactory.java
@@ -0,0 +1,65 @@
+/*
+ * 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.factories;
+
+import java.util.List;
+
+/**
+ * A factory to create configured table format instances based on string-based properties. See
+ * also {@link TableFactory} for more information.
+ *
+ * @see DeserializationSchemaFactory
+ * @see SerializationSchemaFactory
+ *
+ * @param <T> record type that the format produces or consumes.
+ */
+public interface TableFormatFactory<T> extends TableFactory {
+
+ /**
+ * Flag to indicate if the given format supports deriving information from a schema. If the
+ * format can handle schema information, those properties must be added to the list of
+ * supported properties.
+ */
+ boolean supportsSchemaDerivation();
+
+ /**
+ * List of format property keys that this factory can handle. This method will be used for
+ * validation. If a property is passed that this factory cannot handle, an exception will be
+ * thrown. The list must not contain the keys that are specified by the context.
+ *
+ * <p>Example format properties might be:
+ * - format.line-delimiter
+ * - format.ignore-parse-errors
+ * - format.fields.#.type
+ * - format.fields.#.name
+ *
+ * <p>If schema derivation is enabled, the list must include schema properties:
+ * - schema.#.name
+ * - schema.#.type
+ *
+ * <p>Note: All supported format properties must be prefixed with "format.". If schema derivation is
+ * enabled, also properties with "schema." prefix can be used.
+ *
+ * <p>Use "#" to denote an array of values where "#" represents one or more digits. Property
+ * versions like "format.property-version" must not be part of the supported properties.
+ *
+ * <p>See also {@link TableFactory#supportedProperties()} for more information.
+ */
+ List<String> supportedProperties();
+}
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/TableFactory.scala b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/TableFactory.scala
deleted file mode 100644
index a5dcc60..0000000
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/TableFactory.scala
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.factories
-
-import java.util
-
-/**
- * A factory to create different table-related instances from string-based properties. This
- * factory is used with Java's Service Provider Interfaces (SPI) for discovering. A factory is
- * called with a set of normalized properties that describe the desired configuration. The factory
- * allows for matching to the given set of properties.
- *
- * Classes that implement this interface can be added to the
- * "META_INF/services/org.apache.flink.table.factories.TableFactory" file of a JAR file in
- * the current classpath to be found.
- *
- * @see [[BatchTableSourceFactory]]
- * @see [[BatchTableSinkFactory]]
- * @see [[StreamTableSourceFactory]]
- * @see [[StreamTableSinkFactory]]
- * @see [[TableFormatFactory]]
- */
-trait TableFactory {
-
- /**
- * Specifies the context that this factory has been implemented for. The framework guarantees to
- * only match for this factory if the specified set of properties and values are met.
- *
- * Typical properties might be:
- * - connector.type
- * - format.type
- *
- * Specified property versions allow the framework to provide backwards compatible properties
- * in case of string format changes:
- * - connector.property-version
- * - format.property-version
- *
- * An empty context means that the factory matches for all requests.
- */
- def requiredContext(): util.Map[String, String]
-
- /**
- * List of property keys that this factory can handle. This method will be used for validation.
- * If a property is passed that this factory cannot handle, an exception will be thrown. The
- * list must not contain the keys that are specified by the context.
- *
- * Example properties might be:
- * - schema.#.type
- * - schema.#.name
- * - connector.topic
- * - format.line-delimiter
- * - format.ignore-parse-errors
- * - format.fields.#.type
- * - format.fields.#.name
- *
- * Note: Use "#" to denote an array of values where "#" represents one or more digits. Property
- * versions like "format.property-version" must not be part of the supported properties.
- *
- * In some cases it might be useful to declare wildcards "*". Wildcards can only be declared at
- * the end of a property key.
- *
- * For example, if an arbitrary format should be supported:
- * - format.*
- *
- * Note: Wildcards should be used with caution as they might swallow unsupported properties
- * and thus might lead to undesired behavior.
- */
- def supportedProperties(): util.List[String]
-}
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/TableFormatFactory.scala b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/TableFormatFactory.scala
deleted file mode 100644
index 9e42a15..0000000
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/TableFormatFactory.scala
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.factories
-
-import java.util
-
-/**
- * A factory to create configured table format instances based on string-based properties. See
- * also [[TableFactory]] for more information.
- *
- * @tparam T record type that the format produces or consumes
- * @see [[DeserializationSchemaFactory]]
- * @see [[SerializationSchemaFactory]]
- */
-trait TableFormatFactory[T] extends TableFactory {
-
- /**
- * Flag to indicate if the given format supports deriving information from a schema. If the
- * format can handle schema information, those properties must be added to the list of
- * supported properties.
- */
- def supportsSchemaDerivation(): Boolean
-
- /**
- * List of format property keys that this factory can handle. This method will be used for
- * validation. If a property is passed that this factory cannot handle, an exception will be
- * thrown. The list must not contain the keys that are specified by the context.
- *
- * Example format properties might be:
- * - format.line-delimiter
- * - format.ignore-parse-errors
- * - format.fields.#.type
- * - format.fields.#.name
- *
- * If schema derivation is enabled, the list must include schema properties:
- * - schema.#.name
- * - schema.#.type
- *
- * Note: All supported format properties must be prefixed with "format.". If schema derivation is
- * enabled, also properties with "schema." prefix can be used.
- *
- * Use "#" to denote an array of values where "#" represents one or more digits. Property
- * versions like "format.property-version" must not be part of the supported properties.
- *
- * @see See also [[TableFactory.supportedProperties()]] for more information.
- */
- def supportedProperties(): util.List[String]
-
-}