Maybe I misunderstand how MR works or maybe it is a problem with the Ruby
client.  I am trying to run the following job that will filter the keys as
the first phase. I am not using key filter, as the input will be a search
query.  But whatever I dod, the filtering reduce phase does not appear to
have any effect.  As a minimal example, in the reduce filter phase I simply
return an empty array, which I believe should stop any further processing,
but the job continues to return data.

For instance:

mr = Riak::MapReduce.new(riak)
mr.add('bucket', 'key')
mr.reduce("function(v) { return [] }", :keep => true))

This returns:
{"bucket"=>"key"}

Doing instead:

mr = Riak::MapReduce.new(riak)
mr.add('bucket', 'key')
mr.reduce("riak_kv_mapreduce:reduce_identity", :language => "erlang")
mr.reduce("function(v) { return [] }", :keep => true))

results in the same output.

If I place a map phase before the reduce phase:

mr = Riak::MapReduce.new(riak)
mr.add('bucket', 'key')
mr.map("function(v,e){ return [ v.bucket, v.key, e ] }")
mr.reduce("function(v) { return [] }", :keep => true)
mr.run

I get the expected output, an empty array: []. But this defeats the purpose,
which is to filter the keys in the reduce phase before the objects are
fetched from disk.

Can't a reduce phase appear before a map phase?

If it can, what am I doing wrong?  Or is this a bug?  Using Riak 1.0.0.

Elias
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to