New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix _stats reducer when map function emits array #1484

Merged
merged 1 commit into from Aug 1, 2018

Conversation

Projects
None yet
2 participants
@iilyak
Contributor

iilyak commented Aug 1, 2018

Overview

According to documentation for _stats reduce function there is support for the case when map emits array of integers. This PR fixes this use case (fixup for 5fa3c43).

Testing recommendations

make check apps=couch tests=reduce_stats_test

and following reproducer script courtesy of @nickva

#!/bin/bash

S=${1:-adm:pass@localhost:15984}
DB=${2:-statsdb1}

curl -XDELETE $S/$DB
curl -XPUT $S/$DB

curl -s -XPOST $S/$DB -d '{"_id":"_design/dd2","views":{"v1":{"map":"function(doc){emit(null, doc.x) };","reduce":"_stats"}}}' -H 'Content-Type: application/json'
curl -s -XPOST $S/$DB -d '{"x": [1,2]}' -H 'Content-Type: application/json'

curl $S/$DB/_design/dd2/_view/v1

Related Issues or Pull Requests

Fixes #1377

Checklist

  • Code is written and works correctly;
  • Changes are covered by tests;
  • Documentation reflects the changes;

@iilyak iilyak force-pushed the cloudant:fix-stats-reducer-for-array branch from 63b418b to aeced65 Aug 1, 2018

@nickva

nickva approved these changes Aug 1, 2018

Well done

@iilyak iilyak merged commit 17aec1f into apache:master Aug 1, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@iilyak iilyak deleted the cloudant:fix-stats-reducer-for-array branch Aug 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment