Handle incr exec of cases unhandled with introduced mem opt. Added test passes.
This commit is contained in:
parent
9aaf35561a
commit
ba8d00c224
|
|
@ -33,6 +33,8 @@ interface RuleMatchingProbe : RuleMatchingProbeState {
|
|||
|
||||
fun matches(): Collection<RuleMatchEx>
|
||||
|
||||
fun hasOccurrences(): Boolean
|
||||
|
||||
fun consume(ruleMatch: RuleMatchEx): RuleMatchingProbe
|
||||
|
||||
fun forget(ruleMatch: RuleMatchEx): RuleMatchingProbe
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ internal class ConstraintsProcessing(private var dispatchingFront: Dispatcher.Di
|
|||
resetStore() // clear observers
|
||||
val rules = ArrayList<Rule>().apply { ruleIndex.forEach { add(it) } }
|
||||
val principalState = dispatchingFront.state().filterValues { ruleMatcher ->
|
||||
ispec.isPrincipal(ruleMatcher.rule())
|
||||
ispec.isPrincipal(ruleMatcher.rule()) || ruleMatcher.probe().hasOccurrences()
|
||||
}
|
||||
return SessionTokenImpl(histView, rules, principalState, logicalState.clear())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,6 +247,8 @@ internal class ReteRuleMatcherImpl(private var ruleLookup: RuleLookup,
|
|||
nodeList.add(node)
|
||||
}
|
||||
|
||||
fun occurrencesCount() = introTrail.size()
|
||||
|
||||
fun containsOccurrence(occ: Occurrence): Boolean {
|
||||
return introTrail.contains(occ.identity)
|
||||
}
|
||||
|
|
@ -404,6 +406,10 @@ internal class ReteRuleMatcherImpl(private var ruleLookup: RuleLookup,
|
|||
nodesIt = layers.last().iterate()
|
||||
}
|
||||
|
||||
fun hasOccurrences(): Boolean {
|
||||
return layers.any { it.occurrencesCount() > 0 }
|
||||
}
|
||||
|
||||
fun reset(): Generation {
|
||||
this.nodesIt = layers.last().iterate()
|
||||
return this
|
||||
|
|
@ -510,6 +516,10 @@ internal class ReteRuleMatcherImpl(private var ruleLookup: RuleLookup,
|
|||
return this
|
||||
}
|
||||
|
||||
override fun hasOccurrences(): Boolean {
|
||||
return this.lastGeneration.hasOccurrences()
|
||||
}
|
||||
|
||||
override fun matches(): Collection<RuleMatchImpl> {
|
||||
return lastGeneration.matches
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ internal class RuleMatcherImpl(private var ruleLookup: RuleLookup,
|
|||
{
|
||||
override fun rule(): Rule = lookupRule()
|
||||
|
||||
override fun hasOccurrences(): Boolean = trunkNodes.size > 0 || leafNodes.size > 0
|
||||
|
||||
override fun matches(): Collection<RuleMatchImpl> =
|
||||
leafNodes
|
||||
.filter { node -> !consumedSignatures.contains(node.signature()) }
|
||||
|
|
|
|||
Loading…
Reference in New Issue