TaskBuffer taskBuffer = taskBuffers.getUnchecked(taskId);
Page page = taskBuffer.getPage(pageToken);
if (page != null) {
headers.put(CONTENT_TYPE, PRESTO_PAGES);
headers.put(PRESTO_PAGE_NEXT_TOKEN, String.valueOf(pageToken + 1));
DynamicSliceOutput output = new DynamicSliceOutput(256);
PagesSerde.writePages(createTestingBlockEncodingManager(), output, page);
return new TestingResponse(HttpStatus.OK, headers.build(), output.slice().getInput());
}
else if (taskBuffer.isFinished()) {
headers.put(PRESTO_PAGE_NEXT_TOKEN, String.valueOf(pageToken));
return new TestingResponse(HttpStatus.GONE, headers.build(), new byte[0]);
}