Scala code in one day (7) and scala code in one day

Source: Internet
Author: User
Tags spark mllib

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.