zml1206 commented on code in PR #9914:
URL: https://github.com/apache/incubator-gluten/pull/9914#discussion_r2139108460
##########
gluten-core/src/main/scala/org/apache/spark/sql/internal/SparkConfigUtil.scala:
##########
@@ -16,11 +16,56 @@
*/
package org.apache.spark.sql.internal
+import org.apache.gluten.config.ConfigEntry
+
import org.apache.spark.SparkConf
-import org.apache.spark.internal.config.ConfigEntry
+import org.apache.spark.internal.config.{ConfigEntry => SparkConfigEntry}
object SparkConfigUtil {
- def getEntryValue[T](conf: SparkConf, entry: ConfigEntry[T]): T = {
+
+ implicit class RichSparkConf(val conf: SparkConf) {
+ def get[T](entry: SparkConfigEntry[T]): T = {
+ SparkConfigUtil.get(conf, entry)
+ }
+
+ def get[T](entry: ConfigEntry[T]): T = {
+ SparkConfigUtil.get(conf, entry)
+ }
+
+ def set[T](entry: SparkConfigEntry[T], value: T): SparkConf = {
+ SparkConfigUtil.set(conf, entry, value)
+ }
+
+ def set[T](entry: ConfigEntry[T], value: T): SparkConf = {
+ SparkConfigUtil.set(conf, entry, value)
+ }
+ }
+
+ def get[T](conf: SparkConf, entry: SparkConfigEntry[T]): T = {
conf.get(entry)
}
+
+ def get[T](conf: SparkConf, entry: ConfigEntry[T]): T = {
+ entry.valueConverter(conf.get(entry.key, entry.defaultValueString))
+ }
+
+ def get[T](conf: java.util.Map[String, String], entry: SparkConfigEntry[T]):
T = {
+ entry.valueConverter(conf.getOrDefault(entry.key,
entry.defaultValueString))
+ }
+
+ def get[T](conf: java.util.Map[String, String], entry: ConfigEntry[T]): T = {
+ entry.valueConverter(conf.getOrDefault(entry.key,
entry.defaultValueString))
+ }
+
+ def set[T](conf: SparkConf, entry: SparkConfigEntry[T], value: T): SparkConf
= {
+ conf.set(entry, value)
+ }
+
+ def set[T](conf: SparkConf, entry: ConfigEntry[T], value: T): SparkConf = {
+ value match {
+ case Some(v) => conf.set(entry.key, v.toString)
Review Comment:
Why use `v.toString` instead of `entry.stringConverter(v)`?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]