jmapreduce 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/wordcount.rb +1 -27
- data/release/jmapreduce.jar +0 -0
- metadata +5 -7
data/examples/wordcount.rb
CHANGED
@@ -12,33 +12,7 @@ JMapReduce.job 'Count' do
|
|
12
12
|
reduce do |key, values|
|
13
13
|
sum = 0
|
14
14
|
values.each {|v| sum += v }
|
15
|
-
emit(key,
|
15
|
+
emit(key, sum)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
JMapReduce.job "Histogram" do
|
20
|
-
setup do
|
21
|
-
RANGES = [0..1, 2..3, 4..5, 6..10, 11..20, 21..30, 31..40, 41..50, 51..100, 101..200, 201..300, 301..10_000, 10_001..99_999]
|
22
|
-
end
|
23
|
-
|
24
|
-
map do |word, count|
|
25
|
-
range = RANGES.find {|range| range.include?(count['sum']) }
|
26
|
-
emit("#{range.first.to_s.rjust(5,'0')}-#{range.last.to_s.rjust(5,'0')}", 1)
|
27
|
-
end
|
28
|
-
|
29
|
-
reduce do |range, counts|
|
30
|
-
total = counts.inject(0) {|sum,count| sum+count }
|
31
|
-
emit(range, '|'*(total/20))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# this job is just a pass though which takes advantage of the map/reduce shuffle to get ordered keys
|
36
|
-
JMapReduce.job "Sort" do
|
37
|
-
reduce_tasks 1
|
38
|
-
end
|
39
|
-
|
40
|
-
__END__
|
41
|
-
|
42
|
-
To run:
|
43
|
-
|
44
|
-
./bin/jmapreduce examples/wordcount.rb examples/alice.txt /tmp/output
|
data/release/jmapreduce.jar
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jmapreduce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 3
|
9
|
+
version: "0.3"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Abhinay Mehta
|
@@ -14,8 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-
|
18
|
-
default_executable:
|
17
|
+
date: 2012-02-29 00:00:00 Z
|
19
18
|
dependencies:
|
20
19
|
- !ruby/object:Gem::Dependency
|
21
20
|
name: jruby-jars
|
@@ -50,7 +49,6 @@ files:
|
|
50
49
|
- vendors/msgpack.jar
|
51
50
|
- examples/alice.txt
|
52
51
|
- examples/wordcount.rb
|
53
|
-
has_rdoc: true
|
54
52
|
homepage: https://bitbucket.org/abhinaymehta/jmapreduce
|
55
53
|
licenses: []
|
56
54
|
|
@@ -80,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
78
|
requirements: []
|
81
79
|
|
82
80
|
rubyforge_project:
|
83
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.7.2
|
84
82
|
signing_key:
|
85
83
|
specification_version: 3
|
86
84
|
summary: Map/Reduce Framework
|