Github user shivaram commented on a diff in the pull request:
https://github.com/apache/spark/pull/8458#discussion_r38950081
--- Diff: core/src/main/scala/org/apache/spark/api/r/RBackendHandler.scala
---
@@ -171,35 +183,58 @@ private[r] class RBackendHandler(server: RBackend)
}.toArray
}
- // Checks if the arguments passed in args matches the parameter types.
- // NOTE: Currently we do exact match. We may add type conversions later.
+ // Find a matching method in all methods of the same name of a class
+ // according to the passed arguments. Arguments may be converted in
+ // order to match a method.
+ //
+ // Returns a two-element tuple. The first element is the index of
+ // the matched method in the list of the methods of the same name.
+ // The second element is the list of converted arguments.
def matchMethod(
- numArgs: Int,
- args: Array[java.lang.Object],
- parameterTypes: Array[Class[_]]): Boolean = {
- if (parameterTypes.length != numArgs) {
- return false
- }
+ parameterTypesOfMethods: Array[Array[Class[_]]],
+ args: Array[Object]): (Option[Int], Array[Object]) = {
+ val numArgs = args.length
+
+ for (index <- 0 to parameterTypesOfMethods.length - 1) {
+ val parameterTypes = parameterTypesOfMethods(index)
+
+ if (parameterTypes.length == numArgs) {
+ val convertedArgs = new Array[Object](numArgs)
--- End diff --
Is there any reason we shouldn't modify `args` in place and make a copy ?
---
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]