You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/07/21 11:32:06 UTC

[GitHub] [flink] ChengkaiYang2022 commented on a diff in pull request #20316: [FLINK-27292][docs-zh] Translate the "Data Type Extraction" section of "Data Types" to Chinese

ChengkaiYang2022 commented on code in PR #20316:
URL: https://github.com/apache/flink/pull/20316#discussion_r926561585


##########
docs/content.zh/docs/dev/table/types.md:
##########
@@ -1558,25 +1558,18 @@ COALESCE(TRY_CAST('non-number' AS INT), 0) --- 结果返回数字 0 的 INT 格
 在下一个版本,这个参数会被移除。
 {{< /hint >}}
 
-Data Type Extraction
+数据类型提取
 --------------------
 
 {{< tabs "extraction" >}}
 {{< tab "Java/Scala" >}}
-At many locations in the API, Flink tries to automatically extract data type from class information using
-reflection to avoid repetitive manual schema work. However, extracting a data type reflectively is not always
-successful because logical information might be missing. Therefore, it might be necessary to add additional
-information close to a class or field declaration for supporting the extraction logic.
+在 API 中的很多地方,Flink 都尝试使用反射从类信息中自动提取数据类型,以避免重复手动定义 schema 的工作。但是,通过反射提取数据类型并不总是有效,因为可能会缺失逻辑信息。因此,可能需要在类或字段声明的附近添加额外信息以支持提取逻辑。

Review Comment:
   在 API 中的很多地方,Flink 都尝试利用反射机制从类信息中自动提取数据类型,以避免重复地手动定义 schema 。但是,通过反射提取数据类型并不总是有效的,因为有可能会缺失逻辑信息。因此,可能需要在类或字段声明的附近添加额外信息以支持提取逻辑。



##########
docs/content.zh/docs/dev/table/types.md:
##########
@@ -1558,25 +1558,18 @@ COALESCE(TRY_CAST('non-number' AS INT), 0) --- 结果返回数字 0 的 INT 格
 在下一个版本,这个参数会被移除。
 {{< /hint >}}
 
-Data Type Extraction
+数据类型提取
 --------------------
 
 {{< tabs "extraction" >}}
 {{< tab "Java/Scala" >}}
-At many locations in the API, Flink tries to automatically extract data type from class information using
-reflection to avoid repetitive manual schema work. However, extracting a data type reflectively is not always
-successful because logical information might be missing. Therefore, it might be necessary to add additional
-information close to a class or field declaration for supporting the extraction logic.
+在 API 中的很多地方,Flink 都尝试使用反射从类信息中自动提取数据类型,以避免重复手动定义 schema 的工作。但是,通过反射提取数据类型并不总是有效,因为可能会缺失逻辑信息。因此,可能需要在类或字段声明的附近添加额外信息以支持提取逻辑。
 
-The following table lists classes that can be implicitly mapped to a data type without requiring further information.
+下表列出了无需更多信息即可隐式映射到数据类型的类。
 
-If you intend to implement classes in Scala, *it is recommended to use boxed types* (e.g. `java.lang.Integer`)
-instead of Scala's primitives. Scala's primitives (e.g. `Int` or `Double`) are compiled to JVM primitives (e.g.
-`int`/`double`) and result in `NOT NULL` semantics as shown in the table below. Furthermore, Scala primitives that
-are used in generics (e.g. `java.util.Map[Int, Double]`) are erased during compilation and lead to class
-information similar to `java.util.Map[java.lang.Object, java.lang.Object]`.
+如果你打算在 Scala 中实现类,*建议使用包装类型*(例如 `java.lang.Integer`)而不是 Scala 的基本类型。如下表所示,Scala 的基本类型(例如 `Int` 或 `Double`)被编译为 JVM 基本类型(例如 `int`/`double`)并产生 `NOT NULL` 语义。此外,在泛型中使用的 Scala 基本类型(例如 `java.util.Map[Int, Double]`)在编译期间会被抹去,导致类信息类似于 `java.util.Map[java.lang.Object, java.lang.Object]`。

Review Comment:
   如果你打算在 Scala 中实现类,*建议使用包装类型*(例如 `java.lang.Integer`)而不是 Scala 的基本类型。如下表所示,Scala 的基本类型(例如 `Int` 或 `Double`)会被编译为 JVM 基本类型(例如 `int`/`double`)并产生 `NOT NULL` 语义。此外,在泛型中使用的 Scala 基本类型时(例如 `java.util.Map[Int, Double]`),基本类型在编译期间会被抹去,导致类信息类似于 `java.util.Map[java.lang.Object, java.lang.Object]`。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org