-
Notifications
You must be signed in to change notification settings - Fork 28.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-12424][ML] The implementation of ParamMap#filter is wrong. #10381
Conversation
// Not using filterKeys also avoid SI-6654 | ||
val filtered = map.filter { | ||
case (k, _) => | ||
k.parent == parent.uid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the indent seems to be broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've fixed it.
LGTM except one minor comment. |
Test build #48008 has finished for PR 10381 at commit
|
Test build #48010 has finished for PR 10381 at commit
|
// returns the instance of collections.Map, not mutable.Map. | ||
// Otherwise, we get ClassCastException. | ||
// Not using filterKeys also avoid SI-6654 | ||
val filtered = map.filter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This could be on one line but I wouldn't change it
Test build #48019 has finished for PR 10381 at commit
|
cc: @mengxr @jkbradley |
LGTM |
// returns the instance of collections.Map, not mutable.Map. | ||
// Otherwise, we get ClassCastException. | ||
// Not using filterKeys also avoid SI-6654 | ||
val filtered = map.filter { case (k, _) => k.parent == parent.uid } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hasn't this changed the logic slightly? now you compare to parent.uid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original logic is wrong because the type of .parent
is String (this is a member of Param
) while the type of parameter parent
is Params
.
According to the implementation of Param
, the member parent
of Param
is passed uid
of Identifiable
which is a trait of Params
.
class Param[T](val parent: String, val name: String, val doc: String, val isValid: T => Boolean)
extends Serializable {
def this(parent: Identifiable, name: String, doc: String, isValid: T => Boolean) =
this(parent.uid, name, doc, isValid)
Test build #48364 has finished for PR 10381 at commit
|
Thanks @srowen , @BenFradet and @yanboliang for the review. I'm merging this into |
ParamMap#filter uses `mutable.Map#filterKeys`. The return type of `filterKey` is collection.Map, not mutable.Map but the result is casted to mutable.Map using `asInstanceOf` so we get `ClassCastException`. Also, the return type of Map#filterKeys is not Serializable. It's the issue of Scala (https://issues.scala-lang.org/browse/SI-6654). Author: Kousuke Saruta <[email protected]> Closes #10381 from sarutak/SPARK-12424. (cherry picked from commit 07165ca) Signed-off-by: Kousuke Saruta <[email protected]>
ParamMap#filter uses
mutable.Map#filterKeys
. The return type offilterKey
is collection.Map, not mutable.Map but the result is casted to mutable.Map usingasInstanceOf
so we getClassCastException
.Also, the return type of Map#filterKeys is not Serializable. It's the issue of Scala (https://issues.scala-lang.org/browse/SI-6654).