Interface QueryContext
This interface represents the environment of the StructureQuery being executed. This interface is
consumed by StructureQueryConstraint implementations.
It consists mostly of accessors to the forest being searched. Some of them are backed by a per-execution cache and
have better amortized time compared to their counterparts from Forest.
There are also methods that help in mapping row ID to issue ID and vice versa.
-
Method Summary
Modifier and TypeMethodDescriptionintdepth(int idx) A shorthand forgetForest().getDepth(idx).LongArrayfilterIssues(Query query, LongList sortedIssues) Given the specified issue IDs (sorted in increasing order), returns those of them that match the specified JQL.Returns the forest being searched.booleanisIssue(int idx) Returnstrueif the row at the specified index into the forest being searched represents an issue.longissueId(int idx) If the row at the specified index into the forest being searched represents an issue, returns that issues' ID; otherwise, returns 0.intparent(int idx) Behaves asgetForest().getParentIndex(idx), but for many calls the amortized time is much less because of caching; for O(N) calls the amortized time is O(N) with N = size().LongIterableresolveIssueIdToRows(long issueId) Returns row IDs for rows in the forest being searched that represent issue with the specified ID.LongIterableresolveIssueKeyToRows(String issueKey) Returns row IDs for rows in the forest being searched that represent issues with the specified issue key.voidresolveRowIdsToIssues(LongIterator rows, boolean sorted, LongLongProcedure rowIssueCollector) Looks up the specified rows, and for each issue among them callsrowIssueCollectorwith row ID and issue ID, respectively.row(int idx) Returns a row object at the specified index in the forest being searched.longrowId(int idx) Returns row ID at the specified index in the forest being searched.LongIteratorrows(IntIterator indices) Given indices into the forest being searched, returns the corresponding rows.intsize()A shorthand forgetForest().size().intsubtreeEnd(int idx) Behaves asgetForest().getSubtreeEnd(idx), but for many calls the amortized time is much less because of caching; for O(N) calls the amortized time is O(N) with N = size().
-
Method Details
-
rowId
long rowId(int idx) Returns row ID at the specified index in the forest being searched. Basically, a shorthand forgetForest().getRow(idx).- Parameters:
idx- index into the forest being searched, must be not less than 0 and less thansize()- Returns:
- row ID
- Throws:
IndexOutOfBoundsException- ifidxis not within range[0 .. size()).- See Also:
-
row
Returns a row object at the specified index in the forest being searched. Basically, a shorthand forRowManager rm = ...; rm.getRow(getForest().getRow(idx)).- Parameters:
idx- index into the forest being searched, must be not less than 0 and less thansize()- Returns:
- row object
- Throws:
IndexOutOfBoundsException- ifidxis not within range[0 .. size()).- See Also:
-
rows
LongIterator rows(IntIterator indices) Given indices into the forest being searched, returns the corresponding rows. This behaves likegetForest().getRows().get(indices), but the result is computed on-demand (lazily).- Parameters:
indices- an iterator over indices into the forest being searched; each index must be not less than 0 and less thansize()- Returns:
- row IDs
- Throws:
IndexOutOfBoundsException- if any ofindicesis not within range[0 .. size()).- See Also:
-
isIssue
boolean isIssue(int idx) Returnstrueif the row at the specified index into the forest being searched represents an issue. The result is cached, so subsequent calls of this method during the computation of this query should be faster.- Parameters:
idx- index into the forest being searched, must be not less than 0 and less thansize()- Returns:
- true iff the row is an issue
- Throws:
IndexOutOfBoundsException- ifidxis not within range[0 .. size()).
-
issueId
long issueId(int idx) If the row at the specified index into the forest being searched represents an issue, returns that issues' ID; otherwise, returns 0. The result is cached, so subsequent calls of this method during the computation of this query should be faster.- Parameters:
idx- index into the forest being searched, must be not less than 0 and less thansize()- Returns:
- issue ID if the row is an issue, 0 otherwise
- Throws:
IndexOutOfBoundsException- ifidxis not within range[0 .. size()).
-
depth
int depth(int idx) A shorthand forgetForest().getDepth(idx).- Parameters:
idx- index into the forest being searched, must be not less than 0 and less thansize()- Returns:
- row depth
- Throws:
IndexOutOfBoundsException- ifidxis not within range[0 .. size()).- See Also:
-
size
int size()A shorthand forgetForest().size().- Returns:
- size of the forest being searched
- See Also:
-
parent
int parent(int idx) Behaves as
getForest().getParentIndex(idx), but for many calls the amortized time is much less because of caching; for O(N) calls the amortized time is O(N) with N = size().Not only the result for the requested index is cached, but also the results of all indices between the requested index and the returned index.
- Parameters:
idx- index into the forest being searched, must be not less than 0 and less thansize()- Returns:
- index of the parent row for the specified row
- Throws:
IndexOutOfBoundsException- ifidxis not within range[0 .. size()).- See Also:
-
subtreeEnd
int subtreeEnd(int idx) Behaves as
getForest().getSubtreeEnd(idx), but for many calls the amortized time is much less because of caching; for O(N) calls the amortized time is O(N) with N = size().Not only the result for the requested index is cached, but also the results of all indices between the requested index and the returned index.
- Parameters:
idx- index into the forest being searched, must be not less than 0 and less thansize()- Returns:
- next index after the end of this row's subtree
- Throws:
IndexOutOfBoundsException- ifidxis not within range[0 .. size()).- See Also:
-
getForest
Forest getForest()Returns the forest being searched.- Returns:
- the forest being searched
-
resolveRowIdsToIssues
void resolveRowIdsToIssues(LongIterator rows, boolean sorted, LongLongProcedure rowIssueCollector) Looks up the specified rows, and for each issue among them calls
rowIssueCollectorwith row ID and issue ID, respectively.This method reuses the same cache used by
isIssue(int)andissueId(int). Also, it uses a faster bulk row lookup method inRowManager.There are no guarantees on the order of calls to
rowIssueCollectorregardless ofsortedparameter.- Parameters:
rows- row IDs to resolvesorted- specifytrueif you can guarantee that the iterator produces strictly increasing values. Mind that here we talk about values ordered by row ID, not index into the forest being searched.rowIssueCollector- callback to receive(row ID, issue ID)for all rows amongrowsthat represent issues. The order of calls may not correspond to the order inrows.
-
filterIssues
LongArray filterIssues(Query query, LongList sortedIssues) Given the specified issue IDs (sorted in increasing order), returns those of them that match the specified JQL.
The order of elements in the returned is not specified.
- Parameters:
query- the JQL query objectsortedIssues- issue ID list, sorted in increasing order- Returns:
- ID list of issues matching the JQL, in unspecified order
-
resolveIssueIdToRows
LongIterable resolveIssueIdToRows(long issueId) Returns row IDs for rows in the forest being searched that represent issue with the specified ID.- Parameters:
issueId- ID of the issue (e.g., 10210)- Returns:
- row IDs for rows in the forest being searched that represent the issue
-
resolveIssueKeyToRows
Returns row IDs for rows in the forest being searched that represent issues with the specified issue key.- Parameters:
issueKey- key of the issue (e.g., FOO-123)- Returns:
- row IDs for rows in the forest being searched that represent the issue
-