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

  • Home
  • SEARCH
  • 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 5970405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:22:11+00:00 2026-05-22T20:22:11+00:00

if I have this collection { humidity : 96.5812, temperature : 10.5006 } {

  • 0

if I have this collection

{ "humidity" : 96.5812, "temperature" : 10.5006 }
{ "humidity" : 97.1184, "temperature" : 10.2808 }
{ "humidity" : 96.2882, "temperature" : 8.4493 }
{ "humidity" : 97.8266, "temperature" : 7.4481 }
{ "humidity" : 98.9255, "temperature" : 7.2772 }
{ "humidity" : 99.4628, "temperature" : 7.3993 }
{ "humidity" : 99.4383, "temperature" : 7.4237 }
{ "humidity" : 99.6825, "temperature" : 7.1307 }
{ "humidity" : 99.5116, "temperature" : 6.1539 }
{ "humidity" : 99.8779, "temperature" : 5.4701 }

how I can get the max and min value of temperature with mapreduce?

  • 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-22T20:22:12+00:00Added an answer on May 22, 2026 at 8:22 pm
    // Simple map function - just returns the temperature value
    // for the record
    var map = function() {
        emit('temperature', this.temperature);
    };
    
    // A reduce function to find the minimum value in the reduced set
    var reduce_min = function(key, values) {
        var min = values[0];
        values.forEach(function(val) {
            if (val < min) min = val;
        })
        return min;
    };
    
    // A reduce function to find the maximum value in the reduced set
    var reduce_max = function(key, values) {
        var max = values[0];
        values.forEach(function(val){
            if (val > max) max = val;
        })
        return max;
    }
    
    // Use the mapReduce function to get the min and max
    var min = db.temp.mapReduce(map, reduce_min, {out:{inline:1}}).results[0].value;
    var max = db.temp.mapReduce(map, reduce_max, {out:{inline:1}}).results[0].value;
    print("Min: " + min + ", max: " + max);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this class: public MyClass { public void initialize(Collection<String> data) { this.data =
I have this json which populates my collection ( TableListCollection ) of models (
I have Collection List<Car> . How to compare each item from this collection with
I have this timer function, it gives me following exception. Collection was modified; enumeration
I have a collection like this List<int> {1,15,17,8,3}; how to get a flat string
The situation is like this: I have an Observable Collection that has a bunch
Another easy one hopefully. Let's say I have a collection like this: List<DateTime> allDates;
I have 3 collection datatable that shows in this below Month: January ID NAME
I have a collection of MODS records that looks like this: <modsCollection> <mods [namespaces
Suppose I have a collection of files like this: echo -e apple\n cherry >>

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.