Riak MapReduce in single node using javascript and python -


i want perform mapreduce job on data in riak db using javascript. stuck in begining, couldnot understand how returning value.

client = riak.riakclient() query = client.add('user') query.map("""             function(v){                var i=0;                i++;              return [i];              }          """)  result in query.run():     print "%s" % (result); 

for simplicity have checked above example.

here query bucket , user contain 5 sets of data in riakdb. think map() returns single value returns array 5 value, think equivalent 5 set of data in riakdb.

1 1 1 1 1 

and here, why can return array? treats each dataset independently, , returns each. think have 5 1's. due reason when process fetched data inside map(), returns gives unexpected result me.

so please give me suggestion. think basic thing couldnot it. highly appreciate help.

when run mapreduce job, map phase code sent out vnodes data stored , executed each value in data. resulting arrays collected , passed single reduce phase, returns array. if there sufficiently many results, reduce phase may run multiple times, previous reduce result , batch of map results input.

the fact getting 5 results implies 5 keys seen in bucket. there no global state shared between instances of map phase function, each have independent i, why each result 1.

you might try returning [v.key] have unique each one, or if values expected small, return [json.stringify(v)] can see entire structure passed map.

you should note according docs site javascript map reduce has been officially deprecated, may want use erlang functions new development.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -