@PublicApi
public 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.
Modifier and Type | Method and Description |
---|---|
int |
depth(int idx)
A shorthand for
getForest().getDepth(idx) . |
LongArray |
filterIssues(Query query,
LongList sortedIssues)
Given the specified issue IDs (sorted in increasing order), returns those of them that match the specified JQL.
|
Forest |
getForest()
Returns the forest being searched.
|
boolean |
isIssue(int idx)
Returns
true if the row at the specified index into the forest being searched represents an issue. |
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.
|
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(). |
LongIterable |
resolveIssueIdToRows(long issueId)
Returns row IDs for rows in the forest being searched that represent issue with the specified ID.
|
LongIterable |
resolveIssueKeyToRows(String issueKey)
Returns row IDs for rows in the forest being searched that represent issues with the specified issue key.
|
void |
resolveRowIdsToIssues(LongIterator rows,
boolean sorted,
LongLongProcedure rowIssueCollector)
Looks up the specified rows, and for each issue among them calls
rowIssueCollector with row ID and issue ID,
respectively. |
StructureRow |
row(int idx)
Returns a row object at the specified index in the forest being searched.
|
long |
rowId(int idx)
Returns row ID at the specified index in the forest being searched.
|
LongIterator |
rows(IntIterator indices)
Given indices into the forest being searched, returns the corresponding rows.
|
int |
size()
A shorthand for
getForest().size() . |
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(). |
long rowId(int idx)
getForest().getRow(idx)
.idx
- index into the forest being searched, must be not less than 0 and less than size()
IndexOutOfBoundsException
- if idx
is not within range [0 .. size())
.Forest.getRow(int)
StructureRow row(int idx)
RowManager rm = ...; rm.getRow(getForest().getRow(idx))
.idx
- index into the forest being searched, must be not less than 0 and less than size()
IndexOutOfBoundsException
- if idx
is not within range [0 .. size())
.Forest.getRow(int)
,
RowRetriever.getRow(long)
LongIterator rows(IntIterator indices)
getForest().getRows().get(indices)
, but the result is computed on-demand (lazily).indices
- an iterator over indices into the forest being searched;
each index must be not less than 0 and less than size()
IndexOutOfBoundsException
- if any of indices
is not within range [0 .. size())
.Forest.getRow(int)
boolean isIssue(int idx)
true
if 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.idx
- index into the forest being searched, must be not less than 0 and less than size()
IndexOutOfBoundsException
- if idx
is not within range [0 .. size())
.long issueId(int idx)
idx
- index into the forest being searched, must be not less than 0 and less than size()
IndexOutOfBoundsException
- if idx
is not within range [0 .. size())
.int depth(int idx)
getForest().getDepth(idx)
.idx
- index into the forest being searched, must be not less than 0 and less than size()
IndexOutOfBoundsException
- if idx
is not within range [0 .. size())
.Forest.getDepth(int)
int size()
getForest().size()
.Forest.size()
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.
idx
- index into the forest being searched, must be not less than 0 and less than size()
IndexOutOfBoundsException
- if idx
is not within range [0 .. size())
.Forest.getParentIndex(int)
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.
idx
- index into the forest being searched, must be not less than 0 and less than size()
IndexOutOfBoundsException
- if idx
is not within range [0 .. size())
.Forest.getSubtreeEnd(int)
Forest getForest()
void resolveRowIdsToIssues(LongIterator rows, boolean sorted, LongLongProcedure rowIssueCollector)
Looks up the specified rows, and for each issue among them calls rowIssueCollector
with row ID and issue ID,
respectively.
This method reuses the same cache used by isIssue(int)
and issueId(int)
. Also, it uses a faster
bulk row lookup method in RowManager
.
There are no guarantees on the order of calls to rowIssueCollector
regardless of sorted
parameter.
rows
- row IDs to resolvesorted
- specify true
if 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 among rows
that represent
issues. The order of calls may not correspond to the order in rows
.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.
query
- the JQL query objectsortedIssues
- issue ID list, sorted in increasing orderLongIterable resolveIssueIdToRows(long issueId)
issueId
- ID of the issue (e.g., 10210)LongIterable resolveIssueKeyToRows(String issueKey)
issueKey
- key of the issue (e.g., FOO-123)Copyright © 2024 Tempo Software. All Rights Reserved.