Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/12498#discussion_r60240255
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/feature/HashingTF.scala ---
@@ -54,20 +60,43 @@ class HashingTF(val numFeatures: Int) extends
Serializable {
}
/**
+ * Set the hash algorithm used when mapping term to integer.
+ * (default: murmur3)
+ */
+ @Since("2.0.0")
+ def setHashAlgorithm(value: String): this.type = {
+ hashAlgorithm = value
+ this
+ }
+
+ /**
* Returns the index of the input term.
*/
@Since("1.1.0")
+ @deprecated("Use indexOfTerm instead. This method will be removed in
2.1.0.", "2.0.0")
def indexOf(term: Any): Int = Utils.nonNegativeMod(term.##, numFeatures)
/**
+ * Returns the index of the input term by different hash algorithms.
+ */
+ @Since("2.0.0")
+ def indexOfTerm(hashAlgorithm: String)(term: Any): Int = {
--- End diff --
Yes, but it doesn't quite make sense as a public API, since the user has
already specified the hashing algorithm. It should just accept the term like
`indexOf`. Of course, internally it's necessary to use the right algorithm, but
that can be saved off as a function from Any to Int whenever the setter is
called to change the algorithm. It's not even necessary to pick the algorithm
at runtime on every call.
---
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]