I am using Jira's SearchService for reporting againts large number of issues (>200K issues). Returning this many issues from a search and loading them into memory is clearly bad for the system. (Most of the time ends up with an OutOfMemory Exception)
On the other hand, SearchProvider.search() supports paging but each page has to be retrieved with a separate search() so searching repeatedly for different pages may return inconsistent data if the underlying data changes between your searches.
Keeping in mind that memory is the bottleneck:
I am working with Jira 7.x server but I prefer a solution that works on Jira 6.x as well, if possible.
P.S. I found some community answers in the site but most of them does not match my need or they are old and the api seems to be deprecated.
Hi,
Did you try smth low-level like this - https://docs.atlassian.com/software/jira/docs/api/7.3.3/com/atlassian/jira/issue/search/SearchProviderFactoryImpl.html ?
Thanks Anton,
I didn't try that and it sure looks promising.
While searching for a solution, I actually came across some other answers pointing to this but the answers mostly emphasized this was moved out of the API and the best way to go was to use SearchService. So I saw it as a deprecated api.
Anyway, I will try to derive a solution from here but it is hard to find a sample code about this. Any directions that will lead to a code sample will be greatly appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I implemented the SearchProvider approach and got very good results. It is poorly documented (as usual) so requires some trial and error but sure works.
Using this approach I made a search that only returns issueIDs (List<String>) which uses very little memory. Iterating through this list I retrieved each issue individually and let the issue reference go as soon as I was done. This made a HUGE positive impact on memory use because now GC can collect issue objects that are no longer necessary.
Here is the code sample to get the issueId list:
SearchProvider searchProvider = ComponentAccessor.getComponent(SearchProvider.class);
FieldHitCollector collector = new FieldHitCollector("issue_id");
List<String> values = collector.getValues();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.