Skip to content

Commit

Permalink
Re:NationalSecurityAgency#879 - Removed trigger booleans, is page les…
Browse files Browse the repository at this point in the history
…s than requested page size, update status
  • Loading branch information
plainolneesh committed Jun 2, 2021
1 parent af7fe60 commit 7bd9ac2
Showing 1 changed file with 10 additions and 15 deletions.
Expand Up @@ -196,10 +196,14 @@ public ResultsPage next() throws Exception {
touch();
long pageStartTime = System.currentTimeMillis();
List<Object> resultList = new ArrayList<>();

int currentPageCount = 0;
long currentPageBytes = 0;
int maxPageSize = Math.min(this.settings.getPagesize(), this.logic.getMaxPageSize());

try {
addNDC();
int currentPageCount = 0;
long currentPageBytes = 0;


// test for any exceptions prior to loop as hasNext() would likely be false;
testForUncaughtException(resultList.size());
Expand Down Expand Up @@ -237,13 +241,9 @@ public ResultsPage next() throws Exception {
log.info("Query logic max results has been reached, aborting query.next call");
this.getMetric().setLifecycle(QueryMetric.Lifecycle.MAXRESULTS);
break;

} else if (numResults >= this.maxResults) {
log.info("Results are greater than max results, aborting query.next call");
this.getMetric().setLifecycle(BaseQueryMetric.Lifecycle.MAXRESULTS);
break;
}


if (this.logic.getMaxWork() >= 0 && (this.getMetric().getNextCount() + this.getMetric().getSeekCount()) >= this.logic.getMaxWork()) {
log.info("Query logic max work has been reached, aborting query.next call");
this.getMetric().setLifecycle(QueryMetric.Lifecycle.MAXWORK);
Expand All @@ -255,10 +255,9 @@ public ResultsPage next() throws Exception {
// this page.
long pageTimeInCall = (System.currentTimeMillis() - pageStartTime);

int maxPageSize = Math.min(this.settings.getPagesize(), this.logic.getMaxPageSize());
if (timing != null && currentPageCount > 0 && timing.shouldReturnPartialResults(currentPageCount, maxPageSize, pageTimeInCall)) {
log.info("Query logic max expire before page is full, returning existing results " + currentPageCount + " " + maxPageSize + " "
+ pageTimeInCall + " " + timing);
+ pageTimeInCall + " " + timing);
break;
}

Expand Down Expand Up @@ -334,13 +333,9 @@ public ResultsPage next() throws Exception {
}
}
}
if (resultList.isEmpty()) {
return new ResultsPage();
} else {
return new ResultsPage(resultList,ResultsPage.Status.PARTIAL);
}
ResultsPage.Status status = (currentPageCount < maxPageSize) ? ResultsPage.Status.PARTIAL : ResultsPage.Status.COMPLETE;
return new ResultsPage(resultList, status);
}

public void cancel() {
this.canceled = true;
// save off the future as it could be removed at any time
Expand Down

0 comments on commit 7bd9ac2

Please sign in to comment.