comparison service/mqtt_to_rdf/inference.py @ 1639:ae5ca4ba8954

rm unused computation
author drewp@bigasterisk.com
date Mon, 13 Sep 2021 01:54:49 -0700
parents 0ba1625037ae
children 4bb6f593ebf3
comparison
equal deleted inserted replaced
1638:0ba1625037ae 1639:ae5ca4ba8954
102 log.debug(f'{INDENT*6} {self}.advance has {augmentedWorkingSet=}') 102 log.debug(f'{INDENT*6} {self}.advance has {augmentedWorkingSet=}')
103 103
104 if self._advanceWithPlainMatches(augmentedWorkingSet): 104 if self._advanceWithPlainMatches(augmentedWorkingSet):
105 return 105 return
106 106
107 curBind = self.prev.currentBinding() if self.prev else CandidateBinding({}) 107 if self._advanceWithFunctions():
108 [lhsStmtBound] = curBind.apply([self.lhsStmt], returnBoundStatementsOnly=False)
109
110 fullWorkingSet = self.workingSet + self.parent.graph
111 boundFullWorkingSet = list(curBind.apply(fullWorkingSet, returnBoundStatementsOnly=False))
112 log.debug(f'{fullWorkingSet.__len__()=} {len(boundFullWorkingSet)=}')
113
114 if self._advanceWithFunctions(augmentedWorkingSet, boundFullWorkingSet, lhsStmtBound):
115 return 108 return
116 109
117 log.debug(f'{INDENT*6} {self} is past end') 110 log.debug(f'{INDENT*6} {self} is past end')
118 self._pastEnd = True 111 self._pastEnd = True
119 112
135 self._current = outBinding 128 self._current = outBinding
136 log.debug(f'{INDENT*7} new binding from {self} -> {outBinding}') 129 log.debug(f'{INDENT*7} new binding from {self} -> {outBinding}')
137 return True 130 return True
138 return False 131 return False
139 132
140 def _advanceWithFunctions(self, augmentedWorkingSet: Sequence[Triple], boundFullWorkingSet, lhsStmtBound) -> bool: 133 def _advanceWithFunctions(self) -> bool:
141 pred: Node = self.lhsStmt[1] 134 pred: Node = self.lhsStmt[1]
142 135
143 for functionType in functionsFor(pred): 136 for functionType in functionsFor(pred):
144 fn = functionType(self.lhsStmt, self.parent.graph) 137 fn = functionType(self.lhsStmt, self.parent.graph)
145 try: 138 try:
336 329
337 for b in existingRhsBnodes: 330 for b in existingRhsBnodes:
338 331
339 key = tuple(sorted(bound.binding.binding.items())), b 332 key = tuple(sorted(bound.binding.binding.items())), b
340 self.rhsBnodeMap.setdefault(key, BNode()) 333 self.rhsBnodeMap.setdefault(key, BNode())
341
342 try: 334 try:
343 bound.binding.addNewBindings(CandidateBinding({b: self.rhsBnodeMap[key]})) 335 bound.binding.addNewBindings(CandidateBinding({b: self.rhsBnodeMap[key]}))
344 except BindingConflict: 336 except BindingConflict:
345 continue 337 continue
346 338