mirror of
https://github.com/corda/corda.git
synced 2024-12-20 05:28:21 +00:00
ENT-6876: Optimised vault query to not query for total state count if the first page isn't full (#7449)
This commit is contained in:
parent
6a22494431
commit
5cdbec9ddf
@ -706,9 +706,6 @@ class NodeVaultService(
|
|||||||
paging: PageSpecification,
|
paging: PageSpecification,
|
||||||
sorting: Sort,
|
sorting: Sort,
|
||||||
contractStateType: Class<out T>): Vault.Page<T> {
|
contractStateType: Class<out T>): Vault.Page<T> {
|
||||||
// calculate total results where a page specification has been defined
|
|
||||||
val totalStatesAvailable = if (paging.isDefault) -1 else queryTotalStateCount(criteria, contractStateType)
|
|
||||||
|
|
||||||
val (query, stateTypes) = createQuery(criteria, contractStateType, sorting)
|
val (query, stateTypes) = createQuery(criteria, contractStateType, sorting)
|
||||||
query.setResultWindow(paging)
|
query.setResultWindow(paging)
|
||||||
|
|
||||||
@ -732,6 +729,13 @@ class NodeVaultService(
|
|||||||
ArrayList()
|
ArrayList()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val totalStatesAvailable = when {
|
||||||
|
paging.isDefault -> -1L
|
||||||
|
// If the first page isn't full then we know that's all the states that are available
|
||||||
|
paging.pageNumber == DEFAULT_PAGE_NUM && states.size < paging.pageSize -> states.size.toLong()
|
||||||
|
else -> queryTotalStateCount(criteria, contractStateType)
|
||||||
|
}
|
||||||
|
|
||||||
return Vault.Page(states, statesMetadata, totalStatesAvailable, stateTypes, otherResults)
|
return Vault.Page(states, statesMetadata, totalStatesAvailable, stateTypes, otherResults)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user