Skip to content

Commit 6f05d3c

Browse files
committed
fix bug with too many reduced exchanges
1 parent bafd3ab commit 6f05d3c

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

api/routes/getExchanges.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function getExchanges(req, res) {
8080
} else if (options.reduce && options.interval) {
8181
return {error: 'cannot use reduce with interval', code: 400}
8282
} else if (options.reduce) {
83-
options.limit = req.query.limit ? options.limit : 50000
83+
options.limit = 10000
8484
} else if (options.limit > 1000) {
8585
options.limit = 1000
8686
} else if (options.interval &&
@@ -234,8 +234,15 @@ function getExchanges(req, res) {
234234
log.info(params.base.currency, params.counter.currency)
235235

236236
hbase.getExchanges(params, function(err, resp) {
237-
if (err) {
237+
if (err && err === 'too many rows') {
238+
errorResponse({
239+
code: 400,
240+
error: 'too many exchanges, use a smaller interval'
241+
})
242+
243+
} else if (err) {
238244
errorResponse(err)
245+
239246
} else if (params.reduce) {
240247
formatInterval(resp.reduced)
241248
resp.rows = [resp.reduced]

lib/hbase/hbase-thrift/data.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,15 @@ HbaseClient.getExchanges = function(options, callback) {
14871487
}, function(err, resp) {
14881488
var result
14891489

1490-
if (resp) {
1490+
if (resp &&
1491+
options.reduce &&
1492+
options.limit &&
1493+
resp.rows.length === options.limit &&
1494+
resp.marker) {
1495+
callback('too many rows')
1496+
return
1497+
1498+
} else if (resp) {
14911499
result = resp
14921500
} else {
14931501
result = {

0 commit comments

Comments
 (0)