Skip to content

Commit

Permalink
Faster triple storage when not saving derivations.
Browse files Browse the repository at this point in the history
  • Loading branch information
balhoff committed Jan 10, 2018
1 parent 14b07c1 commit 728b6c5
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,13 @@ final class RuleEngine(inputRules: Iterable[Rule], val storeDerivations: Boolean
private val DegeneratePattern = TriplePattern(AnyNode, AnyNode, AnyNode)

protected[engine] def processTriple(triple: Triple, memory: WorkingMemory): Unit = {
if (!memory.facts(triple)) {
memory.facts += triple
if (memory.facts.add(triple)) {
memory.agenda = memory.agenda.enqueue(triple)
}

}

protected[engine] def processDerivedTriple(triple: Triple, derivation: Derivation, memory: WorkingMemory) = {
if (memory.facts.add(triple)) {
//if (memory.facts.size % 100000 == 0) println(memory.facts.size)
//memory.derivations = memory.derivations |+| Map(triple -> List(derivation))
memory.derivations += triple -> (derivation :: memory.derivations.getOrElse(triple, Nil))
memory.agenda = memory.agenda.enqueue(triple)
}
Expand Down

0 comments on commit 728b6c5

Please sign in to comment.