신은섭(Shin Eun Seop)

add examples

1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<module type="JAVA_MODULE" version="4" />
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5 + <modelVersion>1.0.0</modelVersion>
6 +
7 + <groupId>cesco</groupId>
8 + <artifactId>Detecting_fraud_clicks</artifactId>
9 + <version>1.0-SNAPSHOT</version>
10 +
11 + <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
12 + <dependencies>
13 + <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
14 + <dependency>
15 + <groupId>org.apache.spark</groupId>
16 + <artifactId>spark-core_2.11</artifactId>
17 + <version>2.3.0</version>
18 + </dependency>
19 +
20 + </dependencies>
21 +
22 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +import org.apache.spark.SparkConf;
2 +import org.apache.spark.api.java.JavaRDD;
3 +import org.apache.spark.api.java.JavaSparkContext;
4 +import scala.Tuple2;
5 +
6 +import java.util.Arrays;
7 +import java.util.List;
8 +
9 +public class MapExample {
10 +
11 + static SparkConf conf = new SparkConf().setMaster("local[*]").setAppName("Cesco");
12 + static JavaSparkContext sc = new JavaSparkContext(conf);
13 +
14 + public static void main(String[] args) throws Exception {
15 +
16 + // Parallelized with 2 partitions
17 + JavaRDD<String> x = sc.parallelize(
18 + Arrays.asList("spark", "rdd", "example", "sample", "example"),
19 + 2);
20 +
21 + // Word Count Map Example
22 + JavaRDD<Tuple2<String, Integer>> y1 = x.map(e -> new Tuple2<>(e, 1));
23 + List<Tuple2<String, Integer>> list1 = y1.collect();
24 +
25 + // Another example of making tuple with string and it's length
26 + JavaRDD<Tuple2<String, Integer>> y2 = x.map(e -> new Tuple2<>(e, e.length()));
27 + List<Tuple2<String, Integer>> list2 = y2.collect();
28 +
29 + System.out.println(list1);
30 + }
31 +}
1 +public class valid {
2 + private int x;
3 +
4 + valid() {
5 + x = 0;
6 + }
7 +
8 + void printX(){
9 + System.out.println(x);
10 + }
11 +
12 + public static void main(String[] args){
13 + valid v = new valid();
14 + v.printX();
15 + }
16 +
17 +}
1 +public class testValid {
2 +
3 +}
No preview for this file type
No preview for this file type
No preview for this file type