Showing
8 changed files
with
75 additions
and
0 deletions
2018-1-java.iml
0 → 100644
pom.xml
0 → 100644
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 |
src/main/java/MapExample.java
0 → 100644
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 | +} |
src/main/java/valid.java
0 → 100644
src/test/java/testValid.java
0 → 100644
target/classes/MapExample.class
0 → 100644
No preview for this file type
target/classes/valid.class
0 → 100644
No preview for this file type
target/test-classes/testValid.class
0 → 100644
No preview for this file type
-
Please register or login to post a comment