Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Help with map reduce
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
james  
View profile  
 More options Jul 2 2011, 6:57 pm
From: james <jmslee...@gmail.com>
Date: Sat, 2 Jul 2011 15:57:25 -0700 (PDT)
Local: Sat, Jul 2 2011 6:57 pm
Subject: Help with map reduce
Hi,

I'm using the Python driver with v 1.8.1.

Having trouble getting reduce to work when there's only 1 document to
reduce.  No problems at all when there are >1 document to reduce for a
given key.

Here's an example illustrating my problem:

Source collection - "source-mr"
Output collection - "out-mr"

SOURCE COLLECTION
----------------------------------

> db["source-mr"].find()

{ "_id" : ObjectId("4e0f9c948d4528c39aee706c"), "x" : 1 }

MAP REDUCE CODE
----------------------------------
    m = Code("function() { "
             "  emit(this.x, 1);"
             "}");

    r = Code("function(key, values) {"
             "  return 2;"
             "}");

    res = db["source-mr"].map_reduce(m, r, query={}, out="out-mr")

OUTPUT COLLECTION
----------------------------------

> db["out-mr"].find()

{ "_id" : 1, "value" : 1 }

Reduce is not running or else I would see {"value": 2} in the output
collection.  If I add another document to my source collection with
the same key ("x": 1), reduce runs properly and I see {"value": 2} in
my output collection.

Thanks in advance for your help.

James


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Millman  
View profile  
 More options Jul 2 2011, 7:00 pm
From: Sam Millman <sam.mill...@gmail.com>
Date: Sun, 3 Jul 2011 00:00:03 +0100
Local: Sat, Jul 2 2011 7:00 pm
Subject: Re: [mongodb-user] Help with map reduce

Reduce will not run on a single document.

I am not sure why you need reduce to run on a single document since it just
designed to combine emitted data really...you finalize function does
post-processing stuff.

On 2 July 2011 23:57, james <jmslee...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bernie Hackett  
View profile  
 More options Jul 5 2011, 6:09 pm
From: Bernie Hackett <ber...@10gen.com>
Date: Tue, 5 Jul 2011 15:09:04 -0700 (PDT)
Local: Tues, Jul 5 2011 6:09 pm
Subject: Re: Help with map reduce
Sam is correct. In your example with only one document there isn't
anything to reduce. If you try your example in the mongo shell you
will get the same result. If you need to do any kind of post-
processing use the finalize parameter.

On Jul 2, 4:00 pm, Sam Millman <sam.mill...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »