-
Notifications
You must be signed in to change notification settings - Fork 2
Ccdihub 4.10.0 #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.11.0
Are you sure you want to change the base?
Ccdihub 4.10.0 #59
Changes from all commits
d460403
6ab4c8c
e395db1
4fd83ba
5d2adbf
e1bda5a
e28e8a2
82fea93
415ee27
c898238
933e72e
3e00266
5ba533c
0d06c8d
afa7d36
71e6e47
38da623
3997d04
8639c8e
6d67faf
39bab6f
2347b6c
b4274ae
e2f9903
5caff92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ public class Const { | |
|
|
||
| public static class ES_UNITS { | ||
| public static final int DEFAULT_SIZE = 10; | ||
| public static final int MAX_SIZE = 10000; | ||
| public static final int MAX_SIZE = 200000; | ||
|
||
| public static final String GS_HIGHLIGHT_DELIMITER = "$"; | ||
| public static final String KEYWORD = ".keyword"; | ||
| } | ||
|
|
@@ -18,7 +18,7 @@ public static class ES_PARAMS { | |
|
|
||
| public static final String SORT_DIRECTION = "sort_direction"; | ||
| public static final String CASE_IDS = "case_ids"; | ||
| public static final int AGGS_SIZE = 1000; | ||
| public static final int AGGS_SIZE = 200000; | ||
|
||
| public static final String INPUT = "input"; | ||
| public static final String NESTED_FILTER = "FILTER_INFO"; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,7 +116,7 @@ private ResponseEntity<String> getGraphQLResponse(HttpEntity<String> httpEntity, | |
| JsonElement rawVar = jsonObject.get("variables"); | ||
| variables = gson.fromJson(rawVar, Map.class); | ||
| // Verify that all parameter inputs are less than 1000 values | ||
| int maxValues = 1000; | ||
| int maxValues = 200000; | ||
|
||
| for (String key: variables.keySet()){ | ||
| Object valuesObject = variables.get(key); | ||
| if (!(valuesObject instanceof List)){ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,11 +1,13 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package gov.nih.nci.bento.service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.gson.*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import gov.nih.nci.bento.model.ConfigurationDAO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import gov.nih.nci.bento.model.search.MultipleRequests; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import gov.nih.nci.bento.service.connector.AWSClient; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import gov.nih.nci.bento.service.connector.AbstractClient; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import gov.nih.nci.bento.service.connector.DefaultClient; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.http.util.EntityUtils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.logging.log4j.LogManager; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.logging.log4j.Logger; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -20,12 +22,18 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.io.IOException; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // import java.lang.management.ManagementFactory; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // import java.lang.management.MemoryMXBean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // import java.lang.management.MemoryUsage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Service("ESService") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public class ESService { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static final String SCROLL_ENDPOINT = "/_search/scroll"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static final String JSON_OBJECT = "jsonObject"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static final String AGGS = "aggs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static final int MAX_ES_SIZE = 10000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static final int MAX_ES_SIZE = 200000; // Do not return more than this number of records | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static final int SCROLL_THRESHOLD = 10000; // Use scroll when trying to retrieve past this number of records | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static final int SCROLL_SIZE = 10000; // How big each scroll should be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+36
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private static final Logger logger = LogManager.getLogger(RedisService.class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private RestClient client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -57,6 +65,32 @@ public JsonObject send(Request request) throws IOException{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| return getJSonFromResponse(response); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // public void checkMemoryInit() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // // Get the Java Runtime object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Runtime runtime = Runtime.getRuntime(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // // Get the maximum heap size (in bytes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // long maxMemory = runtime.maxMemory(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // // Get the initial heap size (in bytes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // long initialMemory = runtime.totalMemory(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // // Get the current available memory (in bytes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // long freeMemory = runtime.freeMemory(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // // Convert to MB for better readability | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // System.out.println("Initial Heap Size: " + (initialMemory / (1024 * 1024)) + " MB"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // System.out.println("Maximum Heap Size: " + (maxMemory / (1024 * 1024)) + " MB"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // System.out.println("Free Memory: " + (freeMemory / (1024 * 1024)) + " MB"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // public void checkMemoryNow() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // // Optionally log the memory usage using MemoryMXBean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // MemoryUsage heapMemoryUsage = memoryMXBean.getHeapMemoryUsage(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // System.out.println("Used Heap Memory: " + (heapMemoryUsage.getUsed() / (1024 * 1024)) + " MB"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // System.out.println("Committed Heap Memory: " + (heapMemoryUsage.getCommitted() / (1024 * 1024)) + " MB"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+68
to
+92
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public <T> Map<String, T> elasticMultiSend(@NotNull List<MultipleRequests> requests) throws IOException { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MultiSearchRequest multiRequests = new MultiSearchRequest(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -123,7 +157,7 @@ public Map<String, Object> buildListQuery(Map<String, Object> params, Set<String | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filter.add(Map.of( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "terms", Map.of( key, valueSet) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "terms", Map.of( key, valueSet) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -261,8 +295,6 @@ public Map<String, JsonObject> collectRangeAggs(JsonObject jsonObject, String[] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| return data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public List<String> collectBucketKeys(JsonArray buckets) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| List<String> keys = new ArrayList<>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (var bucket: buckets) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -274,7 +306,7 @@ public List<String> collectBucketKeys(JsonArray buckets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| public List<String> collectField(Request request, String fieldName) throws IOException { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| List<String> results = new ArrayList<>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request.addParameter("scroll", "10S"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request.addParameter("scroll", "1m"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| JsonObject jsonObject = send(request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| JsonArray searchHits = jsonObject.getAsJsonObject("hits").getAsJsonArray("hits"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -288,7 +320,7 @@ public List<String> collectField(Request request, String fieldName) throws IOExc | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Request scrollRequest = new Request("POST", SCROLL_ENDPOINT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String scrollId = jsonObject.get("_scroll_id").getAsString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Map<String, Object> scrollQuery = Map.of( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "scroll", "10S", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "scroll", "1m", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "scroll_id", scrollId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| scrollRequest.setJsonEntity(gson.toJson(scrollQuery)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -319,65 +351,112 @@ public List<Map<String, Object>> collectPage(Request request, Map<String, Object | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public List<Map<String, Object>> collectPage(Request request, Map<String, Object> query, String[][] properties, int pageSize, int offset) throws IOException { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // data over limit of Elasticsearch, have to use roll API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Make sure page size is less than max allowed size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pageSize > MAX_ES_SIZE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new IOException("Parameter 'first' must not exceeded " + MAX_ES_SIZE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pageSize + offset > MAX_ES_SIZE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Check whether to use scroll | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pageSize + offset > SCROLL_THRESHOLD) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return collectPageWithScroll(request, query, properties, pageSize, offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // data within limit can use just from/size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query.put("size", pageSize); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query.put("from", offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request.setJsonEntity(gson.toJson(query)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String queryJson = gson.toJson(query); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request.setJsonEntity(queryJson); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| JsonObject jsonObject = send(request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return collectPage(jsonObject, properties, pageSize); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // offset MUST be multiple of pageSize, otherwise the page won't be complete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Uses scroll to obtain results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param request The Opensearch request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param query The query to be sent in the body of the Opensearch request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param properties The Opensearch properties to retrieve | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param pageSize The desired number of results to obtain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param offset The desired offset of the results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @throws IOException | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private List<Map<String, Object>> collectPageWithScroll( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Request request, Map<String, Object> query, String[][] properties, int pageSize, int offset) throws IOException { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final int optimumSize = ( MAX_ES_SIZE / pageSize ) * pageSize; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (offset % pageSize != 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new IOException("'offset' must be multiple of 'first'!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query.put("size", optimumSize); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request.setJsonEntity(gson.toJson(query)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request.addParameter("scroll", "10S"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| JsonObject page = rollToPage(request, offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return collectPage(page, properties, pageSize, offset % optimumSize); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query.put("size", SCROLL_SIZE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String jsonizedQuery = gson.toJson(query); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request.setJsonEntity(jsonizedQuery); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request.addParameter("scroll", "1m"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // JsonObject page = rollToPage(request, pageSize, offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // return collectPage(page, properties, pageSize, offset % SCROLL_SIZE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // return collectPage(page, properties, pageSize, offset % SCROLL_SIZE); |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented-out debugging code. If memory monitoring is needed in production, it should be implemented properly with appropriate logging levels.
| // checkMemoryInit(); |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collectPageWithScroll always requests SCROLL_SIZE regardless of (pageSize, offset) and materializes all intermediate hits, which can overshoot and allocate far more data than needed; compute an adaptive first batch size (e.g. remainingNeeded = offsetRemainder + pageSize) and slice only required hits instead of filling an oversized JsonArray.
| query.put("size", SCROLL_SIZE); | |
| String jsonizedQuery = gson.toJson(query); | |
| request.setJsonEntity(jsonizedQuery); | |
| request.addParameter("scroll", "1m"); | |
| // JsonObject page = rollToPage(request, pageSize, offset); | |
| // return collectPage(page, properties, pageSize, offset % SCROLL_SIZE); | |
| JsonArray page = rollToPage(request, pageSize, offset); | |
| // checkMemoryInit(); | |
| return collectScrollPage(page, properties, pageSize, offset % SCROLL_SIZE); | |
| // Compute the minimum number of hits needed for the first batch | |
| int offsetRemainder = offset % SCROLL_SIZE; | |
| int remainingNeeded = offsetRemainder + pageSize; | |
| int firstBatchSize = Math.min(remainingNeeded, SCROLL_SIZE); | |
| query.put("size", firstBatchSize); | |
| String jsonizedQuery = gson.toJson(query); | |
| request.setJsonEntity(jsonizedQuery); | |
| request.addParameter("scroll", "1m"); | |
| JsonArray page = rollToPage(request, pageSize, offset); | |
| // Slice only the required hits from the page | |
| int startIdx = offsetRemainder; | |
| int endIdx = Math.min(startIdx + pageSize, page.size()); | |
| JsonArray slicedPage = new JsonArray(); | |
| for (int i = startIdx; i < endIdx; i++) { | |
| slicedPage.add(page.get(i)); | |
| } | |
| return collectScrollPage(slicedPage, properties, pageSize, 0); |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @return tag is missing a description. Please add a description of what this method returns (e.g., 'A JsonArray containing all hits from the scroll requests').
| * @return | |
| * @return A JsonArray containing all hits from the scroll requests, up to the requested page size and offset. |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented-out code. These variables are no longer needed since the method now returns a JsonArray directly.
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rollToPage adds entire scroll batches even when only a tail slice is needed for the requested page, causing unnecessary retention of possibly tens of thousands of documents; limit appended hits to the exact slice: compute startIndex = max(0, offset - (numCumulativeHits - numScrollHits)) and endIndex = min(numScrollHits, startIndex + (pageSize - allHits.size())).
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rollToPage adds entire scroll batches even when only a tail slice is needed for the requested page, causing unnecessary retention of possibly tens of thousands of documents; limit appended hits to the exact slice: compute startIndex = max(0, offset - (numCumulativeHits - numScrollHits)) and endIndex = min(numScrollHits, startIndex + (pageSize - allHits.size())).
| allHits.addAll(searchHits); | |
| // Compute the slice of hits to add | |
| int startIndex = Math.max(0, offset - (numCumulativeHits - numScrollHits)); | |
| int endIndex = Math.min(numScrollHits, startIndex + (pageSize - allHits.size())); | |
| for (int i = startIndex; i < endIndex; i++) { | |
| allHits.add(searchHits.get(i)); | |
| } |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scroll keep-alive value '1m' is duplicated; extract a constant (e.g. SCROLL_KEEPALIVE) to avoid divergence and ease future tuning.
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented-out code. The old JsonObject wrapping logic has been replaced by returning the JsonArray directly.
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented-out code. This old line extracts searchHits from a JsonObject, but the method now receives searchHits directly as a parameter.
| //JsonArray searchHits = jsonObject.getAsJsonObject("hits").getAsJsonArray("hits"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These memory management imports are unused in this class; remove them to avoid clutter.