2, Scala simple example
Reference Tutorial: HTTPS://YQ.ALIYUN.COM/TOPIC/69 2.1 Interactive Programming
Spark-shell is spark interactive operating mode, provides interactive programming, side-knocking code side execution, do not need to create program source files, convenient debugging procedures, conducive to rapid learning spark.
[Root@node1 spark-2.2.0]# Bin/spark-shell Using Spark ' s default log4j prof
This is a Scala by Example from the official website.The example of how Scala is used in more detail after tutorial1.Programing with Actors and Message2.Expressions and Simple Functions3.first-class Functions4.Class and Objects5.Case Classes and Pattern Matching6.Generic Types and Methods7.Lists8.for-comprehensions9.Mu
The term "microservices architecture (microservice Architecture)" has been widely disseminated over the past few years, and it is used to describe a particular way of designing applications as a set of independently deployable services. At present, this architecture is not exactly defined, but in the organization around the business capabilities, automatic deployment (automated deployment), end intelligence (intelligence in the endpoints), language an
Brief introductionThere is no enumeration type in Scala, but the enumeration class is provided in the standard class library to produce enumerations. After extending the enumeration class, call the value method to initialize the possible values in the enumeration. The inner class value is actually an abstract class, and the real creation is Val. Because it's actually Val, you can pass in the ID and name for value If not specified, the ID is added to t
Package Yjmyzzimport Java.io.PrintWriterimport Java.util.Dateimport scala.io.Sourceobject ScalaApp02 {def main (args: Array[string]) {tupledemo println mapdemo println arraydemo println filewriteandread println (getu Rlcontent ("http://www.cnblogs.com/yjmyzz/")}/** * Tuple example */def Tupledemo = {//val represents a constant (equivalent to final in Java), VAR represents a variable Val tuple = ("Jimmy", +, New Date ())//This is more concise th
The program simply reads the data from the file and calculates it.Package com.bill.www/** * Created by Bill on 2016/2/3. * Purpose: Simple data calculation using Scala * source file: Interface record number of 20, including timestamp and floating-point data * execution: Scala Readfile.scala "E:\\spark\\data\\i_22_221000000073_l_ 20151016\\i_22_221000000073_l_20151016_223458.dat "* Development environment: W
Brief introductionThere are no enumeration types in Scala, but the enumeration class is provided in the standard class library to produce enumerations. After extending the enumeration class, call the value method class to initialize the possible values in the enumeration.The inner class value is actually an abstract class, and the real creation is Val. Because it is actually Val, you can pass in the ID and name for value. If not specified, the ID is a
Here's a simple Scala call-by-name example. I ' ll show the normal approach to writing a method and passing in a parameter, and then show a call-by-name (pass by name) Example. 1) A "Normal" Scala method
Here I show how to pass a parameter to a method "normally", i.e., call by value:
Object Test extends App {
def ti
After learning about some basic features of Scala, we can see its thread implementation: actor. I don't know if this is appropriate, because actor seems to focus on using message transmission to collaborate between entities. The prototype is as follows:
abstract class Actor extends Thread with MailBox{def act() : Unitoverride def run(): Unit = act()def !(msg: Any) = send(msg)}
From the source code of this version (The definition of actor and the abst
Cross-validation
method thought:
Crossvalidator divides the dataset into several subsets for training and testing respectively. When K=3, Crossvalidator produces 3 training data and test data pairs, each data is trained with 2/3 of the data, and 1/3 of the data is tested. For a specific set of parameter tables, Crossvalidator calculates the average of the evaluation criteria for the training model based on three sets of different training data and test data. After the optimal parameter table is
Original: https://my.oschina.net/u/877759/blog/501733
Write a scala multi-threaded demo to prepare for later use
Runnable/callable
Difference: runnable No return value, callable thread executes with return value
runnable Example
Importjava.util.concurrent. {Executors,executorservice} objecttest{defmain (args:Array[String]) {//Creating a thread pool valthreadpool:executorservice=
Executors.newfixedthreadpo
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.