Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6875377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:18:54+00:00 2026-05-27T04:18:54+00:00

I have a large dataset (about 1.1M documents) that I need to run mapreduce

  • 0

I have a large dataset (about 1.1M documents) that I need to run mapreduce on.

The field to group on is an array named xref. Due to the size of the collection and the fact I’m doing this in a 32-bit environment, I’m trying to reduce the collection to another collection in a new database.

First, here’s a data sample:

{ "_id" : ObjectId("4ec6d3aa61910ad451f12e01"), 
"bii" : -32.9867, 
"class" : 2456, 
"decdeg" : -82.4856, 
"lii" : 297.4896,
"name" : "HD 22237", 
"radeg" : 50.3284,
"vmag" : 8, 
"xref" : ["HD 22237", "CPD -82   65", "-82   64","PPM 376283", "SAO 258336",
          "CP-82   65","GC 4125" ] }

{ "_id" : ObjectId("4ec6d44661910ad451f78eba"), 
  "bii" : -32.9901, 
  "class" : 2450, 
  "decdeg" : -82.4781, 
  "decpm" : 0.013,
  "lii" : 297.4807, 
  "name" : "PPM 376283", 
  "radeg" : 50.3543, 
  "rapm" : 0.0357, 
  "vmag" : 8.4, 
  "xref" : ["HD 22237", "CPD -82   65", "-82   64","PPM 376283", "SAO 258336",
          "CP-82   65","GC 4125" ] }

{ "_id" : ObjectId("4ec6d48a61910ad451feae04"), 
  "bii" : -32.9903, 
  "class" : 2450, 
  "decdeg" : -82.4779, 
  "decpm" : 0.027,
  "hd_component" : 0, 
  "lii" : 297.4806, 
  "name" : "SAO 258336", 
  "radeg" : 50.3543, 
  "rapm" : 0.0355, 
  "vmag" : 8, 
"xref" : ["HD 22237", "CPD -82   65", "-82   64","PPM 376283", "SAO 258336",
          "CP-82   65","GC 4125" ] }

Here are the map and reduce functions (right now I’m only lii and bii fields):

function map() {
try {
    emit(this.xref, {lii:this.lii, bii:this.bii});
} catch(e) {
}
}

function reduce(key, values) {

var result = {xref:key, lii: 0.0, bii: 0.0};
try {
    values.forEach(function(value) {

        if (value.lii && value.bii) {
            result.lii += value.lii;
            result.bii += value.bii;
        }
    });

    result.bii /= values.length;
    result.lii /= values.length;
} catch(e) {
}

return result;
}

Unfortunately, running this eventually comes up with an error message:

db.catalog.mapReduce(map, reduce, {out:{replace:"catalog2", db:"astro2"}});

Wed Nov 23 10:12:25 uncaught exception: map reduce failed:{
    "assertion" : "_id cannot be an array",
    "assertionCode" : 10099,
    "errmsg" : "db assertion failure",
    "ok" : 0

The xref field IS an array, but all values are equal in that array. Is it trying to use that array as the id field in the new collections?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:18:55+00:00Added an answer on May 27, 2026 at 4:18 am

    Yes it is not possible to set _id as an array, because it has a special behavior for indexing.
    The key you emit by is used as _id in the output collection.
    Potentially this could work only with an “inline” output mode if the result is small, since it wont go to a collection.
    But ideally you would translate the array into a string (for example concat the values) and use that as _id, or make it a sub-object instead of an array.

    Also note that the result of your reduce function should not include the key.
    Just return {lii: .., bii: ..}

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large dataset with documents that sometimes cross-reference each other, sometimes do
I have a large dataset (over 100,000 records) that I wish to load into
Imagine you have a large dataset that may or may not be filtered by
I have a relatively large dataset of items (a few thousand items) that I
I have a rather large dataset in text file with about 25 million rows
I have a fairly large dataset (~1.4m rows) that I'm doing some splitting and
Interpolating Large Datasets I have a large data set of about 0.5million records representing
Say if I have a large dataset, the table has well over a million
I have a large ADO.Net dataset and two database schemas (Oracle) with different constraints.
I have a fairly large hierarchical dataset I'm importing. The total size of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.