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 matches(): Collection<RuleMatchEx>
|
||||||
|
|
||||||
|
fun hasOccurrences(): Boolean
|
||||||
|
|
||||||
fun consume(ruleMatch: RuleMatchEx): RuleMatchingProbe
|
fun consume(ruleMatch: RuleMatchEx): RuleMatchingProbe
|
||||||
|
|
||||||
fun forget(ruleMatch: RuleMatchEx): RuleMatchingProbe
|
fun forget(ruleMatch: RuleMatchEx): RuleMatchingProbe
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ internal class ConstraintsProcessing(private var dispatchingFront: Dispatcher.Di
|
||||||
resetStore() // clear observers
|
resetStore() // clear observers
|
||||||
val rules = ArrayList<Rule>().apply { ruleIndex.forEach { add(it) } }
|
val rules = ArrayList<Rule>().apply { ruleIndex.forEach { add(it) } }
|
||||||
val principalState = dispatchingFront.state().filterValues { ruleMatcher ->
|
val principalState = dispatchingFront.state().filterValues { ruleMatcher ->
|
||||||
ispec.isPrincipal(ruleMatcher.rule())
|
ispec.isPrincipal(ruleMatcher.rule()) || ruleMatcher.probe().hasOccurrences()
|
||||||
}
|
}
|
||||||
return SessionTokenImpl(histView, rules, principalState, logicalState.clear())
|
return SessionTokenImpl(histView, rules, principalState, logicalState.clear())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,8 @@ internal class ReteRuleMatcherImpl(private var ruleLookup: RuleLookup,
|
||||||
nodeList.add(node)
|
nodeList.add(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun occurrencesCount() = introTrail.size()
|
||||||
|
|
||||||
fun containsOccurrence(occ: Occurrence): Boolean {
|
fun containsOccurrence(occ: Occurrence): Boolean {
|
||||||
return introTrail.contains(occ.identity)
|
return introTrail.contains(occ.identity)
|
||||||
}
|
}
|
||||||
|
|
@ -404,6 +406,10 @@ internal class ReteRuleMatcherImpl(private var ruleLookup: RuleLookup,
|
||||||
nodesIt = layers.last().iterate()
|
nodesIt = layers.last().iterate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hasOccurrences(): Boolean {
|
||||||
|
return layers.any { it.occurrencesCount() > 0 }
|
||||||
|
}
|
||||||
|
|
||||||
fun reset(): Generation {
|
fun reset(): Generation {
|
||||||
this.nodesIt = layers.last().iterate()
|
this.nodesIt = layers.last().iterate()
|
||||||
return this
|
return this
|
||||||
|
|
@ -510,6 +516,10 @@ internal class ReteRuleMatcherImpl(private var ruleLookup: RuleLookup,
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun hasOccurrences(): Boolean {
|
||||||
|
return this.lastGeneration.hasOccurrences()
|
||||||
|
}
|
||||||
|
|
||||||
override fun matches(): Collection<RuleMatchImpl> {
|
override fun matches(): Collection<RuleMatchImpl> {
|
||||||
return lastGeneration.matches
|
return lastGeneration.matches
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@ internal class RuleMatcherImpl(private var ruleLookup: RuleLookup,
|
||||||
{
|
{
|
||||||
override fun rule(): Rule = lookupRule()
|
override fun rule(): Rule = lookupRule()
|
||||||
|
|
||||||
|
override fun hasOccurrences(): Boolean = trunkNodes.size > 0 || leafNodes.size > 0
|
||||||
|
|
||||||
override fun matches(): Collection<RuleMatchImpl> =
|
override fun matches(): Collection<RuleMatchImpl> =
|
||||||
leafNodes
|
leafNodes
|
||||||
.filter { node -> !consumedSignatures.contains(node.signature()) }
|
.filter { node -> !consumedSignatures.contains(node.signature()) }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue