This is sample code for Apache Hadoop Word Count using Scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hdfs dfs -cat /user/khannedy/small-word-count.txt/part-r-00000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AT-COMMAND. 1 | |
Android 1 | |
Dan 1 | |
Dengan 1 | |
GAK 1 | |
GAMMU 1 | |
Gateway 1 | |
Gateway. 1 | |
Integrasinya 1 | |
Java, 1 | |
NodeJS 1 | |
PAKE 1 | |
PHP, 1 | |
Pada 1 | |
RIBET, 1 | |
Ruby, 1 | |
SMS 2 | |
android 1 | |
apapun, 1 | |
aplikasi 4 | |
atau 2 | |
bahkan 1 | |
bisa 1 | |
buku 3 | |
cara 1 | |
colok 1 | |
dalam 2 | |
dan 2 | |
dapat 1 | |
dibuat 2 | |
digunakan 1 | |
driver 1 | |
gak 2 | |
gunakan 1 | |
ini 2 | |
ini, 1 | |
install 1 | |
itu 1 | |
kabel 1 | |
ke-3 1 | |
kita 2 | |
lagi 1 | |
mau 1 | |
membahas 1 | |
membuat 1 | |
menggunakan 2 | |
oleh 1 | |
paling 1 | |
pemrograman 1 | |
penting, 1 | |
perlu 2 | |
pihak 1 | |
pun 1 | |
saya 1 | |
sebagai 1 | |
segala 1 | |
semuanya. 1 | |
seperti 1 | |
serial 1 | |
teknologi 1 | |
tidak 2 | |
usah 2 | |
yang 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hadoop jar target/scala-2.11/hadoop-assembly-1.0.jar com.deepwissen.hadoop.WordCountApp /user/khannedy/small-artikel.txt /user/khannedy/small-word-count.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pada buku ini saya membahas cara membuat aplikasi | |
android yang dapat kita gunakan sebagai SMS Gateway. | |
Dengan aplikasi yang dibuat dalam buku ini, kita tidak | |
perlu lagi menggunakan aplikasi pihak ke-3 seperti | |
GAMMU atau bahkan tidak perlu menggunakan AT-COMMAND. | |
Dan yang paling penting, aplikasi Android SMS Gateway | |
yang dibuat dalam buku ini bisa digunakan oleh teknologi | |
atau pemrograman apapun, mau itu Java, PHP, Ruby, NodeJS | |
dan semuanya. Integrasinya pun GAK PAKE RIBET, gak usah | |
install driver dan gak usah colok kabel serial segala |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.deepwissen.hadoop | |
import java.lang.Iterable | |
import java.util.StringTokenizer | |
import org.apache.hadoop.conf.Configuration | |
import org.apache.hadoop.fs.{FileSystem, Path} | |
import org.apache.hadoop.io.{IntWritable, LongWritable, Text} | |
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat | |
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat | |
import org.apache.hadoop.mapreduce.{Job, Mapper, Reducer} | |
import scala.collection.JavaConversions._ | |
/** | |
* @author Eko Khannedy | |
* @since 2/15/15 | |
*/ | |
object WordCountApp extends App { | |
class WordCountMapper extends Mapper[LongWritable, Text, Text, IntWritable] { | |
override def map(key: LongWritable, value: Text, context: Mapper[LongWritable, Text, Text, IntWritable]#Context): Unit = { | |
val tokenizer = new StringTokenizer(value.toString) | |
while (tokenizer.hasMoreTokens) { | |
context.write(new Text(tokenizer.nextToken()), new IntWritable(1)) | |
} | |
} | |
} | |
class WordCountReducer extends Reducer[Text, IntWritable, Text, IntWritable] { | |
override def reduce(key: Text, values: Iterable[IntWritable], context: Reducer[Text, IntWritable, Text, IntWritable]#Context): Unit = { | |
val sum = values.foldLeft(0)(_ + _.get()) | |
context.write(key, new IntWritable(sum)) | |
} | |
} | |
// main app | |
val conf = new Configuration() | |
val job = Job.getInstance(conf, "Scala Word Count") | |
val filesystem = FileSystem.get(conf) | |
job.setJarByClass(getClass) | |
job.setMapperClass(classOf[WordCountMapper]) | |
job.setCombinerClass(classOf[WordCountReducer]) | |
job.setReducerClass(classOf[WordCountReducer]) | |
job.setOutputKeyClass(classOf[Text]) | |
job.setOutputValueClass(classOf[IntWritable]) | |
FileInputFormat.addInputPath(job, new Path(args(0))) | |
FileOutputFormat.setOutputPath(job, new Path(args(1))) | |
val result = job.waitForCompletion(true) | |
System.exit(if (result) 0 else 1) | |
} |
Pak,,saya ingin menampilkan data dari 2 tabel(yg ada di database) yang berbeda ke jtable,,caranya bagaimana ya.. Mohon pencerahanya.. Tks
mas kenapa saat di jalan di compt prom .kok scala nya gak jalan ?
Ayo update lagi tutorial menggunakan scala
eh ketemu pak dosenku