@@ -11,9 +11,8 @@ is stored at auxiliary mongoDB collections.
1111This software depends in:
1212
1313- [ Lua 5.2] ( http://www.lua.org/ )
14- - [ pakozm/luamongo] ( https://github.com/pakozm/luamongo/ ) , a fork of
15- [ moai/luamongo] ( https://github.com/moai/luamongo ) for Lua 5.2 and with minor
16- improvements.
14+ - [ luamongo] ( https://github.com/moai/luamongo/ ) , mongoDB driver
15+ for Lua 5.2.
1716
1817Installation
1918------------
@@ -105,7 +104,8 @@ the same structure, they return a Lua table with two fields:
105104- ** init** function, which receives a table of arguments and allows to configure
106105 your module options, in case that you need any option.
107106
108- - ** func** function, which implements the necessary Lua code.
107+ - A function which implements the necessary Lua code for the operation. The name
108+ of the function is different for each operation.
109109
110110A map-reduce task is divided, at least, in the following modules:
111111
@@ -120,7 +120,7 @@ local init = function(arg)
120120end
121121return {
122122 init = init ,
123- func = function ()
123+ taskfn = function ()
124124 coroutine.yield (1 ," mapreduce/server.lua" )
125125 coroutine.yield (2 ," mapreduce/worker.lua" )
126126 coroutine.yield (3 ," mapreduce/test.lua" )
@@ -130,15 +130,17 @@ return {
130130```
131131
132132- ** mapfn.lua** is the script where the map function is implemented. The
133- ** func** field is executed as a standard Lua function, and receives tow
134- arguments ` (key,value) ` generated by one of the yields at your ` taskfn `
135- script. Map results are produced by calling the global function
133+ ** func** field is executed as a standard Lua function, and receives three
134+ arguments ` (key,value,emit) ` . The first two are generated b
135+ one of the yields at your ` taskfn `
136+ script. The third argument is a function. Map results
137+ are produced by calling the function
136138 ` emit(key,value) ` .
137139
138140``` Lua
139141return {
140142 init = function () end ,
141- func = function (key ,value )
143+ mapfn = function (key ,value , emit )
142144 for line in io.lines (value ) do
143145 for w in line :gmatch (" [^%s]+" ) do
144146 emit (w ,1 )
@@ -161,7 +163,7 @@ local offset_basis = 2166136261
161163local MAX = 2 ^ 32
162164return {
163165 init = function () end ,
164- func = function (key )
166+ partitionfn = function (key )
165167 -- compute hash
166168 local h = offset_basis
167169 for i = 1 ,# key do
@@ -186,7 +188,7 @@ return {
186188``` Lua
187189return {
188190 init = function () end ,
189- func = function (key ,values )
191+ reducefn = function (key ,values )
190192 local count = 0
191193 for _ ,v in ipairs (values ) do count = count + v end
192194 return count
@@ -204,7 +206,7 @@ return {
204206``` Lua
205207return {
206208 init = function () end ,
207- func = function (it )
209+ finalfn = function (it )
208210 for key ,value in it do
209211 print (value ,key )
210212 end
0 commit comments