Scala code in one day (7) and scala code in one day
Scala code in one day (7)
To better control spark, I recently studied scala language features, mainly reading "quick learning scala" and writing down some codes that I think are useful.
Package examplesclass Angela {// package visibility This specifies that this method can only be visible in the examples package // this pitfall was encountered during the Second Development of spark mllib, some mllib functions are visible to the package and cannot be accessed by other packages. // The solution is to name your program the same as the package where the function is located, such as org. apache. spark. mllib. xxxx. In this way, you can access some mllib classes and functions. private [examples] def sayHello = {println ("Hello! ") }}// Introduce the rename import java. util. {HashMap => JavaHashMap} // hide. In this case, the HashMap of java cannot be accessed and imported to java. util. {HashMap =>_} // both the introduction of renaming and hiding can solve conflicts (or overwrites) caused by the same class names of different packages. // you do not know when conflicts will occur, when will it be overwritten. remember that if the names of the classes used are the same, you must note that the simple and effective method of d is to rename // import java. lang. _ // import scala. _ // import Predef. _ object Example7 extends App {new StringBuilder}
Author: linger link: http://blog.csdn.net/lingerlanlan/article/details/43766311