Skip to content

Commit

Permalink
Rename matchMethod() to findMatchedSignature(). Update function descr…
Browse files Browse the repository at this point in the history
…iption.
  • Loading branch information
Sun Rui committed Sep 10, 2015
1 parent a7aa017 commit afad2c6
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions core/src/main/scala/org/apache/spark/api/r/RBackendHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private[r] class RBackendHandler(server: RBackend)
val methods = cls.getMethods
val selectedMethods = methods.filter(m => m.getName == methodName)
if (selectedMethods.length > 0) {
val index = matchMethod(
val index = findMatchedSignature(
selectedMethods.map(_.getParameterTypes),
args)

Expand All @@ -146,7 +146,7 @@ private[r] class RBackendHandler(server: RBackend)
} else if (methodName == "<init>") {
// methodName should be "<init>" for constructor
val ctors = cls.getConstructors
val index = matchMethod(
val index = findMatchedSignature(
ctors.map(_.getParameterTypes),
args)

Expand Down Expand Up @@ -183,13 +183,17 @@ private[r] class RBackendHandler(server: RBackend)
}.toArray
}

// 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.
// Find a matching method signature in an array of signatures of constructors
// or methods of the same name according to the passed arguments. Arguments
// may be converted in order to match a signature.
//
// Returns an Option[Int] which is the index of the matched method in
// the list of the methods of the same name.
def matchMethod(
// Note that in Java reflection, constructors and normal methods are of different
// classes, and share no parent class that provides methods for reflection uses.
// There is no unified way to handle them in this function. So an array of signatures
// is passed in instead of an array of candidate constructors or methods.
//
// Returns an Option[Int] which is the index of the matched signature in the array.
def findMatchedSignature(
parameterTypesOfMethods: Array[Array[Class[_]]],
args: Array[Object]): Option[Int] = {
val numArgs = args.length
Expand Down

0 comments on commit afad2c6

Please sign in to comment.