Conservative lookahead in reportloader_chunk

This commit is contained in:
Jiang Yio 2023-05-25 06:21:32 -04:00
parent cdbcc51927
commit 6fcd3825c8

View File

@ -292,7 +292,13 @@
} }
function data_endtime(data) { function data_endtime(data) {
for(var i = data.length - 1; i >= 0; --i) if((data[i].time) && (!isNaN(data[i].time))) return data[i].time; for(var i = data.length - 1, time; i >= 0; --i) if((time = data[i].time) && (!isNaN(time))) return time;
}
function data_endtime_conservative(data) {
var dt_end = data_endtime(data);
if(dt_end) for(var i = data.length - 1, time; i >= 0; --i) if((time = data[i].time) && (time > dt_end)) return time;
return dt_end;
} }
function data_interval(data) { function data_interval(data) {
@ -388,8 +394,7 @@
} else var res = []; } else var res = [];
if(hasmore) { // lookahead if(hasmore) { // lookahead
var batch = (await client.ORWRP_REPORT_TEXT_LONGCACHE(dfn, rpt_id, '', SZ_RANGE, '', -1, cursor.toFixed(9))).map(fn_map).sort((a, b) => b.time - a.time); var batch = (await client.ORWRP_REPORT_TEXT_LONGCACHE(dfn, rpt_id, '', SZ_RANGE, '', -1, cursor.toFixed(9))).map(fn_map).sort((a, b) => b.time - a.time);
res.dt_next = data_endtime(batch); if(res.dt_next = (batch.length >= SZ_WINDOW ? data_endtime_conservative : data_endtime)(batch)) res.next = strftime_vista(res.dt_next);
if(res.dt_next) res.next = strftime_vista(res.dt_next);
} }
if((!res.dt_next) && (cursor) && (data.length > 0) && ((res.length < 1) || (res[res.length - 1] !== data[data.length - 1]))) res.dt_next = strptime_vista(res.next = cursor); if((!res.dt_next) && (cursor) && (data.length > 0) && ((res.length < 1) || (res[res.length - 1] !== data[data.length - 1]))) res.dt_next = strptime_vista(res.next = cursor);
return res; return res;