0

Please explain what is the meaning of term.## in following scala snippet. This is a snippet from apache spark.

Scala documentation says that ## returns zero. However, being a beginner I am not able to relate here.

/**
* Returns the index of the input term.
*/
@Since("1.1.0")
def indexOf(term: Any): Int = Utils.nonNegativeMod(term.##, numFeatures)


/* Calculates 'x' modulo 'mod', takes to consideration sign of x,
* i.e. if 'x' is negative, than 'x' % 'mod' is negative too
* so function return (x % mod) + mod in that case.
*/
def nonNegativeMod(x: Int, mod: Int): Int = {
val rawMod = x % mod
rawMod + (if (rawMod < 0) mod else 0)
}
zero323
  • 322,348
  • 103
  • 959
  • 935
Akshay Sharma
  • 49
  • 1
  • 5

0 Answers0