Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12498#discussion_r60304808
  
    --- 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 --
    
    You can't save it as a function whenever the setter is called since the 
ParamMap can be modified via ```Params.set```, bypassing the setHashAlgorithm 
method.  I'd recommend keeping ```indexOf``` (not deprecating it) and changing 
it to call getHashAlgorithm and compute the index based on the correct 
algorithm.  ```transform()``` just needs to make sure it only checks the 
hashAlgorithm once (rather than on each call to indexOf).


---
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]

Reply via email to