lambda_map_reduce 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 40060acb9db9afddd390172b73baf410326a9be9
4
+ data.tar.gz: b9eb6707700128e0e8a76b47984391c8337d9818
5
+ SHA512:
6
+ metadata.gz: 2278752f75071467ff6dfada0599d161992ed0a93294ea9bfd916db88a94eefef84ec7af0c5fa688bbb74e1f49a218fb80ca96b4b5fc599d9bcfcca0b2e0c6f9
7
+ data.tar.gz: 2fb0a2df70753ff1522d513bbff46ad6b71286d740814b9193d553539023af4b4873b43db97ecb421a1ae6367eed55ee5379944959290d7bed0364119438ef54
@@ -0,0 +1,15 @@
1
+ ## Welcome!
2
+
3
+ We're so glad you're thinking about contributing to an 18F open source project! If you're unsure or afraid of anything, just ask or submit the issue or pull request anyways. The worst that can happen is that you'll be politely asked to change something. We appreciate any sort of contribution, and don't want a wall of rules to get in the way of that.
4
+
5
+ Before contributing, we encourage you to read our CONTRIBUTING policy (you are here), our LICENSE, and our README, all of which should be in this repository. If you have any questions, or want to read more about our underlying policies, you can consult the 18F Open Source Policy GitHub repository at https://github.com/18f/open-source-policy, or just shoot us an email/official government letterhead note to [18f@gsa.gov](mailto:18f@gsa.gov).
6
+
7
+ ## Public domain
8
+
9
+ This project is in the public domain within the United States, and
10
+ copyright and related rights in the work worldwide are waived through
11
+ the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
12
+
13
+ All contributions to this project will be released under the CC0
14
+ dedication. By submitting a pull request, you are agreeing to comply
15
+ with this waiver of copyright interest.
@@ -0,0 +1,31 @@
1
+ As a work of the United States Government, this project is in the
2
+ public domain within the United States.
3
+
4
+ Additionally, we waive copyright and related rights in the work
5
+ worldwide through the CC0 1.0 Universal public domain dedication.
6
+
7
+ ## CC0 1.0 Universal Summary
8
+
9
+ This is a human-readable summary of the [Legal Code (read the full text)](https://creativecommons.org/publicdomain/zero/1.0/legalcode).
10
+
11
+ ### No Copyright
12
+
13
+ The person who associated a work with this deed has dedicated the work to
14
+ the public domain by waiving all of his or her rights to the work worldwide
15
+ under copyright law, including all related and neighboring rights, to the
16
+ extent allowed by law.
17
+
18
+ You can copy, modify, distribute and perform the work, even for commercial
19
+ purposes, all without asking permission.
20
+
21
+ ### Other Information
22
+
23
+ In no way are the patent or trademark rights of any person affected by CC0,
24
+ nor are the rights that other persons may have in the work or in how the
25
+ work is used, such as publicity or privacy rights.
26
+
27
+ Unless expressly stated otherwise, the person who associated a work with
28
+ this deed makes no warranties about the work, and disclaims liability for
29
+ all uses of the work, to the fullest extent permitted by applicable law.
30
+ When using or citing the work, you should not imply endorsement by the
31
+ author or the affirmer.
@@ -0,0 +1,58 @@
1
+ # `lambda_map_reduce` gem
2
+
3
+ A [MapReduce](https://research.google.com/archive/mapreduce.html)
4
+ implementation for use with
5
+ [lambdas](http://rubymonk.com/learning/books/1-ruby-primer/chapters/34-lambdas-and-blocks-in-ruby/lessons/77-lambdas-in-ruby).
6
+
7
+ ## Installation
8
+
9
+ Run `gem install lambda_map_reduce` on the command line or add `gem
10
+ 'lambda_map_reduce'` to your project's
11
+ [`Gemfile`](http://bundler.io/gemfile.html).
12
+
13
+ ## Usage
14
+
15
+ `LambdaMapReduce.map_reduce` takes an `Enumerable`, a `mapper` lambda, and a
16
+ `reducer` lambda.
17
+
18
+ The `mapper` lambda is called once for every item in the `Enumerable`. It
19
+ should take a single item and return an `Array` of `[key, value]` pairs.
20
+
21
+ The algorithm will shuffle all `value` items with the same `key` together, and
22
+ pass the resulting `[key, Array of values] Arrays` to the `reducer`, which
23
+ should return a single item.
24
+
25
+ The `mapper` and `reducer` may return `nil`. The result of the algorithm is
26
+ the `Array` of items produced from each `reducer` call.
27
+
28
+ An example from [the `team_api` gem's `CrossReferencer`
29
+ class](https://github.com/18F/team_api/blob/master/lib/team_api/cross_referencer.rb):
30
+
31
+ ```ruby
32
+ require 'lambda_map_reduce'
33
+
34
+ module TeamApi
35
+ class CrossReferencer
36
+ def self.create_tag_xrefs(site, items, category, xref_data)
37
+ items_to_tags = lambda do |item|
38
+ item_xref = xref_data.item_to_xref item
39
+ item[category].map { |tag| [tag, item_xref] } unless item[category].nil?
40
+ end
41
+ create_tag_xrefs = lambda do |tag, item_xrefs|
42
+ [tag, tag_xref(site, category, tag, item_xrefs)]
43
+ end
44
+ LambdaMapReduce.map_reduce(items, items_to_tags, create_tag_xrefs).to_h
45
+ end
46
+ end
47
+ end
48
+ ```
49
+
50
+ ## Public domain
51
+
52
+ This project is in the worldwide [public domain](LICENSE.md). As stated in [CONTRIBUTING](CONTRIBUTING.md):
53
+
54
+ > This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
55
+ >
56
+ > All contributions to this project will be released under the CC0
57
+ >dedication. By submitting a pull request, you are agreeing to comply
58
+ >with this waiver of copyright interest.
@@ -0,0 +1,4 @@
1
+ # @author Mike Bland (michael.bland@gsa.gov)
2
+
3
+ require_relative 'lambda_map_reduce/map_reduce'
4
+ require_relative 'lambda_map_reduce/version'
@@ -0,0 +1,12 @@
1
+ # @author Mike Bland (michael.bland@gsa.gov)
2
+
3
+ module LambdaMapReduce
4
+ # Returns an Array of objects after mapping and reducing items.
5
+ # mapper takes a single item and returns an Array of [key, value] pairs.
6
+ # reducer takes a [key, Array of values] pair and returns a single item.
7
+ def self.map_reduce(items, mapper, reducer)
8
+ items.flat_map { |item| mapper.call(item) }.compact
9
+ .each_with_object({}) { |kv, shuffle| (shuffle[kv[0]] ||= []) << kv[1] }
10
+ .map { |key, values| reducer.call(key, values) }.compact
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # @author Mike Bland (michael.bland@gsa.gov)
2
+
3
+ module LambdaMapReduce
4
+ VERSION = '0.0.0'
5
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lambda_map_reduce
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Bland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: go_script
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: about_yml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: This is a full implementation of the MapReduce algorithm specifically
112
+ for use with lambdas. It is useful for problems that are a natural fit for the MapReduce
113
+ model (such as building cross-references) when the data set fits easily within memory.
114
+ email:
115
+ - michael.bland@gsa.gov
116
+ executables: []
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - CONTRIBUTING.md
121
+ - LICENSE.md
122
+ - README.md
123
+ - lib/lambda_map_reduce.rb
124
+ - lib/lambda_map_reduce/map_reduce.rb
125
+ - lib/lambda_map_reduce/version.rb
126
+ homepage: https://github.com/18F/lambda_map_reduce
127
+ licenses:
128
+ - CC0
129
+ metadata: {}
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 2.4.5.1
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: A MapReduce implementation for use with lambdas
150
+ test_files: []