feat:首次提交
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package org.example;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
-- m.movieId,m.title,r.avg_rating
|
||||
create table `top_ten_avg_ratings`
|
||||
(
|
||||
`id` int(11) not null AUTO_INCREMENT comment '自增id',
|
||||
`movie_id` int(11) not null comment '电影id',
|
||||
`title` varchar(200) not null comment '电影名称',
|
||||
`avg_rating` decimal(10, 2) not null comment '电影名称',
|
||||
`update_time` datetime default current_timestamp comment '更新时间',
|
||||
primary key (`id`),
|
||||
unique key `movie_id_unique` (`movie_id`)
|
||||
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
|
||||
|
||||
CREATE TABLE genres_average_rating
|
||||
(
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`genres` VARCHAR(100) NOT NULL COMMENT '电影类别',
|
||||
`avg_rating` DECIMAL(10, 2) NOT NULL COMMENT '电影类别平均评分',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `genres_UNIQUE` (`genres`)
|
||||
) ENGINE = INNODB
|
||||
DEFAULT CHARSET = utf8;
|
||||
@@ -0,0 +1,4 @@
|
||||
log4j.rootLogger=error, stdout
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
|
||||
@@ -0,0 +1,3 @@
|
||||
hello world
|
||||
hello spark
|
||||
hello scala
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.example.spark
|
||||
|
||||
import org.apache.spark.{SparkConf, SparkContext}
|
||||
|
||||
object App {
|
||||
def main(args: Array[String]): Unit = {
|
||||
|
||||
val sparkConf = new SparkConf()
|
||||
.setMaster("local[2]")
|
||||
.setAppName("scala spark app")
|
||||
.set("spark.driver.host", "127.0.0.1")
|
||||
.set("spark.driver.bindAddress", "127.0.0.1")
|
||||
|
||||
val sc = new SparkContext(sparkConf)
|
||||
|
||||
val textFile = sc.textFile("src/main/resources/word.txt")
|
||||
|
||||
println(textFile.count())
|
||||
|
||||
val me = textFile.filter(line => line.contains("me"))
|
||||
println("me.collect() = " + me.collect().mkString(","))
|
||||
|
||||
val value = textFile
|
||||
.flatMap(_.split(" "))
|
||||
.map((_, 1))
|
||||
.reduceByKey(_+_)
|
||||
|
||||
println(value.collect().mkString("\n"))
|
||||
|
||||
|
||||
sc.stop()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.example.spark
|
||||
|
||||
import org.apache.spark.{SparkConf, SparkContext}
|
||||
|
||||
object test {
|
||||
def main(args: Array[String]): Unit = {
|
||||
val sc = new SparkContext(new SparkConf()
|
||||
.setMaster("local")
|
||||
.setAppName("test")
|
||||
.set("spark.driver.host", "127.0.0.1")
|
||||
.set("spark.driver.bindAddress", "127.0.0.1"))
|
||||
sc.textFile("src/main/resources/word.txt").foreach(println)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user