bramble 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c78abeda625df09bdbbfbaa059768757a54380f9
4
- data.tar.gz: b641d188443171568abe011b22fc5b3ccf7083e6
3
+ metadata.gz: 2baaf8e5894d3d7673a6888e6eab091883520c7d
4
+ data.tar.gz: 55f0b6791f770a1a6fe710d3a98972677cdfed31
5
5
  SHA512:
6
- metadata.gz: 3d5e01178d77d2cd06c99634318835143dbdcb3ba203ecc6477cb7bb60d32019521d531660bc1a8f6e7eab258d0d55ec617113ee61e112c3e31a74a9094b655a
7
- data.tar.gz: a54391b20995074b7b16382d75823d247f9fb267f27bae2804db4ed5e97c3fc2fbd331cbf666e8a5d42817aafabe8a26c3f194148bf29cc6010876cd2763c4d4
6
+ metadata.gz: e081ada613296ab5d5a410bf0759b2a425610a3618ae2d0762b762ee25689e344b10d8a2943bdf45a9b9e22534ffc78c4aac36f22fa09db9fa4d957534e78e78
7
+ data.tar.gz: 4196394526521889d7d56a4f981fad5a7152847cdf62ee1146e0d5ac4411b392fc46b6578dafac648918320ec4af0750ef50d7f4499f1fe0be38e4baf10e859d
data/lib/bramble/keys.rb CHANGED
@@ -14,16 +14,20 @@ module Bramble
14
14
  "#{namespace(handle)}:keys"
15
15
  end
16
16
 
17
+ def map_total_count_key(handle)
18
+ "#{namespace(handle)}:map_total_count"
19
+ end
20
+
17
21
  def map_finished_count_key(handle)
18
22
  "#{namespace(handle)}:map_finished_count"
19
23
  end
20
24
 
21
- def reduce_finished_count_key(handle)
22
- "#{namespace(handle)}:reduce_finished_count"
25
+ def reduce_total_count_key(handle)
26
+ "#{namespace(handle)}:reduce_total_count"
23
27
  end
24
28
 
25
- def total_count_key(handle)
26
- "#{namespace(handle)}:total_count"
29
+ def reduce_finished_count_key(handle)
30
+ "#{namespace(handle)}:reduce_finished_count"
27
31
  end
28
32
 
29
33
  def result_key(handle)
data/lib/bramble/map.rb CHANGED
@@ -6,7 +6,7 @@ module Bramble
6
6
 
7
7
  def perform(handle, implementation, values)
8
8
  Bramble::State.running?(handle) do
9
- storage.set(total_count_key(handle), values.length)
9
+ storage.set(map_total_count_key(handle), values.length)
10
10
  values.each do |value|
11
11
  Bramble::MapJob.perform_later(handle, implementation.name, Bramble::Serialize.dump(value))
12
12
  end
@@ -25,10 +25,9 @@ module Bramble
25
25
  end
26
26
  Bramble::State.running?(handle) do
27
27
  finished = storage.increment(map_finished_count_key(handle))
28
- total = storage.get(total_count_key(handle)).to_i
28
+ total = storage.get(map_total_count_key(handle)).to_i
29
29
  if finished == total
30
30
  Bramble::Reduce.perform(handle, implementation)
31
- Bramble::State.clear_map(handle)
32
31
  end
33
32
  end
34
33
  end
@@ -5,9 +5,12 @@ module Bramble
5
5
  module_function
6
6
 
7
7
  def perform(handle, implementation)
8
- all_raw_keys = storage.map_keys_get(keys_key(handle))
9
- all_raw_keys.each do |raw_key|
10
- Bramble::ReduceJob.perform_later(handle, implementation.name, raw_key)
8
+ Bramble::State.running?(handle) do
9
+ all_raw_keys = storage.map_keys_get(keys_key(handle))
10
+ storage.set(reduce_total_count_key(handle), all_raw_keys.length)
11
+ all_raw_keys.each do |raw_key|
12
+ Bramble::ReduceJob.perform_later(handle, implementation.name, raw_key)
13
+ end
11
14
  end
12
15
  end
13
16
 
@@ -28,7 +28,7 @@ module Bramble
28
28
  private
29
29
 
30
30
  def total_count
31
- @total_count ||= storage.get(Bramble::Keys.total_count_key(handle)).to_i
31
+ @total_count ||= storage.get(Bramble::Keys.reduce_total_count_key(handle)).to_i
32
32
  end
33
33
 
34
34
  def finished_count
data/lib/bramble/state.rb CHANGED
@@ -38,11 +38,12 @@ module Bramble
38
38
  storage.delete(data_key(handle, group_key))
39
39
  end
40
40
  storage.delete(keys_key(handle))
41
+ storage.delete(map_total_count_key(handle))
41
42
  storage.delete(map_finished_count_key(handle))
42
43
  end
43
44
 
44
45
  def clear_reduce(handle)
45
- storage.delete(total_count_key(handle))
46
+ storage.delete(reduce_total_count_key(handle))
46
47
  storage.delete(reduce_finished_count_key(handle))
47
48
  storage.delete(result_key(handle))
48
49
  end
@@ -1,3 +1,3 @@
1
1
  module Bramble
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bramble
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo