Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/5514#discussion_r28447131
--- Diff: core/src/main/scala/org/apache/spark/SparkConf.scala ---
@@ -443,61 +461,55 @@ private[spark] object SparkConf extends Logging {
}
/**
- * Translate the configuration key if it is deprecated and has a
replacement, otherwise just
- * returns the provided key.
- *
- * @param userKey Configuration key from the user / caller.
- * @param warn Whether to print a warning if the key is deprecated.
Warnings will be printed
- * only once for each key.
+ * Looks for available deprecated keys for the given config option, and
return the first
+ * value available.
*/
- private def translateConfKey(userKey: String, warn: Boolean = false):
String = {
- deprecatedConfigs.get(userKey)
- .map { deprecatedKey =>
- if (warn) {
- deprecatedKey.warn()
- }
- deprecatedKey.newName.getOrElse(userKey)
- }.getOrElse(userKey)
+ def getDeprecatedConfig(key: String, conf: SparkConf): Option[String] = {
+ configsWithAlternatives.get(key).flatMap(
+ _.collectFirst {
+ case x if conf.contains(x.key) =>
+ val value = conf.get(x.key)
+ x.translation.map(_(value)).getOrElse(value)
+ })
+ }
+
+ /**
+ * Logs a warning message if the given config key is deprecated.
+ */
+ def logDeprecationWarning(key: String): Unit = {
+ deprecatedConfigs.get(key).foreach { cfg =>
+ logWarning(
+ s"The configuration key '$key' has been deprecated as of Spark
${cfg.version} and " +
+ s"may be removed in the future. ${cfg.deprecationMessage}")
+ }
+
+ allAlternatives.get(key).foreach { case (newKey, cfg) =>
+ logWarning(
+ s"The configuration key '$key' has been deprecated as of Spark
${cfg.version} and " +
+ s"and may be removed in the future. Please use the new key
'$newKey' instead.")
+ }
}
/**
- * Holds information about keys that have been deprecated or renamed.
+ * Holds information about keys that have been deprecated and do not
have a replacement.
--- End diff --
minor, but do you think it's more natural for `DeprecatedConfig` to hold
the key itself as one of its fields? Then we'll construct a map around a list
of such configs for easier access. Similarly for `AlternativeConfig`. I would
think that this class contains all the information I need to translate the
values (including the new key). Not a big deal if you don't change this.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]