You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "nickva (via GitHub)" <gi...@apache.org> on 2025/03/26 17:09:25 UTC
[PR] Implement topN/bottomN built-in reducers [couchdb]
nickva opened a new pull request, #5494:
URL: https://github.com/apache/couchdb/pull/5494
These should help use the already existing grouping and key sorting functionality to keep track of last update times, or top sales numbers or anything of that sort.
It's a bit tricky to have options for built-in reducers, so start with a few powers of ten: 1, 10, 100.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement topN/bottomN built-in reducers [couchdb]
Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson commented on PR #5494:
URL: https://github.com/apache/couchdb/pull/5494#issuecomment-2755918614
interesting
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement topN/bottomN built-in reducers [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on PR #5494:
URL: https://github.com/apache/couchdb/pull/5494#issuecomment-2758326186
> Nitpick/bikeshed: _top_N looks a little nicer than _topN
Good idea, Jan. I'll update it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement top_N/bottom_N built-in reducers [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva merged PR #5494:
URL: https://github.com/apache/couchdb/pull/5494
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement topN/bottomN built-in reducers [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on PR #5494:
URL: https://github.com/apache/couchdb/pull/5494#issuecomment-2755151026
Start with a draft pr to gauge interest. Needs tests obviously.
Here is a simple python script to try it out: https://gist.github.com/nickva/17c85d5e7081f31dca5a2bf3917ef2f3
With a simple map function to keep track of sales for some random years and months:
```javascript
function(doc){
emit([doc.year, doc.month], doc.sales);
}
```
```
% http $DB/db/_design/d1/_view/top10'?group=true&group_level=1&limit=3'
HTTP/1.1 200 OK
{
"rows": [
{
"key": [
2001
],
"value": [
931.021664033225,
829.0717011821488,
775.5360993378665,
683.0977590565661,
276.51499916212737,
266.4315223593118,
222.90260934980307,
216.76802801301613,
215.68095305906292,
209.32930207334888
]
},
{
"key": [
2002
],
"value": [
328966.2202201642,
5447.123292157605,
539.0773556077951,
307.63403941541753,
294.4198798831839,
281.49331767967436,
248.46343368068253,
245.5418654674753,
240.29692621507647,
235.05686309321763
]
},
{
"key": [
2003
],
"value": [
2349.6558110810374,
1782.184922248414,
1747.2645751778125,
1233.396982485958,
1030.6886567619686,
775.6718095876206,
752.2617494897446,
402.6604976482621,
382.0057134025877,
248.0430488012996
]
}
]
}
```
```
http $DB/db/_design/d1/_view/top1'?group=true&group_level=2&start_key=[2021]&limit=3'
HTTP/1.1 200 OK
{
"rows": [
{
"key": [
2021,
1
],
"value": [
145.47625983483155
]
},
{
"key": [
2021,
2
],
"value": [
250.70341326647355
]
},
{
"key": [
2021,
3
],
"value": [
4484.3909590737285
]
}
]
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement topN/bottomN built-in reducers [couchdb]
Posted by "janl (via GitHub)" <gi...@apache.org>.
janl commented on PR #5494:
URL: https://github.com/apache/couchdb/pull/5494#issuecomment-2757318967
very nice addition!
Nitpick/bikeshed: `_top_N` looks a little nicer than `_topN`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org