mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
Merge branch 'release/os/4.6' into christians/update-feat-20200502
This commit is contained in:
commit
2cb89897b4
@ -612,12 +612,15 @@ class HibernateQueryCriteriaParser(val contractStateType: Class<out ContractStat
|
||||
entityRoot
|
||||
}
|
||||
|
||||
val joinPredicate = if(IndirectStatePersistable::class.java.isAssignableFrom(entityRoot.javaType)) {
|
||||
criteriaBuilder.equal(vaultStates.get<PersistentStateRef>("stateRef"), entityRoot.get<IndirectStatePersistable<*>>("compositeKey").get<PersistentStateRef>("stateRef"))
|
||||
} else {
|
||||
criteriaBuilder.equal(vaultStates.get<PersistentStateRef>("stateRef"), entityRoot.get<PersistentStateRef>("stateRef"))
|
||||
if (entityRoot != vaultStates){ // to avoid self join
|
||||
val joinPredicate = if(IndirectStatePersistable::class.java.isAssignableFrom(entityRoot.javaType)) {
|
||||
criteriaBuilder.equal(vaultStates.get<PersistentStateRef>("stateRef"), entityRoot.get<IndirectStatePersistable<*>>("compositeKey").get<PersistentStateRef>("stateRef"))
|
||||
}
|
||||
else {
|
||||
criteriaBuilder.equal(vaultStates.get<PersistentStateRef>("stateRef"), entityRoot.get<PersistentStateRef>("stateRef"))
|
||||
}
|
||||
predicateSet.add(joinPredicate)
|
||||
}
|
||||
predicateSet.add(joinPredicate)
|
||||
|
||||
// resolve general criteria expressions
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
@ -501,6 +501,40 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
||||
assertThat(queriedStates).containsExactlyElementsOf(allStates)
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `query with sort criteria and pagination on large volume of states should complete in time`() {
|
||||
val numberOfStates = 1000
|
||||
val pageSize = 1000
|
||||
|
||||
for (i in 1..50) {
|
||||
database.transaction {
|
||||
vaultFiller.fillWithSomeTestLinearStates(numberOfStates, linearNumber = 100L)
|
||||
}
|
||||
}
|
||||
|
||||
val criteria = VaultQueryCriteria(status = Vault.StateStatus.ALL)
|
||||
|
||||
val sortAttribute = SortAttribute.Custom(DummyLinearStateSchemaV1.PersistentDummyLinearState::class.java, "stateRef")
|
||||
|
||||
Sort.Direction.values().forEach { sortDirection ->
|
||||
|
||||
val sorting = Sort(listOf(Sort.SortColumn(sortAttribute, sortDirection)))
|
||||
|
||||
val start = System.currentTimeMillis()
|
||||
val queriedStates = mutableListOf<StateAndRef<*>>()
|
||||
var pageNumber = 0
|
||||
while (pageNumber * pageSize < numberOfStates) {
|
||||
val paging = PageSpecification(pageNumber = pageNumber + 1, pageSize = pageSize)
|
||||
val page = vaultService.queryBy<DummyLinearContract.State>(sorting = sorting, paging = paging, criteria = criteria)
|
||||
queriedStates += page.states
|
||||
pageNumber++
|
||||
}
|
||||
|
||||
val elapsed = System.currentTimeMillis() - start
|
||||
assertThat(elapsed).isLessThan(1000)
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `unconsumed states with count`() {
|
||||
|
Loading…
Reference in New Issue
Block a user