Debian Codegraph @

Source/Reasoner/Kernel/Algorithm/CIndividualNodeBackendCacheHandler.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CIndividualNodeBackendCacheHandler.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Algorithm {
31
32 CIndividualNodeBackendCacheHandler::CIndividualNodeBackendCacheHandler(CBackendRepresentativeMemoryCacheReader* backAssCacheReader, CBackendRepresentativeMemoryCacheWriter* backAssCacheWriter) : CBackendAssociationCacheHandler(backAssCacheReader, backAssCacheWriter) {
33 }
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 bool CIndividualNodeBackendCacheHandler::determineAssociationBackendCardinality(CIndividualProcessNode* indiNode, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) {
49
50 function<void(CPROCESSHASH<cint64, CRoleCardinalityCountData>* superRoleTagUsedCardCountHash)> initFunc = [&](CPROCESSHASH<cint64, CRoleCardinalityCountData>* superRoleTagUsedCardCountHash)->void {
51 CReapplyConceptLabelSet* conSet = indiNode->getReapplyConceptLabelSet(false);
52 if (conSet) {
53 for (CConceptDescriptor* conSatDesIt = conSet->getAddingSortedConceptDescriptionLinker(); conSatDesIt; conSatDesIt = conSatDesIt->getNext()) {
54 CConcept* concept = conSatDesIt->getConcept();
55 bool negation = conSatDesIt->isNegated();
56 cint64 conOpCode = concept->getOperatorCode();
57 if (!negation && conOpCode == CCATMOST || negation && conOpCode == CCATLEAST) {
58 CRole* role = concept->getRole();
59 cint64 cardinality = concept->getParameter();
60 if (negation && conOpCode == CCATLEAST) {
61 cardinality = cardinality - 1;
62 }
63 CRoleCardinalityCountData& cardCountData = (*superRoleTagUsedCardCountHash)[role->getRoleTag()];
64 if (!cardCountData.mHasRestrictingCardinality) {
65 cardCountData.mHasRestrictingCardinality = true;
66 cardCountData.mRestrictingCardinality = cardinality;
67 } else {
68 cardCountData.mRestrictingCardinality = qMin(cardCountData.mRestrictingCardinality, cardinality);
69 }
70 }
71 }
72 }
73 };
74 return CBackendAssociationCacheHandler::determineCardinalityAssociationBackendItem(initFunc, roleUsedCardHash, false, tmpAssWriteDataLinker, calcAlgContext);
75 }
76
77
78
79
80
81
82
83
84
85
86 bool CIndividualNodeBackendCacheHandler::determineFullConceptSetLabelAssociationBackendItemWithSeparatedDeterministicNode(CIndividualProcessNode* extractionIndiNode, CIndividualProcessNode* deterministicConSetNode, CIndividualProcessNode* indiNode, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) {
87 CReapplyConceptLabelSet* conSet = extractionIndiNode->getReapplyConceptLabelSet(false);
88 if (!conSet) {
89 return false;
90 }
91
92 CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = getIndividualAssociationDataFromIndividualNode(indiNode, calcAlgContext);
93
94 cint64 maxDetBranchTag = calcAlgContext->getProcessingDataBox()->getMaximumDeterministicBranchTag();
95
96 bool deterministic = false;
97 bool excludePositiveNominalConcepts = true;
98
99 bool nondeterministicElements = false;
100
101
102 CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* >* signatureTmpConSetRefLabelHash = mSignatureTmpDetConSetRefLabelHash;
103 if (!deterministic) {
104 signatureTmpConSetRefLabelHash = mSignatureTmpNonDetConSetRefLabelHash;
105 }
106
107 function<bool(CConcept* concept, bool negation)> exclusionDetermineFunction = [&](CConcept* concept, bool negation)->bool {
108 if (excludePositiveNominalConcepts && concept->getOperatorCode() == CCNOMINAL && !negation) {
109 return false;
110 }
111 return true;
112 };
113
114 function<bool(CConcept* concept, bool negation, CDependencyTrackPoint* depTrackPoint)> deterministicDetermineFunction = [&](CConcept* concept, bool negation, CDependencyTrackPoint* depTrackPoint)->bool {
115 bool deterministic = true;
116 if (deterministicConSetNode != extractionIndiNode) {
117 CConceptDescriptor* conDes = nullptr;
118 CDependencyTrackPoint* detIndiDepTrackPoint = nullptr;
119 if (deterministicConSetNode->getReapplyConceptLabelSet(false)->getConceptDescriptor(concept, conDes, detIndiDepTrackPoint)) {
120 deterministic = true;
121 if (!detIndiDepTrackPoint || detIndiDepTrackPoint->getBranchingTag() > maxDetBranchTag) {
122 deterministic = false;
123 }
124 } else {
125 deterministic = false;
126 }
127 } else {
128 if (!depTrackPoint || depTrackPoint->getBranchingTag() > maxDetBranchTag) {
129 deterministic = false;
130 }
131 }
132 if (!deterministic) {
133 nondeterministicElements = true;
134 }
135 return deterministic;
136 };
137
138 cint64 conCount = conSet->getConceptCount();
139 cint64 conSetSigValue = CBackendRepresentativeMemoryCacheUtilities::getConceptDescriptorSignature(conSet->getAddingSortedConceptDescriptionLinker(), conCount, exclusionDetermineFunction, deterministicDetermineFunction);
140
141
142 if (conCount > 0) {
143
144 CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getFullConceptSetLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL, conSetSigValue, conCount, conSet->getAddingSortedConceptDescriptionLinker(), exclusionDetermineFunction, deterministicDetermineFunction);
145
146 if (cachedLabelItem) {
147 ++mStatReusedCachedLabels;
148 tmpAssWriteDataLinker->setReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL, cachedLabelItem);
149 return true;
150 }
151
152
153 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*& prevTempRefLabels = (*signatureTmpConSetRefLabelHash)[conSetSigValue];
154 if (prevTempRefLabels) {
155 for (CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* prevTempRefLabelIt = prevTempRefLabels; prevTempRefLabelIt; prevTempRefLabelIt = prevTempRefLabelIt->getNext()) {
156 if (prevTempRefLabelIt->getCacheValueCount() == conCount) {
157 bool compatibleConcepts = true;
158 for (CBackendRepresentativeMemoryLabelValueLinker* labelValueLinkerIt = prevTempRefLabelIt->getCacheValueLinker(); labelValueLinkerIt && compatibleConcepts; labelValueLinkerIt = labelValueLinkerIt->getNext()) {
159 CCacheValue cacheValue = labelValueLinkerIt->getCacheValue();
160 CConcept* concept = (CConcept*)cacheValue.getIdentification();
161 bool negation = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDNEGATEDCONCEPT || cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_NEGATED_CONCEPT;
162 bool deterministic = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDNEGATEDCONCEPT || cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDCONCEPT;
163
164 if (excludePositiveNominalConcepts && concept->getOperatorCode() == CCNOMINAL && !negation) {
165 compatibleConcepts = false;
166 }
167
168 CConceptDescriptor* conDes = nullptr;
169 CDependencyTrackPoint* depTrackPoint = nullptr;
170 if (!conSet->getConceptDescriptor(concept, conDes, depTrackPoint)) {
171 compatibleConcepts = false;
172 } else if (negation != conDes->isNegated()) {
173 compatibleConcepts = false;
174 } else if (deterministicDetermineFunction(concept, negation, depTrackPoint) != deterministic) {
175 compatibleConcepts = false;
176 }
177 }
178 if (compatibleConcepts) {
179 ++mStatReusedHashedSignatureLabels;
180 ++mStatReusedTempLabels;
181 tmpAssWriteDataLinker->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL, prevTempRefLabelIt);
182 return true;
183 }
184 }
185 }
186 }
187
188
189 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker >::allocateAndConstruct(mMemAllocMan);
190 newTempRefLabel->initLabelWriteData(conSetSigValue, CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL);
191 newTempRefLabel->setCompletelySaturated(false);
192 newTempRefLabel->setCompletelyHandled(true);
193 newTempRefLabel->setCompletelyPropagated(true);
194 for (CConceptDescriptor* conDesIt = conSet->getAddingSortedConceptDescriptionLinker(); conDesIt; conDesIt = conDesIt->getNext()) {
195 CConcept* concept = conDesIt->getConcept();
196 bool negation = conDesIt->isNegated();
197
198 bool considerConcept = exclusionDetermineFunction(concept, negation);
199 if (considerConcept) {
200 bool deterministic = deterministicDetermineFunction(concept, negation, conDesIt->getDependencyTrackPoint());
201 CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan);
202 labelValueLinker->initLabelValueLinker(getCacheValue(concept, negation, deterministic));
203 newTempRefLabel->appendCacheValueLinker(labelValueLinker);
204 }
205 }
206 newTempRefLabel->setNondeterministicElements(nondeterministicElements);
207 mNewTmpLabelList->append(newTempRefLabel);
208 ++mStatCreatedTempLabels;
209
210 tmpAssWriteDataLinker->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL, newTempRefLabel);
211 prevTempRefLabels = newTempRefLabel->append(prevTempRefLabels);
212 return true;
213 } else {
214 return false;
215 }
216 }
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239 bool CIndividualNodeBackendCacheHandler::determineNondeterministicConceptSetLabelAssociationBackendItemWithExcludedConceptsFromDeterministicLabel(CIndividualProcessNode* extractionIndiNode, CIndividualProcessNode* indiNode, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) {
240 CReapplyConceptLabelSet* conSet = extractionIndiNode->getReapplyConceptLabelSet(false);
241 if (!conSet) {
242 return false;
243 }
244
245 CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = getIndividualAssociationDataFromIndividualNode(indiNode, calcAlgContext);
246
247
248 bool deterministic = false;
249 bool excludePositiveNominalConcepts = true;
250
251 CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* >* signatureTmpConSetRefLabelHash = mSignatureTmpDetConSetRefLabelHash;
252 if (!deterministic) {
253 signatureTmpConSetRefLabelHash = mSignatureTmpNonDetConSetRefLabelHash;
254 }
255
256 function<bool(CConcept* concept, bool negation)> exclusionDetermineFunction = [&](CConcept* concept, bool negation)->bool {
257 if (excludePositiveNominalConcepts && concept->getOperatorCode() == CCNOMINAL && !negation) {
258 return false;
259 }
260 if (hasConceptInAssociatedDeterministicConceptSetLabel(indiAssData, concept, negation, calcAlgContext)) {
261 return false;
262 }
263 return true;
264 };
265
266 cint64 conCount = conSet->getConceptCount();
267 cint64 conSetSigValue = CBackendRepresentativeMemoryCacheUtilities::getConceptDescriptorSignature(conSet->getAddingSortedConceptDescriptionLinker(), conCount, exclusionDetermineFunction);
268
269
270 if (conCount > 0) {
271
272 CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getConceptSetLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_CONCEPT_SET_LABEL, conSetSigValue, conCount, conSet->getAddingSortedConceptDescriptionLinker(), exclusionDetermineFunction);
273
274 if (cachedLabelItem) {
275 ++mStatReusedCachedLabels;
276 tmpAssWriteDataLinker->setReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_CONCEPT_SET_LABEL, cachedLabelItem);
277 return true;
278 }
279
280
281 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*& prevTempRefLabels = (*signatureTmpConSetRefLabelHash)[conSetSigValue];
282 if (prevTempRefLabels) {
283 for (CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* prevTempRefLabelIt = prevTempRefLabels; prevTempRefLabelIt; prevTempRefLabelIt = prevTempRefLabelIt->getNext()) {
284 if (prevTempRefLabelIt->getCacheValueCount() == conCount) {
285 bool compatibleConcepts = true;
286 for (CBackendRepresentativeMemoryLabelValueLinker* labelValueLinkerIt = prevTempRefLabelIt->getCacheValueLinker(); labelValueLinkerIt && compatibleConcepts; labelValueLinkerIt = labelValueLinkerIt->getNext()) {
287 CCacheValue cacheValue = labelValueLinkerIt->getCacheValue();
288 CConcept* concept = (CConcept*)cacheValue.getIdentification();
289 bool negation = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDNEGATEDCONCEPT;
290
291 if (excludePositiveNominalConcepts && concept->getOperatorCode() == CCNOMINAL && !negation) {
292 compatibleConcepts = false;
293 }
294 if (hasConceptInAssociatedDeterministicConceptSetLabel(indiAssData, concept, negation, calcAlgContext)) {
295 compatibleConcepts = false;
296 }
297 }
298 if (compatibleConcepts) {
299 ++mStatReusedHashedSignatureLabels;
300 ++mStatReusedTempLabels;
301 tmpAssWriteDataLinker->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_CONCEPT_SET_LABEL, prevTempRefLabelIt);
302 return true;
303 }
304 }
305 }
306 }
307
308
309 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker >::allocateAndConstruct(mMemAllocMan);
310 newTempRefLabel->initLabelWriteData(conSetSigValue, CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_CONCEPT_SET_LABEL);
311 newTempRefLabel->setCompletelySaturated(false);
312 newTempRefLabel->setCompletelyHandled(true);
313 newTempRefLabel->setCompletelyPropagated(true);
314 for (CConceptDescriptor* conDesIt = conSet->getAddingSortedConceptDescriptionLinker(); conDesIt; conDesIt = conDesIt->getNext()) {
315 CConcept* concept = conDesIt->getConcept();
316 bool negation = conDesIt->isNegated();
317
318 bool considerConcept = exclusionDetermineFunction(concept, negation);
319 if (considerConcept) {
320 CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan);
321 labelValueLinker->initLabelValueLinker(getCacheValue(concept, negation));
322 newTempRefLabel->appendCacheValueLinker(labelValueLinker);
323 }
324 }
325 mNewTmpLabelList->append(newTempRefLabel);
326 ++mStatCreatedTempLabels;
327
328 tmpAssWriteDataLinker->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_CONCEPT_SET_LABEL, newTempRefLabel);
329 prevTempRefLabels = newTempRefLabel->append(prevTempRefLabels);
330 return true;
331 } else {
332 return false;
333 }
334 }
335
336
337
338 bool CIndividualNodeBackendCacheHandler::determineConceptSetLabelAssociationBackendItem(CIndividualProcessNode* indiNode, cint64 labelType, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) {
339 CReapplyConceptLabelSet* conSet = indiNode->getReapplyConceptLabelSet(false);
340 if (!conSet) {
341 return false;
342 }
343
344 bool deterministic = labelType == CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_CONCEPT_SET_LABEL;
345 bool excludePositiveNominalConcepts = true;
346
347 CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* >* signatureTmpConSetRefLabelHash = mSignatureTmpDetConSetRefLabelHash;
348 if (!deterministic) {
349 signatureTmpConSetRefLabelHash = mSignatureTmpNonDetConSetRefLabelHash;
350 }
351
352 cint64 conCount = conSet->getConceptCount();
353 cint64 maxDetBranchTag = calcAlgContext->getProcessingDataBox()->getMaximumDeterministicBranchTag();
354 cint64 conSetSigValue = CBackendRepresentativeMemoryCacheUtilities::getConceptDescriptorSignature(conSet->getAddingSortedConceptDescriptionLinker(), conCount, deterministic, maxDetBranchTag, excludePositiveNominalConcepts);
355
356 if (conCount > 0) {
357
358 CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getConceptSetLabelCacheEntry(conSetSigValue, conCount, conSet->getAddingSortedConceptDescriptionLinker(), deterministic, maxDetBranchTag, excludePositiveNominalConcepts);
359 if (cachedLabelItem) {
360 ++mStatReusedCachedLabels;
361 tmpAssWriteDataLinker->setReferredLabelData(labelType, cachedLabelItem);
362 return true;
363 }
364
365
366 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*& prevTempRefLabels = (*signatureTmpConSetRefLabelHash)[conSetSigValue];
367 if (prevTempRefLabels) {
368 for (CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* prevTempRefLabelIt = prevTempRefLabels; prevTempRefLabelIt; prevTempRefLabelIt = prevTempRefLabelIt->getNext()) {
369 if (prevTempRefLabelIt->getCacheValueCount() == conCount) {
370 bool compatibleConcepts = true;
371 for (CBackendRepresentativeMemoryLabelValueLinker* labelValueLinkerIt = prevTempRefLabelIt->getCacheValueLinker(); labelValueLinkerIt && compatibleConcepts; labelValueLinkerIt = labelValueLinkerIt->getNext()) {
372 CCacheValue cacheValue = labelValueLinkerIt->getCacheValue();
373 CConcept* concept = (CConcept*)cacheValue.getIdentification();
374 bool negation = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDNEGATEDCONCEPT;
375 if (excludePositiveNominalConcepts && concept->getOperatorCode() == CCNOMINAL && !negation) {
376 compatibleConcepts = false;
377 }
378
379
380 CConceptDescriptor* conDes = nullptr;
381 CDependencyTrackPoint* depTrackPoint = nullptr;
382 if (!conSet->getConceptDescriptor(concept, conDes, depTrackPoint)) {
383 compatibleConcepts = false;
384 } else {
385 if (conDes->isNegated() != negation) {
386 compatibleConcepts = false;
387 }
388
389 bool deterministicallyDerived = true;
390 if (!depTrackPoint || depTrackPoint->getBranchingTag() > maxDetBranchTag) {
391 deterministicallyDerived = false;
392 }
393
394 if (deterministicallyDerived != deterministic) {
395 compatibleConcepts = false;
396 }
397 }
398 }
399 if (compatibleConcepts) {
400 ++mStatReusedHashedSignatureLabels;
401 ++mStatReusedTempLabels;
402 tmpAssWriteDataLinker->setReferredTemporaryLabelData(labelType, prevTempRefLabelIt);
403 return true;
404 }
405 }
406 }
407 }
408
409
410 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker >::allocateAndConstruct(mMemAllocMan);
411 newTempRefLabel->initLabelWriteData(conSetSigValue, labelType);
412 newTempRefLabel->setCompletelySaturated(false);
413 newTempRefLabel->setCompletelyHandled(true);
414 newTempRefLabel->setCompletelyPropagated(true);
415 for (CConceptDescriptor* conDesIt = conSet->getAddingSortedConceptDescriptionLinker(); conDesIt; conDesIt = conDesIt->getNext()) {
416 CConcept* concept = conDesIt->getConcept();
417 bool negation = conDesIt->isNegated();
418
419 bool deterministicallyDerived = true;
420 if (!conDesIt->getDependencyTrackPoint() || conDesIt->getDependencyTrackPoint()->getBranchingTag() > maxDetBranchTag) {
421 deterministicallyDerived = false;
422 }
423 bool considerConcept = deterministicallyDerived == deterministic;
424 if (excludePositiveNominalConcepts && concept->getOperatorCode() == CCNOMINAL && !negation) {
425 considerConcept = false;
426 }
427
428 if (considerConcept) {
429 CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan);
430 labelValueLinker->initLabelValueLinker(getCacheValue(concept, negation));
431 newTempRefLabel->appendCacheValueLinker(labelValueLinker);
432 }
433 }
434 mNewTmpLabelList->append(newTempRefLabel);
435 ++mStatCreatedTempLabels;
436
437 tmpAssWriteDataLinker->setReferredTemporaryLabelData(labelType, newTempRefLabel);
438 prevTempRefLabels = newTempRefLabel->append(prevTempRefLabels);
439 return true;
440 } else {
441 return false;
442 }
443 }
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464 bool CIndividualNodeBackendCacheHandler::determineSameIndividualSetLabelAssociationBackendItem(CIndividualProcessNode* indiNode, cint64 labelType, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, bool* integratedAllMergingsFlag, CCalculationAlgorithmContext* calcAlgContext) {
465 CIndividualMergingHash* indiMergingHash = indiNode->getIndividualMergingHash(false);
466 if (!indiMergingHash) {
467 if (integratedAllMergingsFlag) {
468 *integratedAllMergingsFlag = true;
469 }
470 return false;
471 }
472 cint64 indiId = indiNode->getNominalIndividual()->getIndividualID();
473
474 bool deterministic = labelType == CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL;
475
476 CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* >* signatureTmpIndiSetRefLabelHash = mSignatureTmpDetSameIndiSetRefLabelHash;
477 if (!deterministic) {
478 signatureTmpIndiSetRefLabelHash = mSignatureTmpNonDetSameIndiSetRefLabelHash;
479 }
480
481 cint64 indiCount = indiMergingHash->getMergedIndividualCount() + 1;
482 cint64 maxDetBranchTag = calcAlgContext->getProcessingDataBox()->getMaximumDeterministicBranchTag();
483
484 cint64 indiSetSigValue = CBackendRepresentativeMemoryCacheUtilities::getIndividualSetSignature(indiId, indiMergingHash, indiCount, deterministic, maxDetBranchTag);
485
486 if (integratedAllMergingsFlag) {
487 *integratedAllMergingsFlag = indiCount == indiMergingHash->getMergedIndividualCount() + 1;
488 }
489
490 if (indiCount > 0) {
491
492 CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getIndividualSetLabelCacheEntry(labelType, indiSetSigValue, indiId, indiMergingHash, indiCount, deterministic, maxDetBranchTag);
493 if (cachedLabelItem) {
494 ++mStatReusedCachedLabels;
495 tmpAssWriteDataLinker->setReferredLabelData(labelType, cachedLabelItem);
496 return true;
497 }
498
499
500 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*& prevTempRefLabels = (*signatureTmpIndiSetRefLabelHash)[indiSetSigValue];
501 if (prevTempRefLabels) {
502 for (CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* prevTempRefLabelIt = prevTempRefLabels; prevTempRefLabelIt; prevTempRefLabelIt = prevTempRefLabelIt->getNext()) {
503 if (prevTempRefLabelIt->getCacheValueCount() == indiCount) {
504 bool compatibleLabels = true;
505 for (CBackendRepresentativeMemoryLabelValueLinker* labelValueLinkerIt = prevTempRefLabelIt->getCacheValueLinker(); labelValueLinkerIt && compatibleLabels; labelValueLinkerIt = labelValueLinkerIt->getNext()) {
506 CCacheValue cacheValue = labelValueLinkerIt->getCacheValue();
507 cint64 mergedIndiId = cacheValue.getTag();
508
509 if (indiId != mergedIndiId) {
510 if (indiMergingHash->hasMergedIndividual(mergedIndiId)) {
511 if (!deterministic) {
512 CIndividualMergingHashData data = indiMergingHash->value(mergedIndiId);
513 if (!data.getDependencyTrackPoint() || data.getDependencyTrackPoint()->getBranchingTag() > maxDetBranchTag) {
514 compatibleLabels = false;
515 }
516 }
517 } else {
518 compatibleLabels = false;
519 }
520 }
521
522 }
523 if (compatibleLabels) {
524 ++mStatReusedHashedSignatureLabels;
525 ++mStatReusedTempLabels;
526 tmpAssWriteDataLinker->setReferredTemporaryLabelData(labelType, prevTempRefLabelIt);
527 return true;
528 }
529 }
530 }
531 }
532
533
534 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker >::allocateAndConstruct(mMemAllocMan);
535 newTempRefLabel->initLabelWriteData(indiSetSigValue, labelType);
536 newTempRefLabel->setCompletelySaturated(false);
537 newTempRefLabel->setCompletelyHandled(true);
538 newTempRefLabel->setCompletelyPropagated(true);
539 for (CIndividualMergingHash::const_iterator it = indiMergingHash->constBegin(), itEnd = indiMergingHash->constEnd(); it != itEnd; ++it) {
540 if (it.value().isMergedWithIndividual()) {
541 cint64 mergedIndiId = it.key();
542 if (mergedIndiId != indiId) {
543 CIndividualMergingHashData mergedData = it.value();
544 bool deterministicallyDerived = true;
545 if (!mergedData.getDependencyTrackPoint() || mergedData.getDependencyTrackPoint()->getBranchingTag() > maxDetBranchTag) {
546 deterministicallyDerived = false;
547 }
548 bool considerIndividual = deterministicallyDerived || !deterministic;
549 if (considerIndividual) {
550 CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan);
551 labelValueLinker->initLabelValueLinker(mAssBackCacheReader->getCacheValue(mergedIndiId, false));
552 newTempRefLabel->appendCacheValueLinker(labelValueLinker);
553 }
554 }
555 }
556 }
557 if (indiId >= 0) {
558 CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan);
559 labelValueLinker->initLabelValueLinker(mAssBackCacheReader->getCacheValue(indiId, false));
560 newTempRefLabel->appendCacheValueLinker(labelValueLinker);
561 }
562 mNewTmpLabelList->append(newTempRefLabel);
563 ++mStatCreatedTempLabels;
564
565 tmpAssWriteDataLinker->setReferredTemporaryLabelData(labelType, newTempRefLabel);
566 prevTempRefLabels = newTempRefLabel->append(prevTempRefLabels);
567 return true;
568 } else {
569 return false;
570 }
571 }
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588 bool CIndividualNodeBackendCacheHandler::determineDifferentIndividualSetLabelAssociationBackendItem(CIndividualProcessNode* indiNode, cint64 labelType, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, bool* integratedAllDifferentFlag, CCalculationAlgorithmContext* calcAlgContext) {
589 CDistinctHash* indiDistinctHash = indiNode->getDistinctHash(false);
590 if (!indiDistinctHash) {
591 if (integratedAllDifferentFlag) {
592 *integratedAllDifferentFlag = true;
593 }
594 return false;
595 }
596 cint64 indiId = indiNode->getNominalIndividual()->getIndividualID();
597
598 bool deterministic = labelType == CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_DIFFRENT_INDIVIDUAL_SET_LABEL;
599
600 CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* >* signatureTmpIndiSetRefLabelHash = mSignatureTmpDetDiffIndiSetRefLabelHash;
601 if (!deterministic) {
602 signatureTmpIndiSetRefLabelHash = mSignatureTmpNonDetDiffIndiSetRefLabelHash;
603 }
604
605 cint64 indiCount = indiDistinctHash->size() + 1;
606 cint64 maxDetBranchTag = calcAlgContext->getProcessingDataBox()->getMaximumDeterministicBranchTag();
607
608 cint64 indiSetSigValue = CBackendRepresentativeMemoryCacheUtilities::getIndividualSetSignature(indiId, indiDistinctHash, indiCount, deterministic, maxDetBranchTag);
609
610 if (integratedAllDifferentFlag) {
611 *integratedAllDifferentFlag = indiCount == indiDistinctHash->size() + 1;
612 }
613
614 if (indiCount > 0) {
615
616 CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getIndividualSetLabelCacheEntry(labelType, indiSetSigValue, indiId, indiDistinctHash, indiCount, deterministic, maxDetBranchTag);
617 if (cachedLabelItem) {
618 ++mStatReusedCachedLabels;
619 tmpAssWriteDataLinker->setReferredLabelData(labelType, cachedLabelItem);
620 return true;
621 }
622
623
624 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*& prevTempRefLabels = (*signatureTmpIndiSetRefLabelHash)[indiSetSigValue];
625 if (prevTempRefLabels) {
626 for (CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* prevTempRefLabelIt = prevTempRefLabels; prevTempRefLabelIt; prevTempRefLabelIt = prevTempRefLabelIt->getNext()) {
627 if (prevTempRefLabelIt->getCacheValueCount() == indiCount) {
628 bool compatibleLabels = true;
629 for (CBackendRepresentativeMemoryLabelValueLinker* labelValueLinkerIt = prevTempRefLabelIt->getCacheValueLinker(); labelValueLinkerIt && compatibleLabels; labelValueLinkerIt = labelValueLinkerIt->getNext()) {
630 CCacheValue cacheValue = labelValueLinkerIt->getCacheValue();
631 cint64 distinctIndiId = cacheValue.getTag();
632
633 if (distinctIndiId >= 0 && indiId != distinctIndiId) {
634 if (indiDistinctHash->contains(-distinctIndiId)) {
635 if (!deterministic) {
636 CDistinctEdge* distinctEdge = indiDistinctHash->value(-distinctIndiId);
637 if (!distinctEdge->getDependencyTrackPoint() || distinctEdge->getDependencyTrackPoint()->getBranchingTag() > maxDetBranchTag) {
638 compatibleLabels = false;
639 }
640 }
641 }
642 else {
643 compatibleLabels = false;
644 }
645 }
646
647 }
648 if (compatibleLabels) {
649 ++mStatReusedHashedSignatureLabels;
650 ++mStatReusedTempLabels;
651 tmpAssWriteDataLinker->setReferredTemporaryLabelData(labelType, prevTempRefLabelIt);
652 return true;
653 }
654 }
655 }
656 }
657
658
659 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker >::allocateAndConstruct(mMemAllocMan);
660 newTempRefLabel->initLabelWriteData(indiSetSigValue, labelType);
661 newTempRefLabel->setCompletelySaturated(false);
662 newTempRefLabel->setCompletelyHandled(true);
663 newTempRefLabel->setCompletelyPropagated(true);
664 for (CDistinctHash::const_iterator it = indiDistinctHash->constBegin(), itEnd = indiDistinctHash->constEnd(); it != itEnd; ++it) {
665 cint64 distinctIndiId = -it.key();
666 if (distinctIndiId >= 0 && distinctIndiId != indiId) {
667 CDistinctEdge* distinctEdge = it.value();
668 bool deterministicallyDerived = true;
669 if (!distinctEdge->getDependencyTrackPoint() || distinctEdge->getDependencyTrackPoint()->getBranchingTag() > maxDetBranchTag) {
670 deterministicallyDerived = false;
671 }
672 bool considerIndividual = deterministicallyDerived || !deterministic;
673 if (considerIndividual) {
674 CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan);
675 labelValueLinker->initLabelValueLinker(mAssBackCacheReader->getCacheValue(distinctIndiId, false));
676 newTempRefLabel->appendCacheValueLinker(labelValueLinker);
677 }
678 }
679 }
680 if (indiId >= 0) {
681 CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan);
682 labelValueLinker->initLabelValueLinker(mAssBackCacheReader->getCacheValue(indiId, false));
683 newTempRefLabel->appendCacheValueLinker(labelValueLinker);
684 }
685 mNewTmpLabelList->append(newTempRefLabel);
686 ++mStatCreatedTempLabels;
687
688 tmpAssWriteDataLinker->setReferredTemporaryLabelData(labelType, newTempRefLabel);
689 prevTempRefLabels = newTempRefLabel->append(prevTempRefLabels);
690 return true;
691 }
692 else {
693 return false;
694 }
695 }
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741 CIndividualProcessNode* CIndividualNodeBackendCacheHandler::getSuccessorIndividual(CIndividualProcessNode*& indi, CIndividualLinkEdge* link, CCalculationAlgorithmContext* calcAlgContext) {
742 CIndividualProcessNode* succIndi = nullptr;
743
744 if (link->isLocalizationTagUpToDate(calcAlgContext->getUsedProcessTagger()->getCurrentLocalizationTag())) {
745 succIndi = link->getOppositeIndividual(indi);
746 } else {
747 succIndi = link->getOppositeIndividual(indi);
748 if (!succIndi->isLocalizationTagUpToDate(calcAlgContext->getUsedProcessTagger()->getCurrentLocalizationTag()) && succIndi->isRelocalized()) {
749 cint64 succIndiId = link->getOppositeIndividualID(indi);
750 CIndividualProcessNodeVector* indiProcNodeVec = calcAlgContext->getProcessingDataBox()->getIndividualProcessNodeVector();
751 succIndi = indiProcNodeVec->getData(succIndiId);
752 }
753 }
754 return succIndi;
755 }
756
757
758
759 void CIndividualNodeBackendCacheHandler::collectRoleSuccessorData(CIndividualLinkEdge* link, bool inversed, cint64 maxDetBranchTag, bool isNominalNeighbour, bool isDataNeighbour, CPROCESSSET<TRoleInversionPair>* combinedNeighbourDetRoleInstantiatedSet, CSortedNegLinker<CRole *>*& combinedNeighbourDetRoleInstantiatedLinker,
760 CPROCESSSET<TRoleInversionPair>* combinedNeighbourNonDetRoleInstantiatedSet, CSortedNegLinker<CRole *>*& combinedNeighbourNonDetRoleInstantiatedLinker, CPROCESSSET<TRoleInversionPair>* combinedExistentialDetRoleInstantiatedSet, CSortedNegLinker<CRole *>*& combinedExistentialDetRoleInstantiatedLinker,
761 CPROCESSSET<TRoleInversionPair>* combinedExistentialNonDetRoleInstantiatedSet, CSortedNegLinker<CRole *>*& combinedExistentialNonDetRoleInstantiatedLinker, CPROCESSSET<TRoleInversionPair>* combinedDataDetRoleInstantiatedSet, CSortedNegLinker<CRole *>*& combinedDataDetRoleInstantiatedLinker,
762 CPROCESSSET<TRoleInversionPair>* combinedDataNonDetRoleInstantiatedSet, CSortedNegLinker<CRole *>*& combinedDataNonDetRoleInstantiatedLinker, CRole* role, CCalculationAlgorithmContext* calcAlgContext, bool &collected, CIndividualProcessNode* indiNode, CIndividualProcessNode* connIndiNode,
763 cint64 connIndiMergedNominalId, bool connIndiNominalDeterministicallyMerged, CBackendRepresentativeMemoryCacheRoleAssertionLinker* &roleAssertionLinker, CPROCESSSET<cint64>** existentialIndirectlyConnectedNominalIndividualSet, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash,
764 CBackendRepresentativeMemoryLabelCacheItem* prevNeighbourRoleSetLabelRef) {
765
766 bool deterministicallyDerived = connIndiNominalDeterministicallyMerged;
767 CDependencyTrackPoint* lindDepTrackPoint = link->getDependencyTrackPoint();
768 if (!lindDepTrackPoint || lindDepTrackPoint->getBranchingTag() > maxDetBranchTag) {
769 deterministicallyDerived = false;
770 }
771
772
773
774
775 bool isAssertionBase = false;
776 bool nominalConnected = false;
777 bool prevLinkStatusUsage = false;
778 if (prevNeighbourRoleSetLabelRef) {
779
780 cint64 roleTag = role->getRoleTag();
781 if (inversed) {
782 roleTag = -roleTag;
783 }
784 CBackendRepresentativeMemoryLabelValueLinker* cachedValueLinker = prevNeighbourRoleSetLabelRef->getTagCacheValueHash()->value(roleTag);
785 if (cachedValueLinker) {
786 const CCacheValue& prevCacheValue = cachedValueLinker->getCacheValue();
787 bool prevNondeterministicallyDerived = mAssBackCacheReader->isCacheValueRoleNondeterministic(prevCacheValue);
788 if (!prevNondeterministicallyDerived || !deterministicallyDerived) {
789 deterministicallyDerived = !prevNondeterministicallyDerived;
790 isAssertionBase = mAssBackCacheReader->isCacheValueRoleAssertion(prevCacheValue);
791 nominalConnected = mAssBackCacheReader->isCacheValueRoleNominal(prevCacheValue);
792 prevLinkStatusUsage = true;
793 }
794 }
795
796 }
797
798 CPROCESSSET<TRoleInversionPair>** useRoleInstantiatedSet = nullptr;
799 CSortedNegLinker<CRole*>** useRoleInstantiatedLinker = nullptr;
800 if (deterministicallyDerived && isNominalNeighbour) {
801 useRoleInstantiatedSet = &combinedNeighbourDetRoleInstantiatedSet;
802 useRoleInstantiatedLinker = &combinedNeighbourDetRoleInstantiatedLinker;
803 } else if (!deterministicallyDerived && isNominalNeighbour) {
804 useRoleInstantiatedSet = &combinedNeighbourNonDetRoleInstantiatedSet;
805 useRoleInstantiatedLinker = &combinedNeighbourNonDetRoleInstantiatedLinker;
806 } else if (deterministicallyDerived && !isNominalNeighbour && !isDataNeighbour) {
807 useRoleInstantiatedSet = &combinedExistentialDetRoleInstantiatedSet;
808 useRoleInstantiatedLinker = &combinedExistentialDetRoleInstantiatedLinker;
809 } else if (!deterministicallyDerived && !isNominalNeighbour && !isDataNeighbour) {
810 useRoleInstantiatedSet = &combinedExistentialNonDetRoleInstantiatedSet;
811 useRoleInstantiatedLinker = &combinedExistentialNonDetRoleInstantiatedLinker;
812 } else if (deterministicallyDerived && isDataNeighbour) {
813 useRoleInstantiatedSet = &combinedDataDetRoleInstantiatedSet;
814 useRoleInstantiatedLinker = &combinedDataDetRoleInstantiatedLinker;
815 } else if (!deterministicallyDerived && isDataNeighbour) {
816 useRoleInstantiatedSet = &combinedDataNonDetRoleInstantiatedSet;
817 useRoleInstantiatedLinker = &combinedExistentialNonDetRoleInstantiatedLinker;
818 }
819
820
821
822
823 if (useRoleInstantiatedSet && !(*useRoleInstantiatedSet)->contains(TRoleInversionPair(role, inversed))) {
824 (*useRoleInstantiatedSet)->insert(TRoleInversionPair(role, inversed));
825 CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
826 *useRoleInstantiatedLinker = newRoleLinker->init(role, inversed, *useRoleInstantiatedLinker);
827 collected = true;
828 }
829
830
831 if (isNominalNeighbour) {
832
833 if (lindDepTrackPoint && deterministicallyDerived && lindDepTrackPoint->getDependencyNode()->getDependencyType() == CDependencyNode::DNTMERGEDLINK) {
834
835 CMERGEDLINKDependencyNode* mergedLinkDep = (CMERGEDLINKDependencyNode*)lindDepTrackPoint->getDependencyNode();
836 CDependencyTrackPoint* prevLinkDepTrackPoint = mergedLinkDep->getPreviousDependencyTrackPoint();
837 while (prevLinkDepTrackPoint && prevLinkDepTrackPoint->getDependencyNode() && prevLinkDepTrackPoint->getDependencyNode()->getDependencyType() == CDependencyNode::DNTMERGEDLINK) {
838 mergedLinkDep = (CMERGEDLINKDependencyNode*)prevLinkDepTrackPoint->getDependencyNode();
839 prevLinkDepTrackPoint = mergedLinkDep->getPreviousDependencyTrackPoint();
840 }
841
842 if (prevLinkDepTrackPoint && prevLinkDepTrackPoint->getDependencyNode()->getDependencyType() == CDependencyNode::DNTROLEASSERTIONDEPENDENCY) {
843 lindDepTrackPoint = prevLinkDepTrackPoint;
844 }
845
846
847 }
848 if (prevLinkStatusUsage) {
849
850 CBackendRepresentativeMemoryCacheRoleAssertionLinker* linker = CObjectAllocator< CBackendRepresentativeMemoryCacheRoleAssertionLinker >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager());
851 linker->initRoleAssertionLinker(role, inversed, isAssertionBase, nominalConnected, !deterministicallyDerived);
852 roleAssertionLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)linker->append(roleAssertionLinker);
853
854 } else if (lindDepTrackPoint && lindDepTrackPoint->getDependencyNode()->getDependencyType() == CDependencyNode::DNTROLEASSERTIONDEPENDENCY) {
855 isAssertionBase = true;
856
857 CROLEASSERTIONDependencyNode* assertionDepNode = (CROLEASSERTIONDependencyNode*)lindDepTrackPoint->getDependencyNode();
858 CRole* baseAssertionRole = assertionDepNode->getBaseAssertionRole();
859 CIndividual* baseAssertionIndi = assertionDepNode->getBaseAssertionIndividual();
860 bool baseAssertionRoleInversed = true;
861 if (baseAssertionIndi->getIndividualID() == indiNode->getNominalIndividual()->getIndividualID()) {
862 baseAssertionRoleInversed = false;
863 } else {
864 CIndividualMergingHash* mergingHash = indiNode->getIndividualMergingHash(false);
865 if (mergingHash && mergingHash->hasMergedIndividual(baseAssertionIndi->getIndividualID())) {
866 baseAssertionRoleInversed = false;
867 }
868 }
869
870 CBackendRepresentativeMemoryCacheRoleAssertionLinker* linker = CObjectAllocator< CBackendRepresentativeMemoryCacheRoleAssertionLinker >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager());
871 linker->initRoleAssertionLinker(role, inversed, baseAssertionRole == role && baseAssertionRoleInversed == inversed, false, !deterministicallyDerived);
872 roleAssertionLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)linker->append(roleAssertionLinker);
873
874 } else if (lindDepTrackPoint && lindDepTrackPoint->getDependencyNode()->getDependencyType() == CDependencyNode::DNTVALUEDEPENDENCY) {
875 CVALUEDependencyNode* valuDepNode = (CVALUEDependencyNode*)lindDepTrackPoint->getDependencyNode();
876 CIndividualProcessNode* valueIndiNode = valuDepNode->getAppropriateIndividualNode();
877 CConceptDescriptor* valueConDes = valuDepNode->getConceptDescriptor();
878 if (valueConDes && valueConDes->getConcept()->getRole() && valueIndiNode && valueIndiNode->getNominalIndividual()) {
879
880 CRole* baseValueRole = valueConDes->getConcept()->getRole();
881 CIndividual* baseValueIndi = valueIndiNode->getNominalIndividual();
882 bool baseValueRoleInversed = true;
883 if (baseValueIndi->getIndividualID() == indiNode->getNominalIndividual()->getIndividualID()) {
884 baseValueRoleInversed = false;
885 } else {
886 CIndividualMergingHash* mergingHash = indiNode->getIndividualMergingHash(false);
887 if (mergingHash && mergingHash->hasMergedIndividual(baseValueIndi->getIndividualID())) {
888 baseValueRoleInversed = false;
889 }
890 }
891
892 CBackendRepresentativeMemoryCacheRoleAssertionLinker* linker = CObjectAllocator< CBackendRepresentativeMemoryCacheRoleAssertionLinker >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager());
893 linker->initRoleAssertionLinker(role, inversed, false, baseValueRole == role && baseValueRoleInversed == inversed, !deterministicallyDerived);
894 roleAssertionLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)linker->append(roleAssertionLinker);
895
896 } else {
897 CBackendRepresentativeMemoryCacheRoleAssertionLinker* linker = CObjectAllocator< CBackendRepresentativeMemoryCacheRoleAssertionLinker >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager());
898 linker->initRoleAssertionLinker(role, inversed, false, true, !deterministicallyDerived);
899 roleAssertionLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)linker->append(roleAssertionLinker);
900 }
901 } else {
902 CBackendRepresentativeMemoryCacheRoleAssertionLinker* linker = CObjectAllocator< CBackendRepresentativeMemoryCacheRoleAssertionLinker >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager());
903 linker->initRoleAssertionLinker(role, inversed, false, true, !deterministicallyDerived);
904 roleAssertionLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)linker->append(roleAssertionLinker);
905 }
906
907 } else if (!isDataNeighbour) {
908 if (roleUsedCardHash && !inversed) {
909 (*roleUsedCardHash)[role] += 1;
910 }
911 if (connIndiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFSUCCESSORNOMINALCONNECTION)) {
912 CSuccessorConnectedNominalSet* succConnNomSet = connIndiNode->getSuccessorNominalConnectionSet(false);
913 if (succConnNomSet && existentialIndirectlyConnectedNominalIndividualSet) {
914 if (!*existentialIndirectlyConnectedNominalIndividualSet) {
915 *existentialIndirectlyConnectedNominalIndividualSet = CObjectParameterizingAllocator< CPROCESSSET<cint64>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
916 }
917 for (CSuccessorConnectedNominalSet::const_iterator it = succConnNomSet->constBegin(), itEnd = succConnNomSet->constEnd(); it != itEnd; ++it) {
918 cint64 succConnNominalIndi = *it;
919 if (succConnNominalIndi <= 0) {
920 (*existentialIndirectlyConnectedNominalIndividualSet)->insert(-succConnNominalIndi);
921 }
922 }
923 }
924 }
925 }
926 }
927
928 CBackendRepresentativeMemoryCacheIndividualAssociationData* CIndividualNodeBackendCacheHandler::getIndividualAssociationDataFromIndividualNode(CIndividualProcessNode* indiNode, CCalculationAlgorithmContext* calcAlgContext) {
929 CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = nullptr;
930 CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData* backendSyncData = (CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData*)indiNode->getIndividualBackendCacheSynchronisationData(false);
931 if (backendSyncData) {
932 indiAssData = backendSyncData->getAssocitaionData();
933 }
934 if (!indiAssData) {
935 indiAssData = getIndividualAssociationData(indiNode->getNominalIndividual(), calcAlgContext);
936 }
937 return indiAssData;
938 }
939
940
941
942
943
944 bool CIndividualNodeBackendCacheHandler::visitMergedIndividualNodesAssociationData(CIndividualProcessNode* baseIndiNode, CBackendRepresentativeMemoryCacheIndividualAssociationData* excludeIndiAssData, CBackendRepresentativeMemoryLabelCacheItem* excludeIndiSetLabel, bool visitBaseIndiAssoData, cint64 maxDetBranchTag, function<bool(cint64 mergedIndiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* mergedIndiAssData, bool deterministicallyMerged)> visitFunc, CCalculationAlgorithmContext* calcAlgContext) {
945 bool visited = false;
946 bool continueVisiting = true;
947
948 CBackendRepresentativeMemoryCacheIndividualAssociationData* baseIndiAssData = getIndividualAssociationDataFromIndividualNode(baseIndiNode, calcAlgContext);
949 if (visitBaseIndiAssoData && baseIndiAssData) {
950 visited = true;
951 continueVisiting = visitFunc(baseIndiNode->getNominalIndividual()->getIndividualID(), baseIndiAssData, true);
952 }
953 CIndividualMergingHash* mergingHash = baseIndiNode->getIndividualMergingHash(false);
954 if (mergingHash) {
955 for (CIndividualMergingHash::const_iterator it = mergingHash->constBegin(), itEnd = mergingHash->constEnd(); it != itEnd && continueVisiting; ++it) {
956 if (it.value().isMergedWithIndividual()) {
957 cint64 mergedIndiId = it.key();
958 if (!excludeIndiSetLabel || !hasIndividualIdsInAssociatedIndividualSetLabel(excludeIndiAssData, excludeIndiSetLabel, mergedIndiId)) {
959 CBackendRepresentativeMemoryCacheIndividualAssociationData* mergedIndiAssData = getIndividualAssociationData(mergedIndiId, calcAlgContext);
960 if (mergedIndiAssData) {
961 visited = true;
962 bool deterministicallyMerged = true;
963 CIndividualMergingHashData data = it.value();
964 if (!data.getDependencyTrackPoint() || data.getDependencyTrackPoint()->getBranchingTag() > maxDetBranchTag) {
965 deterministicallyMerged = false;
966 }
967 continueVisiting = visitFunc(mergedIndiId, mergedIndiAssData, deterministicallyMerged);
968 }
969 }
970 }
971 }
972 }
973 return visited;
974 }
975
976
977
978
979
980 bool CIndividualNodeBackendCacheHandler::determineRoleInstantiatedSetLabelAssociationBackendItems(CIndividualProcessNode* extractionIndiNode, CIndividualProcessNode* indiNode, bool onlyNondeterministic, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CPROCESSSET<cint64>** existentialIndirectlyConnectedNominalIndividualSet, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, QSet<cint64>* propCutIndiSet, CCalculationAlgorithmContext* calcAlgContext) {
981
982 bool updated = false;
983
984 CPROCESSSET<TRoleInversionPair>* combinedExistentialDetRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
985 CSortedNegLinker<CRole*>* combinedExistentialDetRoleInstantiatedLinker = nullptr;
986
987 CPROCESSSET<TRoleInversionPair>* combinedExistentialNonDetRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
988 CSortedNegLinker<CRole*>* combinedExistentialNonDetRoleInstantiatedLinker = nullptr;
989
990
991
992 CPROCESSSET<TRoleInversionPair>* combinedDataDetRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
993 CSortedNegLinker<CRole*>* combinedDataDetRoleInstantiatedLinker = nullptr;
994
995 CPROCESSSET<TRoleInversionPair>* combinedDataNonDetRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
996 CSortedNegLinker<CRole*>* combinedDataNonDetRoleInstantiatedLinker = nullptr;
997
998
999
1000 CPROCESSSET<TRoleInversionPair>* combinedNeighbourDetRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1001 CSortedNegLinker<CRole*>* combinedNeighbourDetRoleInstantiatedLinker = nullptr;
1002
1003 CPROCESSSET<TRoleInversionPair>* combinedNeighbourNonDetRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1004 CSortedNegLinker<CRole*>* combinedNeighbourNonDetRoleInstantiatedLinker = nullptr;
1005
1006
1007 CPROCESSSET<CBackendRepresentativeMemoryCacheTemporaryLabelReference>* neigbourRoleInstantiatedSetCompination = CObjectParameterizingAllocator< CPROCESSSET<CBackendRepresentativeMemoryCacheTemporaryLabelReference>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1008
1009
1010 CPROCESSSET<cint64>* connIndiSet = CObjectParameterizingAllocator< CPROCESSSET<cint64>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1011
1012
1013
1014 CSuccessorIterator succIt(extractionIndiNode->getSuccessorIterator());
1015 cint64 lastIndiId = CINT64_MAX;
1016 while (succIt.hasNext()) {
1017 CIndividualLinkEdge* link = succIt.nextLink(true);
1018 cint64 succIndiId = link->getOppositeIndividualID(extractionIndiNode);
1019 if (succIndiId != lastIndiId) {
1020 connIndiSet->insert(succIndiId);
1021 lastIndiId = succIndiId;
1022 }
1023 }
1024 CConnectionSuccessorSetIterator connSuccSetIt = extractionIndiNode->getConnectionSuccessorIterator();
1025 while (connSuccSetIt.hasNext()) {
1026 cint64 succConnId = connSuccSetIt.nextSuccessorConnectionID(true);
1027 connIndiSet->insert(succConnId);
1028 }
1029
1030
1031 bool collected = false;
1032 cint64 maxDetBranchTag = calcAlgContext->getProcessingDataBox()->getMaximumDeterministicBranchTag();
1033 cint64 nonMergeConsideredMaxDetBranchTag = calcAlgContext->getProcessingDataBox()->getMaximumDeterministicBranchTag();
1034 if (onlyNondeterministic) {
1035 maxDetBranchTag = -1;
1036 }
1037 CIndividualProcessNodeVector* indiProcNodeVec = calcAlgContext->getProcessingDataBox()->getIndividualProcessNodeVector();
1038
1039
1040 // TODO: integrate/add association data of all merged indis
1041 CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = getIndividualAssociationDataFromIndividualNode(indiNode, calcAlgContext);
1042
1043 CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker* roleSetNeighbourUpdateLinker = nullptr;
1044
1045 CBackendRepresentativeMemoryLabelCacheItem* maxSameIndiSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL);
1046 if (!maxSameIndiSetLabel) {
1047 maxSameIndiSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL);
1048 }
1049
1050
1051 if (indiAssData && (indiAssData->isIndirectlyConnectedNominalIndividual() || extractionIndiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFSYNCHRONIZEDBACKENDSUCCESSOREXPANSIONBLOCKED | CIndividualProcessNode::PRFSATURATIONSUCCESSORCREATIONBLOCKINGCACHED))) {
1052
1053 visitMergedIndividualNodesAssociationData(extractionIndiNode, indiAssData, maxSameIndiSetLabel, true, maxDetBranchTag, [&](cint64 mergedIndiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* mergedIndiAssData, bool deterministicallyMerged)->bool {
1054
1055 if (!mergedIndiAssData->hasDeterministicSameIndividualMerging()) {
1056 // reuse roles of existing existential data role instantiation sets
1057 visitRolesOfAssociatedCompinationRoleSetLabel(mergedIndiAssData, mergedIndiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL), [&](CRole* role, bool inversed)->bool {
1058 if (deterministicallyMerged && !onlyNondeterministic) {
1059 if (!combinedDataDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1060 combinedDataDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1061 CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1062 combinedDataDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedDataDetRoleInstantiatedLinker);
1063 }
1064 } else {
1065 if (!combinedDataNonDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1066 combinedDataNonDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1067 CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1068 combinedDataNonDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedDataNonDetRoleInstantiatedLinker);
1069 }
1070 }
1071 return true;
1072 }, calcAlgContext);
1073
1074
1075 // reuse roles of existing existential role instantiation sets
1076 visitRolesOfAssociatedCompinationRoleSetLabel(mergedIndiAssData, mergedIndiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL), [&](CRole* role, bool inversed)->bool {
1077 if (deterministicallyMerged && !onlyNondeterministic) {
1078 if (!combinedExistentialDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1079 combinedExistentialDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1080 CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1081 combinedExistentialDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedExistentialDetRoleInstantiatedLinker);
1082 }
1083 } else {
1084 if (!combinedExistentialNonDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1085 combinedExistentialNonDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1086 CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1087 combinedExistentialNonDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedExistentialNonDetRoleInstantiatedLinker);
1088 }
1089 }
1090 return true;
1091 }, calcAlgContext);
1092
1093
1094
1095 visitRolesOfAssociatedCompinationRoleSetLabel(mergedIndiAssData, mergedIndiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL), [&](CRole* role, bool inversed)->bool {
1096 if (!combinedExistentialNonDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1097 combinedExistentialNonDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1098 CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1099 combinedExistentialNonDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedExistentialNonDetRoleInstantiatedLinker);
1100 }
1101 return true;
1102 }, calcAlgContext);
1103
1104
1105 visitRolesOfAssociatedCompinationRoleSetLabel(mergedIndiAssData, mergedIndiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL), [&](CRole* role, bool inversed)->bool {
1106 if (!combinedDataNonDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1107 combinedDataNonDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1108 CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1109 combinedDataNonDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedDataNonDetRoleInstantiatedLinker);
1110 }
1111 return true;
1112 }, calcAlgContext);
1113
1114 }
1115
1116 return true;
1117 }, calcAlgContext);
1118 }
1119
1120
1121
1122 //TODO: detect removed non-deterministic neighbour connections (e.g., due to different merging), i.e., go through existing associated neighbour array and check for neighbours with only non-deterministic roles which are not instantiated in the current completion graph (although both individuals are present and fully handled)
1123 CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData* extIndiBackSyncData = (CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData*)extractionIndiNode->getIndividualBackendCacheSynchronisationData(false);
1124 bool propagationCut = false;
1125 bool requiresAllLinksCollecting = false;
1126 if (indiAssData && indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL) && !extractionIndiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFBACKENDEXPANSIONREUSINGINDIVIDUAL) && extIndiBackSyncData->hasAllNeighbourExpansion()) {
1127 tmpAssWriteDataLinker->setLinksUpdateType(CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::REPLACEMENT);
1128 requiresAllLinksCollecting = true;
1129 }
1130 if (!requiresAllLinksCollecting && propCutIndiSet && propCutIndiSet->contains(indiNode->getNominalIndividual()->getIndividualID())) {
1131 tmpAssWriteDataLinker->setLinksUpdateType(CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::REPLACEMENT);
1132 requiresAllLinksCollecting = true;
1133 propagationCut = true;
1134 }
1135
1136
1137 CRole* topRole = calcAlgContext->getProcessingDataBox()->getOntology()->getRBox()->getTopObjectRole();
1138 for (CPROCESSSET<cint64>::const_iterator it = connIndiSet->constBegin(), itEnd = connIndiSet->constEnd(); it != itEnd; ++it) {
1139 cint64 connIndiId = *it;
1140 CIndividualProcessNode* connIndiNode = indiProcNodeVec->getData(connIndiId);
1141
1142 if (!connIndiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFPURGEDBLOCKED)) {
1143 bool isNominalNeighbour = connIndiNode->getNominalIndividual() != nullptr;
1144
1145 bool isDataNeighbour = connIndiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFCONCRETEDATAINDINODE);
1146
1147
1148 CIndividualMergingHash* connIndiMergingHash = connIndiNode->getIndividualMergingHash(false);
1149 CIndividualMergingHash::const_iterator connIndiMergedHashIt, connIndiMergedHashItEnd;
1150 if (connIndiMergingHash) {
1151 connIndiMergedHashIt = connIndiMergingHash->constBegin();
1152 connIndiMergedHashItEnd = connIndiMergingHash->constEnd();
1153 }
1154 bool allConnIndiHandled = false;
1155 cint64 connIndiMergedNominalId = -connIndiId;
1156 bool connIndiDetMerged = true;
1157
1158 while (!allConnIndiHandled) {
1159
1160
1161 CBackendRepresentativeMemoryLabelCacheItem* prevNeighbourRoleSetLabelRef = nullptr;
1162 if (indiAssData && connIndiMergedNominalId >= 0 && connIndiId <= 0) {
1163 CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* neighbourRoleSetHash = indiAssData->getNeighbourRoleSetHash();
1164 if (neighbourRoleSetHash) {
1165 prevNeighbourRoleSetLabelRef = neighbourRoleSetHash->getNeighbourRoleSetLabel(connIndiMergedNominalId);
1166 }
1167 }
1168
1169
1170 CBackendRepresentativeMemoryCacheRoleAssertionLinker* roleAssertionLinker = nullptr;
1171
1172 CSuccessorRoleIterator roleIt(extractionIndiNode->getSuccessorRoleIterator(connIndiNode));
1173 while (roleIt.hasNext()) {
1174 CIndividualLinkEdge* link = roleIt.next(true);
1175 CRole* role = link->getLinkRole();
1176
1177 if (role != topRole) {
1178 collectRoleSuccessorData(link, false, maxDetBranchTag, isNominalNeighbour, isDataNeighbour, combinedNeighbourDetRoleInstantiatedSet, combinedNeighbourDetRoleInstantiatedLinker, combinedNeighbourNonDetRoleInstantiatedSet, combinedNeighbourNonDetRoleInstantiatedLinker, combinedExistentialDetRoleInstantiatedSet,
1179 combinedExistentialDetRoleInstantiatedLinker, combinedExistentialNonDetRoleInstantiatedSet, combinedExistentialNonDetRoleInstantiatedLinker, combinedDataDetRoleInstantiatedSet, combinedDataDetRoleInstantiatedLinker, combinedDataNonDetRoleInstantiatedSet, combinedDataNonDetRoleInstantiatedLinker, role, calcAlgContext, collected, extractionIndiNode, connIndiNode, connIndiMergedNominalId, connIndiDetMerged, roleAssertionLinker, existentialIndirectlyConnectedNominalIndividualSet, roleUsedCardHash, prevNeighbourRoleSetLabelRef);
1180 }
1181 }
1182
1183 CSuccessorRoleIterator commRoleIt(connIndiNode->getSuccessorRoleIterator(extractionIndiNode));
1184 while (commRoleIt.hasNext()) {
1185 CIndividualLinkEdge* link = commRoleIt.next(true);
1186 CRole* role = link->getLinkRole();
1187
1188 if (role != topRole) {
1189 collectRoleSuccessorData(link, true, maxDetBranchTag, isNominalNeighbour, isDataNeighbour, combinedNeighbourDetRoleInstantiatedSet, combinedNeighbourDetRoleInstantiatedLinker, combinedNeighbourNonDetRoleInstantiatedSet, combinedNeighbourNonDetRoleInstantiatedLinker, combinedExistentialDetRoleInstantiatedSet,
1190 combinedExistentialDetRoleInstantiatedLinker, combinedExistentialNonDetRoleInstantiatedSet, combinedExistentialNonDetRoleInstantiatedLinker, combinedDataDetRoleInstantiatedSet, combinedDataDetRoleInstantiatedLinker, combinedDataNonDetRoleInstantiatedSet, combinedDataNonDetRoleInstantiatedLinker, role, calcAlgContext, collected, extractionIndiNode, connIndiNode, connIndiMergedNominalId, connIndiDetMerged, roleAssertionLinker, existentialIndirectlyConnectedNominalIndividualSet, roleUsedCardHash, prevNeighbourRoleSetLabelRef);
1191 }
1192 }
1193
1194
1195 if (roleAssertionLinker) {
1196
1197
1198
1199 CBackendRepresentativeMemoryCacheTemporaryLabelReference neighbourRoleSetLabelRef = getNeighbourRoleInstantiatedSetLabelAssociationBackendItem(nullptr, roleAssertionLinker, nullptr, calcAlgContext);
1200
1201
1202 if (indiAssData && (neighbourRoleSetLabelRef.getReferredLabelData() || neighbourRoleSetLabelRef.getReferredTemporaryLabelData())) {
1203 CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* neighbourRoleSetHash = indiAssData->getNeighbourRoleSetHash();
1204 CBackendRepresentativeMemoryLabelCacheItem* prevLabel = nullptr;
1205 if (neighbourRoleSetHash) {
1206 prevLabel = neighbourRoleSetHash->getNeighbourRoleSetLabel(connIndiMergedNominalId);
1207 }
1208 CBackendRepresentativeMemoryLabelCacheItem* newLabel = neighbourRoleSetLabelRef.getReferredLabelData();
1209 CBackendRepresentativeMemoryLabelValueLinker* valueLinker = nullptr;
1210 if (prevLabel && newLabel && prevLabel != newLabel) {
1211 if (prevLabel->getCacheValueCount() == newLabel->getCacheValueCount()) {
1212 valueLinker = newLabel->getCacheValueLinker();
1213 }
1214 }
1215 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* tmpLabel = neighbourRoleSetLabelRef.getReferredTemporaryLabelData();
1216 if (tmpLabel && prevLabel) {
1217 if (prevLabel->getCacheValueCount() == tmpLabel->getCacheValueCount()) {
1218 valueLinker = tmpLabel->getCacheValueLinker();
1219 }
1220 }
1221
1222 if (valueLinker) {
1223
1224
1225 bool sameRolesCompatible = true;
1226 for (CBackendRepresentativeMemoryLabelValueLinker* linkerIt = valueLinker; linkerIt && sameRolesCompatible; linkerIt = linkerIt->getNext()) {
1227 cint64 tag = linkerIt->getCacheValue().getTag();
1228 if (!prevLabel->getTagCacheValueHash(false)->contains(tag)) {
1229 sameRolesCompatible = false;
1230 } else {
1231 const CCacheValue& prevCacheValue = prevLabel->getTagCacheValueHash(false)->value(tag)->getCacheValue();
1232 const CCacheValue& newCacheValue = linkerIt->getCacheValue();
1233 if (mAssBackCacheReader->isCacheValueRoleInverse(prevCacheValue) != mAssBackCacheReader->isCacheValueRoleInverse(newCacheValue)) {
1234 sameRolesCompatible = false;
1235 }
1236 bool prevNondeterministic = mAssBackCacheReader->isCacheValueRoleNondeterministic(prevCacheValue);
1237 bool newNondeterministic = mAssBackCacheReader->isCacheValueRoleNondeterministic(newCacheValue);
1238 if (prevNondeterministic && !newNondeterministic) {
1239 sameRolesCompatible = false;
1240 }
1241
1242 }
1243 }
1244 if (sameRolesCompatible) {
1245 neighbourRoleSetLabelRef.setReferredTemporaryLabelData(nullptr);
1246 neighbourRoleSetLabelRef.setReferredLabelData(prevLabel);
1247 }
1248 }
1249 }
1250
1251
1252 neigbourRoleInstantiatedSetCompination->insert(neighbourRoleSetLabelRef);
1253
1254
1255 bool alreadyPresent = false;
1256 if (!requiresAllLinksCollecting && indiAssData && neighbourRoleSetLabelRef.getReferredLabelData()) {
1257 CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* neighbourRoleSetHash = indiAssData->getNeighbourRoleSetHash();
1258 if (neighbourRoleSetHash) {
1259 if (neighbourRoleSetLabelRef.getReferredLabelData() == neighbourRoleSetHash->getNeighbourRoleSetLabel(connIndiMergedNominalId)) {
1260 alreadyPresent = true;
1261 }
1262 }
1263 }
1264
1265 if (!alreadyPresent) {
1266 CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker* newRoleSetNeighbourUpdateLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker >::allocateAndConstruct(mMemAllocMan);
1267 newRoleSetNeighbourUpdateLinker->initRoleSetNeighbourUpdateDataLinker(neighbourRoleSetLabelRef, connIndiMergedNominalId);
1268 roleSetNeighbourUpdateLinker = newRoleSetNeighbourUpdateLinker->append(roleSetNeighbourUpdateLinker);
1269 }
1270 }
1271
1272 allConnIndiHandled = true;
1273 if (connIndiMergedHashIt != connIndiMergedHashItEnd) {
1274 while (!connIndiMergedHashIt.value().isMergedWithIndividual() && connIndiMergedHashIt != connIndiMergedHashItEnd) {
1275 ++connIndiMergedHashIt;
1276 }
1277 connIndiMergedNominalId = connIndiMergedHashIt.key();
1278 CIndividualMergingHashData mergingData = connIndiMergedHashIt.value();
1279 allConnIndiHandled = false;
1280 connIndiDetMerged = true;
1281 if (!mergingData.getDependencyTrackPoint() || mergingData.getDependencyTrackPoint()->getBranchingTag() > nonMergeConsideredMaxDetBranchTag) {
1282 connIndiDetMerged = false;
1283 }
1284 ++connIndiMergedHashIt;
1285 }
1286 }
1287
1288 }
1289 }
1290
1291
1292
1293 if (extIndiBackSyncData && !extIndiBackSyncData->hasNonDeterministicallyMergedIndividuals() && !extIndiBackSyncData->hasNewlyMergedAllNeighbourExpansion() && extIndiBackSyncData->hasNewlyMergedIndividuals() && extIndiBackSyncData->hasNewlyMergedInferringNeighbourExpansion()) {
1294 CBackendRepresentativeMemoryLabelCacheItem* detSameIndiSetLabel = indiAssData->getDeterministicConceptSetLabelCacheEntry();
1295 visitMergedIndividualNodesAssociationData(extractionIndiNode, indiAssData, detSameIndiSetLabel, true, maxDetBranchTag, [&](cint64 mergedIndiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* mergedIndiAssData, bool deterministicallyMerged)->bool {
1296
1297 if (!mergedIndiAssData->hasDeterministicSameIndividualMerging()) {
1298
1299 CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* neighbourRoleSetHash = indiAssData->getNeighbourRoleSetHash();
1300
1301 CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* mergedNeighbourRoleSetArray = mergedIndiAssData->getRoleSetNeighbourArray();
1302 if (mergedNeighbourRoleSetArray) {
1303 CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData* neighbourRoleSetArrayIndexData = mergedNeighbourRoleSetArray->getIndexData();
1304 for (cint64 i = 0; i < neighbourRoleSetArrayIndexData->getArraySize(); ++i) {
1305 CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetlabel = neighbourRoleSetArrayIndexData->getNeighbourRoleSetLabel(i);
1306
1307 if (!neighbourRoleSetlabel->hasNondeterministicElements() && !neigbourRoleInstantiatedSetCompination->contains(neighbourRoleSetlabel)) {
1308 mergedNeighbourRoleSetArray->at(i).visitNeighbourIndividualIds([&](cint64 neighbourIndiId)->bool {
1309
1310 bool neighbourNodeConnectionAvailable = true;
1311 CIndividualProcessNode* neighbourIndiNode = indiProcNodeVec->getData(-neighbourIndiId);
1312 if (!neighbourIndiNode) {
1313 neighbourNodeConnectionAvailable = false;
1314 } else if (!connIndiSet->contains(-neighbourIndiId)) {
1315 neighbourIndiNode = getMergedIntoIndividualNode(neighbourIndiNode, false, calcAlgContext);
1316 cint64 mergedIntoNeighbourId = neighbourIndiNode->getNominalIndividual()->getIndividualID();
1317 if (!connIndiSet->contains(-mergedIntoNeighbourId)) {
1318 neighbourNodeConnectionAvailable = false;
1319 }
1320 }
1321
1322
1323 if (!neighbourNodeConnectionAvailable) {
1324 neigbourRoleInstantiatedSetCompination->insert(neighbourRoleSetlabel);
1325
1326 visitRolesOfAssociatedNeigbourRoleSetLabel(mergedIndiAssData, neighbourRoleSetlabel, [&](CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)->bool {
1327 if (!nondeterministic) {
1328 neigbourRoleInstantiatedSetCompination->insert(CBackendRepresentativeMemoryCacheTemporaryLabelReference(neighbourRoleSetlabel));
1329 if (!combinedNeighbourDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1330 combinedNeighbourDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1331 CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1332 combinedNeighbourDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedNeighbourDetRoleInstantiatedLinker);
1333 }
1334 }
1335 return true;
1336 });
1337
1338 return false;
1339 }
1340
1341 return true;
1342 });
1343 }
1344 }
1345 }
1346 }
1347
1348 return true;
1349
1350 }, calcAlgContext);
1351 tmpAssWriteDataLinker->setRequireSameAsNeighboursCompletion(true);
1352 }
1353
1354
1355 // not necessary at the moment since all neighbours are expanded if new nominal individuals are merged
1356 //// add links from the association data of merged individuals, i.e., add all links of other association data that are not in the completion graph and also not as a neighbour in the current association data
1357 //visitMergedIndividualNodesAssociationData(extractionIndiNode, indiAssData, maxSameIndiSetLabel, true, maxDetBranchTag, [&](cint64 mergedIndiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* mergedIndiAssData, bool deterministicallyMerged)->bool {
1358
1359 // CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* neighbourRoleSetHash = indiAssData->getNeighbourRoleSetHash();
1360
1361 // if (mergedIndiAssData != indiAssData) {
1362 // CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* mergedNeighbourRoleSetArray = mergedIndiAssData->getRoleSetNeighbourArray();
1363 // if (mergedNeighbourRoleSetArray) {
1364 // CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArrayIndexData* neighbourRoleSetArrayIndexData = mergedNeighbourRoleSetArray->getIndexData();
1365 // for (cint64 i = 0; i < neighbourRoleSetArrayIndexData->getArraySize(); ++i) {
1366 // CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetlabel = neighbourRoleSetArrayIndexData->getNeighbourRoleSetLabel(i);
1367
1368 // mergedNeighbourRoleSetArray->at(i).visitNeighbourIndividualIds([&](cint64 neighbourIndiId)->bool {
1369
1370 // if (!connIndiSet->contains(-neighbourIndiId) && (!neighbourRoleSetHash || !neighbourRoleSetHash->getNeighbourRoleSetLabel(neighbourIndiId))) {
1371 // if (!neigbourRoleInstantiatedSetCompination->contains(neighbourRoleSetlabel)) {
1372 // neigbourRoleInstantiatedSetCompination->insert(neighbourRoleSetlabel);
1373
1374 // visitRolesOfAssociatedNeigbourRoleSetLabel(mergedIndiAssData, neighbourRoleSetlabel, [&](CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)->bool {
1375 // if (nondeterministic || !deterministicallyMerged) {
1376 // // should never happen, since such non-deterministic neighbour links are considered in the completion graph
1377 // //if (!combinedNeighbourNonDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1378 // // combinedNeighbourNonDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1379 // // CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1380 // // combinedNeighbourNonDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedNeighbourNonDetRoleInstantiatedLinker);
1381 // // neigbourRoleInstantiatedSetCompination->insert(CBackendRepresentativeMemoryCacheTemporaryLabelReference(neighbourRoleSetlabel));
1382 // //}
1383 // } else {
1384 // neigbourRoleInstantiatedSetCompination->insert(CBackendRepresentativeMemoryCacheTemporaryLabelReference(neighbourRoleSetlabel));
1385 // if (!combinedNeighbourDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1386 // combinedNeighbourDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1387 // CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1388 // combinedNeighbourDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedNeighbourDetRoleInstantiatedLinker);
1389 // }
1390 // }
1391 // return true;
1392 // });
1393
1394 // }
1395
1396 // CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker* newRoleSetNeighbourUpdateLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker >::allocateAndConstruct(mMemAllocMan);
1397 // newRoleSetNeighbourUpdateLinker->initRoleSetNeighbourUpdateDataLinker(CBackendRepresentativeMemoryCacheTemporaryLabelReference(neighbourRoleSetlabel), neighbourIndiId);
1398 // roleSetNeighbourUpdateLinker = newRoleSetNeighbourUpdateLinker->append(roleSetNeighbourUpdateLinker);
1399 // }
1400
1401 // return true;
1402 // });
1403 // }
1404 // }
1405 // }
1406
1407 // return true;
1408 //}, calcAlgContext);
1409
1410
1411
1412
1413 if (indiAssData && (!requiresAllLinksCollecting || propagationCut)) {
1414 // add link data for not expanded neighbours from the previous data
1415 if (combinedNeighbourDetRoleInstantiatedLinker || combinedNeighbourNonDetRoleInstantiatedLinker || propagationCut) {
1416
1417 CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* neighbourRoleSetArray = indiAssData->getRoleSetNeighbourArray();
1418 if (neighbourRoleSetArray) {
1419 CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData* neighbourRoleSetArrayIndexData = neighbourRoleSetArray->getIndexData();
1420 for (cint64 i = 0; i < neighbourRoleSetArrayIndexData->getArraySize(); ++i) {
1421 CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetlabel = neighbourRoleSetArrayIndexData->getNeighbourRoleSetLabel(i);
1422 bool hasNonDetElems = neighbourRoleSetlabel->hasNondeterministicElements();
1423
1424 if ((neighbourRoleSetlabel->getCacheValueCount() != 1 || neighbourRoleSetlabel->getCacheValueLinker()->getData().getTag() != 1)) {
1425
1426 neighbourRoleSetArray->at(i).visitNeighbourIndividualIds([&](cint64 neighbourIndiId)->bool {
1427 bool neighbourNodeAvailable = true;
1428 bool neighbourNodeConnectionAvailable = true;
1429 CIndividualProcessNode* neighbourIndiNode = indiProcNodeVec->getData(-neighbourIndiId);
1430 if (!neighbourIndiNode) {
1431 neighbourNodeAvailable = false;
1432 neighbourNodeConnectionAvailable = false;
1433 } else if (!connIndiSet->contains(-neighbourIndiId)) {
1434 neighbourIndiNode = getMergedIntoIndividualNode(neighbourIndiNode, false, calcAlgContext);
1435 cint64 mergedIntoNeighbourId = neighbourIndiNode->getNominalIndividual()->getIndividualID();
1436 if (!connIndiSet->contains(-mergedIntoNeighbourId)) {
1437 neighbourNodeConnectionAvailable = false;
1438 }
1439 }
1440
1441 if ((!hasNonDetElems || !propagationCut) && (!neighbourNodeConnectionAvailable || !neighbourNodeAvailable && hasNonDetElems && extractionIndiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFBACKENDEXPANSIONREUSINGINDIVIDUAL))) {
1442 neigbourRoleInstantiatedSetCompination->insert(CBackendRepresentativeMemoryCacheTemporaryLabelReference(neighbourRoleSetlabel));
1443
1444 // neighbour node is not present/connected in completion graph, i.e., make sure previous neighbour connections are correctly considered
1445 visitRolesOfAssociatedNeigbourRoleSetLabel(indiAssData, neighbourRoleSetlabel, [&](CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)->bool {
1446 if (nondeterministic) {
1447 if (extractionIndiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFBACKENDEXPANSIONREUSINGINDIVIDUAL) && !combinedNeighbourNonDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1448 combinedNeighbourNonDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1449 CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1450 combinedNeighbourNonDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedNeighbourNonDetRoleInstantiatedLinker);
1451 }
1452 // should never happen, since such non-deterministic neighbour links are considered in the completion graph
1453 //CIndividualProcessNode* neighbourIndiNode = indiProcNodeVec->getData(-neighbourIndiId);
1454 //if (!neighbourIndiNode && !combinedNeighbourNonDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1455 // combinedNeighbourNonDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1456 // CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1457 // combinedNeighbourNonDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedNeighbourNonDetRoleInstantiatedLinker);
1458 // neigbourRoleInstantiatedSetCompination->insert(CBackendRepresentativeMemoryCacheTemporaryLabelReference(neighbourRoleSetlabel));
1459 //}
1460 } else {
1461 if (!combinedNeighbourDetRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) {
1462 combinedNeighbourDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1463 CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager());
1464 combinedNeighbourDetRoleInstantiatedLinker = newRoleLinker->init(role, inversed, combinedNeighbourDetRoleInstantiatedLinker);
1465 }
1466 }
1467 return true;
1468 });
1469
1470 // stop iterating through individuals as soon as the first unexpanded has been found
1471 return false;
1472 } else if (!neighbourNodeAvailable && propagationCut && hasNonDetElems) {
1473 // deterministic neighbour label reduction for propagation cut
1474 CBackendRepresentativeMemoryCacheRoleAssertionLinker* roleAssertionLinker = nullptr;
1475 visitRolesOfAssociatedNeigbourRoleSetLabel(indiAssData, neighbourRoleSetlabel, [&](CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)->bool {
1476 if (!nondeterministic) {
1477 combinedNeighbourNonDetRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed));
1478 CBackendRepresentativeMemoryCacheRoleAssertionLinker* linker = CObjectAllocator< CBackendRepresentativeMemoryCacheRoleAssertionLinker >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager());
1479 linker->initRoleAssertionLinker(role, inversed, assertionLinkBase, nominalLinkBase, false);
1480 roleAssertionLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)linker->append(roleAssertionLinker);
1481 }
1482 return true;
1483 });
1484 if (roleAssertionLinker) {
1485 CBackendRepresentativeMemoryCacheTemporaryLabelReference neighbourRoleSetLabelRef = getNeighbourRoleInstantiatedSetLabelAssociationBackendItem(nullptr, roleAssertionLinker, nullptr, calcAlgContext);
1486 neigbourRoleInstantiatedSetCompination->insert(CBackendRepresentativeMemoryCacheTemporaryLabelReference(neighbourRoleSetlabel));
1487 }
1488 return false;
1489 }
1490 return true;
1491 });
1492 }
1493 }
1494 }
1495
1496 }
1497 }
1498
1499
1500
1501
1502
1503
1504
1505 if (combinedExistentialDetRoleInstantiatedLinker) {
1506 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, combinedExistentialDetRoleInstantiatedLinker, combinedExistentialDetRoleInstantiatedSet, false, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext);
1507 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1508 updated = true;
1509 } else if (!requiresAllLinksCollecting && indiAssData) {
1510 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL);
1511 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1512 }
1513
1514 if (combinedExistentialNonDetRoleInstantiatedLinker) {
1515 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, combinedExistentialNonDetRoleInstantiatedLinker, combinedExistentialNonDetRoleInstantiatedSet, false, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext);
1516 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1517 updated = true;
1518 } else if (!requiresAllLinksCollecting && indiAssData) {
1519 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL);
1520 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1521 }
1522
1523
1524
1525
1526
1527
1528 if (combinedDataDetRoleInstantiatedLinker) {
1529 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL, combinedDataDetRoleInstantiatedLinker, combinedDataDetRoleInstantiatedSet, false, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext);
1530 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1531 updated = true;
1532 } else if (!requiresAllLinksCollecting && indiAssData) {
1533 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL);
1534 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1535 }
1536
1537 if (combinedDataNonDetRoleInstantiatedLinker) {
1538 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL, combinedDataNonDetRoleInstantiatedLinker, combinedDataNonDetRoleInstantiatedSet, false, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext);
1539 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1540 updated = true;
1541 } else if (!requiresAllLinksCollecting && indiAssData) {
1542 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL);
1543 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1544 }
1545
1546
1547
1548
1549
1550
1551 if (combinedNeighbourDetRoleInstantiatedLinker) {
1552 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, combinedNeighbourDetRoleInstantiatedLinker, combinedNeighbourDetRoleInstantiatedSet, false, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext);
1553 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1554 updated = true;
1555 } else if (!requiresAllLinksCollecting && indiAssData) {
1556 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL);
1557 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1558 }
1559
1560 if (combinedNeighbourNonDetRoleInstantiatedLinker) {
1561 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, combinedNeighbourNonDetRoleInstantiatedLinker, combinedNeighbourNonDetRoleInstantiatedSet, false, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext);
1562 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1563 updated = true;
1564 } else if (!requiresAllLinksCollecting && indiAssData) {
1565 CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL);
1566 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, labelRef);
1567 }
1568
1569 if (!combinedNeighbourDetRoleInstantiatedLinker && !combinedNeighbourNonDetRoleInstantiatedLinker) {
1570 if (indiAssData) {
1571 CBackendRepresentativeMemoryCacheTemporaryLabelReference tmpLabelRef(indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL));
1572 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, tmpLabelRef);
1573 }
1574 }
1575
1576 tmpAssWriteDataLinker->setRoleSetNeighbourUpdateDataLinker(roleSetNeighbourUpdateLinker);
1577
1578 if (neigbourRoleInstantiatedSetCompination && !neigbourRoleInstantiatedSetCompination->isEmpty()) {
1579 updated |= determineNeighbourRoleInstantiatedSetCompinationLabelAssociationBackendItem(neigbourRoleInstantiatedSetCompination, tmpAssWriteDataLinker, calcAlgContext);
1580 } else {
1581 CBackendRepresentativeMemoryCacheTemporaryLabelReference tmpLabelRef(indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL));
1582 tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL, tmpLabelRef);
1583 }
1584
1585 return updated;
1586
1587 }
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597 CIndividualProcessNode* CIndividualNodeBackendCacheHandler::getMergedIntoIndividualNode(CIndividualProcessNode* indi, bool onlyDeterministic, CCalculationAlgorithmContext* calcAlgContext) {
1598 CIndividualProcessNode* mergedIntoIndiNode = indi;
1599 CIndividualProcessNodeVector* indiProcNodeVec = calcAlgContext->getProcessingDataBox()->getIndividualProcessNodeVector();
1600 cint64 maxDetBranchTag = calcAlgContext->getProcessingDataBox()->getMaximumDeterministicBranchTag();
1601 while (mergedIntoIndiNode->getMergedIntoIndividualNodeID() != mergedIntoIndiNode->getIndividualNodeID() && (!onlyDeterministic || mergedIntoIndiNode->getMergedDependencyTrackPoint() && mergedIntoIndiNode->getMergedDependencyTrackPoint()->getBranchingTag() <= maxDetBranchTag)) {
1602 mergedIntoIndiNode = indiProcNodeVec->getData(mergedIntoIndiNode->getMergedIntoIndividualNodeID());
1603 }
1604 return mergedIntoIndiNode;
1605 }
1606
1607
1608
1609
1610 CIndividualRepresentativeBackendCacheConceptSetLabelProcessingHasher CIndividualNodeBackendCacheHandler::getIndividualRepresentativeBackendCacheConceptSetLabelProcessingHasher(CIndividualProcessNode* indiNode, CCalculationAlgorithmContext* calcAlgContext) {
1611 CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData* backendSyncData = (CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData*)indiNode->getIndividualBackendCacheSynchronisationData(false);
1612 CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = backendSyncData->getAssocitaionData();
1613 CBackendRepresentativeMemoryLabelCacheItem* conceptSetLabelItem = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL);
1614 CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetCombinationLabelItem = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL);
1615 // TODO: also consider outgoing data property set labels to hasher
1616 CIndividualRepresentativeBackendCacheConceptSetLabelProcessingHasher hasher(conceptSetLabelItem, neighbourRoleSetCombinationLabelItem);
1617 return hasher;
1618 }
1619
1620
1621 bool CIndividualNodeBackendCacheHandler::tryAssociateNodesWithBackendCache(CXLinker<CIndividualProcessNode*>* indiNodeLinker, CSatisfiableTaskRepresentativeBackendUpdatingAdapter* repbackUpdAdapter, CCalculationAlgorithmContext* calcAlgContext) {
1622
1623
1624 mSignatureTmpDetConSetRefLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64,CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(),calcAlgContext->getUsedTaskProcessorContext());
1625 mSignatureTmpNonDetConSetRefLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1626
1627 mSignatureTmpDetSameIndiSetRefLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1628 mSignatureTmpNonDetSameIndiSetRefLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1629
1630 mSignatureTmpDetDiffIndiSetRefLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1631 mSignatureTmpNonDetDiffIndiSetRefLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1632
1633 mTmpConceptLabelTmpCardDataHash = CObjectParameterizingAllocator< CPROCESSHASH< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*, CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1634
1635 mSignatureTmpIndiConnIndiSetRefLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1636
1637 mSignatureTmpRefNeigbourRoleInstantiatedSetCombinationLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1638 mRoleInversionTmpRefNeighbourInstantiatedRoleSetLabelHash = CObjectParameterizingAllocator< CPROCESSHASH< TRoleInversionPair, CBackendRepresentativeMemoryCacheTemporaryLabelReference* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1639
1640 mSuperRoleSignatureCacheValueTmpRefNeighbourInstantiatedRoleSetLabelPairHash = CObjectParameterizingAllocator< CPROCESSHASH< cint64, CCacheValueTmpLabelReferenceData* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1641
1642 for (cint64 i = 0; i < CBackendRepresentativeMemoryLabelCacheItem::LABEL_CACHE_ITEM_TYPE_COUNT; ++i) {
1643 mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[i] = CObjectParameterizingAllocator< CPROCESSHASH< CProcessSetHasher<TRoleInversionPair>, CBackendRepresentativeMemoryCacheTemporaryLabelReference* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1644 }
1645
1646 mNewTmpLabelList = CObjectParameterizingAllocator< CPROCESSLIST< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1647 mNewTmpCardList = CObjectParameterizingAllocator< CPROCESSLIST< CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1648
1649 prepareCacheMessages(calcAlgContext);
1650
1651 CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker = nullptr;
1652
1653
1654 CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* >* nominalIndirectConnectionUpdateDataLinkerHash = CObjectParameterizingAllocator< CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1655
1656
1657 CPROCESSHASH< CIndividualRepresentativeBackendCacheConceptSetLabelProcessingHasher, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker*>* conceptSetLabelHasherWriteDataLinkerHasher = CObjectParameterizingAllocator< CPROCESSHASH< CIndividualRepresentativeBackendCacheConceptSetLabelProcessingHasher, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1658 CPROCESSLIST< CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* >* mTmpDelayedInitResolvingLabelList = CObjectParameterizingAllocator< CPROCESSLIST< CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1659
1660
1661 CBackendRepresentativeMemoryCacheTemporaryAssociationUseDataLinker* tmpAssUseDataLinker = nullptr;
1662 CIndividualRepresentativeBackendCacheLoadedAssociationHash* indiLoadedAssocHash = calcAlgContext->getUsedProcessingDataBox()->getBackendCacheLoadedAssociationHash(true);
1663 indiLoadedAssocHash->unshareAll();
1664
1665
1666 CIndividualProcessNodeVector* indiProcNodeVec = calcAlgContext->getProcessingDataBox()->getIndividualProcessNodeVector();
1667
1668 QSet<cint64>* propCutIndiSet = nullptr;
1669 CBackendRepresentativeMemoryCacheTemporaryPropagationCutDataLinker* propCutData = getPropagationCutIndividualData(propCutIndiSet, repbackUpdAdapter, calcAlgContext);
1670
1671 for (CXLinker<CIndividualProcessNode*>* indiNodeLinkerIt = indiNodeLinker; indiNodeLinkerIt; indiNodeLinkerIt = indiNodeLinkerIt->getNext()) {
1672 CIndividualProcessNode* indiNode = indiNodeLinkerIt->getData();
1673
1674 CIndividual* nominalIndividual = indiNode->getNominalIndividual();
1675 if (nominalIndividual) {
1676 indiNode = indiProcNodeVec->getData(indiNode->getIndividualNodeID());
1677
1678 //if (CIRIName::getRecentIRIName(nominalIndividual->getIndividualNameLinker()) == "http://www.Department1.University0.edu/StudentWhoLikesTennisButDislikesBasketBallAndBaseBall") {
1679 // bool debug = true;
1680 //}
1681
1682 CIndividualRepresentativeBackendCacheLoadedAssociationData& assoLoadingData = (*indiLoadedAssocHash)[nominalIndividual->getIndividualID()];
1683
1684
1685 CIndividualProcessNode* detMergedIntoIndiNode = getMergedIntoIndividualNode(indiNode, true, calcAlgContext);
1686 CIndividualProcessNode* nonDetMergedIntoIndiNode = getMergedIntoIndividualNode(detMergedIntoIndiNode, false, calcAlgContext);
1687
1688
1689 CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* newAssWriteDataLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker >::allocateAndConstruct(mMemAllocMan);
1690
1691
1692 if (!nominalIndividual->isTemporaryIndividual()) {
1693 newAssWriteDataLinker->initAccociationWriteData(nominalIndividual, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::REPLACEMENT, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::ADDITION);
1694 } else {
1695 newAssWriteDataLinker->initAccociationWriteData(nominalIndividual->getIndividualID(), CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::REPLACEMENT, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::ADDITION);
1696 }
1697
1698 CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData* nonDetMergedIntoIndiNodeBackendSyncData = (CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData*)nonDetMergedIntoIndiNode->getIndividualBackendCacheSynchronisationData(false);
1699 newAssWriteDataLinker->setScheduledIndividual(nonDetMergedIntoIndiNodeBackendSyncData->isScheduledIndividual());
1700
1701 if (assoLoadingData.getLoadedIndividualAssociationData()) {
1702 newAssWriteDataLinker->setUsedAssociationUpdateId(assoLoadingData.getLoadedIndividualAssociationData()->getAssociationDataUpdateId());
1703 }
1704
1705 if (indiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFSYNCHRONIZEDBACKENPROCESSINGDELAYING)) {
1706 assoLoadingData.setIndividualIntegrated(true);
1707
1708 for (cint64 i = 0; i < CBackendRepresentativeMemoryLabelCacheItem::LABEL_CACHE_ITEM_ASSOCIATABLE_TYPE_COUNT; ++i) {
1709 newAssWriteDataLinker->setReferredLabelData(i, assoLoadingData.getLoadedIndividualAssociationData()->getLabelCacheEntry(i));
1710 }
1711
1712
1713 mTmpDelayedInitResolvingLabelList->append(newAssWriteDataLinker);
1714 } else {
1715
1716 newAssWriteDataLinker->setRepresentativeSameIndividualId(detMergedIntoIndiNode->getNominalIndividual()->getIndividualID());
1717 newAssWriteDataLinker->setDeterministicSameIndividualId(detMergedIntoIndiNode->getNominalIndividual()->getIndividualID());
1718
1719 if (indiNode->getNominalIndividual()->getIndividualID() == detMergedIntoIndiNode->getNominalIndividual()->getIndividualID()) {
1720
1721 bool integratedAllMergingsFlag = false;
1722 determineSameIndividualSetLabelAssociationBackendItem(detMergedIntoIndiNode, CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL, newAssWriteDataLinker, &integratedAllMergingsFlag, calcAlgContext);
1723 if (!integratedAllMergingsFlag || detMergedIntoIndiNode != nonDetMergedIntoIndiNode) {
1724 determineSameIndividualSetLabelAssociationBackendItem(nonDetMergedIntoIndiNode, CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL, newAssWriteDataLinker, &integratedAllMergingsFlag, calcAlgContext);
1725 }
1726
1727 bool integratedAllDifferentFlag = false;
1728 determineDifferentIndividualSetLabelAssociationBackendItem(detMergedIntoIndiNode, CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_DIFFRENT_INDIVIDUAL_SET_LABEL, newAssWriteDataLinker, &integratedAllDifferentFlag, calcAlgContext);
1729 if (!integratedAllDifferentFlag || detMergedIntoIndiNode != nonDetMergedIntoIndiNode) {
1730 determineDifferentIndividualSetLabelAssociationBackendItem(nonDetMergedIntoIndiNode, CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_DIFFRENT_INDIVIDUAL_SET_LABEL, newAssWriteDataLinker, &integratedAllDifferentFlag, calcAlgContext);
1731 }
1732
1733 //determineConceptSetLabelAssociationBackendItem(detMergedIntoIndiNode, CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_CONCEPT_SET_LABEL, newAssWriteDataLinker, calcAlgContext);
1734 //if (detMergedIntoIndiNode == nonDetMergedIntoIndiNode) {
1735 // determineConceptSetLabelAssociationBackendItem(nonDetMergedIntoIndiNode, CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_CONCEPT_SET_LABEL, newAssWriteDataLinker, calcAlgContext);
1736 //} else {
1737 // determineNondeterministicConceptSetLabelAssociationBackendItemWithExcludedConceptsFromDeterministicLabel(nonDetMergedIntoIndiNode, indiNode, newAssWriteDataLinker, calcAlgContext);
1738 //}
1739 determineFullConceptSetLabelAssociationBackendItemWithSeparatedDeterministicNode(nonDetMergedIntoIndiNode, detMergedIntoIndiNode, indiNode, newAssWriteDataLinker, calcAlgContext);
1740
1741 CPROCESSHASH<CRole*, cint64>* roleUsedCardHash = nullptr;
1742 if (nonDetMergedIntoIndiNode->getReapplyConceptLabelSet(false)->getConceptFlags()->containsATMOSTCardinalityFlags()) {
1743 roleUsedCardHash = CObjectParameterizingAllocator< CPROCESSHASH<CRole*, cint64>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1744 }
1745
1746 CPROCESSSET<cint64>* existentialIndirectlyConnectedNominalIndividualSet = nullptr;
1747 determineRoleInstantiatedSetLabelAssociationBackendItems(nonDetMergedIntoIndiNode, indiNode, nonDetMergedIntoIndiNode != detMergedIntoIndiNode, newAssWriteDataLinker, &existentialIndirectlyConnectedNominalIndividualSet, roleUsedCardHash, propCutIndiSet, calcAlgContext);
1748
1749
1750 if (roleUsedCardHash) {
1751 determineAssociationBackendCardinality(nonDetMergedIntoIndiNode, roleUsedCardHash, newAssWriteDataLinker, calcAlgContext);
1752 }
1753
1754
1755 CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = getIndividualAssociationDataFromIndividualNode(indiNode, calcAlgContext);
1756 CBackendRepresentativeMemoryLabelCacheItem* indiConNomLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::INDIRECTLY_CONNECTED_NOMINAL_INDIVIDUAL_SET_LABEL);
1757 if (!existentialIndirectlyConnectedNominalIndividualSet && indiConNomLabel && indiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFSYNCHRONIZEDBACKENDSUCCESSOREXPANSIONBLOCKED)) {
1758 newAssWriteDataLinker->setReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::INDIRECTLY_CONNECTED_NOMINAL_INDIVIDUAL_SET_LABEL, indiConNomLabel);
1759 }
1760
1761
1762 if (existentialIndirectlyConnectedNominalIndividualSet) {
1763 existentialIndirectlyConnectedNominalIndividualSet->remove(indiNode->getNominalIndividual()->getIndividualID());
1764 if (!existentialIndirectlyConnectedNominalIndividualSet->isEmpty()) {
1765 determineIndirectlyConnectedNominalIndividualSetLabelAssociationBackendItem(existentialIndirectlyConnectedNominalIndividualSet, newAssWriteDataLinker, calcAlgContext);
1766
1767 for (CPROCESSSET<cint64>::const_iterator it = existentialIndirectlyConnectedNominalIndividualSet->constBegin(), itEnd = existentialIndirectlyConnectedNominalIndividualSet->constEnd(); it != itEnd; ++it) {
1768 cint64 nomIndiId = *it;
1769
1770 CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker*& nomIndiConnDataLinker = (*nominalIndirectConnectionUpdateDataLinkerHash)[nomIndiId];
1771 if (!nomIndiConnDataLinker) {
1772 nomIndiConnDataLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker >::allocateAndConstruct(mMemAllocMan);
1773 nomIndiConnDataLinker->initNominalIndirectConnectionData(nomIndiId);
1774 if (assoLoadingData.getLoadedIndividualAssociationData()) {
1775 nomIndiConnDataLinker->setLastChangeIntegrationId(assoLoadingData.getLoadedIndividualAssociationData()->getLastIntegratedIndirectlyConnectedIndividualsChangeId());
1776 }
1777 }
1778
1779 // only add linker if the individual was not already connected to the nominal (based on the previous indirectly connected nominal individual set label)
1780 if (!indiConNomLabel || !mAssBackCacheReader->hasIndividualIdsInAssociatedIndividualSetLabel(indiAssData, indiConNomLabel, nominalIndividual->getIndividualID())) {
1781 CXLinker<cint64>* indiIdLinker = CObjectAllocator< CXLinker<cint64> >::allocateAndConstruct(mMemAllocMan);
1782 indiIdLinker->initLinker(nominalIndividual->getIndividualID());
1783 nomIndiConnDataLinker->addIndirectlyConnectedIndividualIdLinker(indiIdLinker);
1784 }
1785 }
1786 }
1787 }
1788
1789
1790 assoLoadingData.setIndividualIntegrated(true);
1791 newAssWriteDataLinker->setCompletelyHandled(true);
1792 newAssWriteDataLinker->setCompletelyPropagated(true);
1793
1794 if (assoLoadingData.hasIndirectlyConnectedIndividualsIntegration()) {
1795 newAssWriteDataLinker->setIndirectlyConnectedIndividualIntegration(true);
1796 if (assoLoadingData.getLoadedNominalIndirectConnectionData()) {
1797 newAssWriteDataLinker->setIntegratedIndirectlyConnectedIndividualsChangeId(assoLoadingData.getLoadedNominalIndirectConnectionData()->getLastChangeId());
1798 }
1799 }
1800
1801
1802 // TODO: check whether there is indeed some update
1803 tmpAssWriteDataLinker = newAssWriteDataLinker->append(tmpAssWriteDataLinker);
1804
1805
1806 CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData* backSyncData = (CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData*)indiNode->getIndividualBackendCacheSynchronisationData(false);
1807 if (backSyncData && !backSyncData->hasNonConceptSetBackendLabelRelatedProcessing()) {
1808 CIndividualRepresentativeBackendCacheConceptSetLabelProcessingHasher hasher = getIndividualRepresentativeBackendCacheConceptSetLabelProcessingHasher(indiNode, calcAlgContext);
1809 conceptSetLabelHasherWriteDataLinkerHasher->insert(hasher, newAssWriteDataLinker);
1810 }
1811
1812 } else {
1813 assoLoadingData.setIndividualIntegrated(true);
1814 tmpAssWriteDataLinker = newAssWriteDataLinker->append(tmpAssWriteDataLinker);
1815 }
1816
1817 }
1818 }
1819 }
1820
1821
1822
1823 if (mTmpDelayedInitResolvingLabelList && !mTmpDelayedInitResolvingLabelList->isEmpty()) {
1824
1825
1826 //CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* >* mIndiWriteDataLinkerHash = CObjectParameterizingAllocator< CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext());
1827
1828 //for (CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinkerIt = tmpAssWriteDataLinker; tmpAssWriteDataLinkerIt; tmpAssWriteDataLinkerIt = tmpAssWriteDataLinkerIt->getNext()) {
1829 // cint64 indiId = tmpAssWriteDataLinkerIt->getData()->getIndividualID();
1830 // mIndiWriteDataLinkerHash->insert(indiId, tmpAssWriteDataLinkerIt);
1831 //}
1832
1833 //CIndividualRepresentativeBackendCacheConceptSetLabelProcessingHash* useBackendConceptSetLabelProcessingHash = calcAlgContext->getProcessingDataBox()->getBackendCacheConceptSetLabelProcessingHash(false);
1834 //CIndividualDelayedBackendInitializationProcessingQueue* delayedBackendInitProcessingQueue = calcAlgContext->getProcessingDataBox()->getDelayedBackendConceptSetLabelProcessingInitializationQueue(false);
1835
1836 for (CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpDelayedInitResolvingLabel : *mTmpDelayedInitResolvingLabelList) {
1837
1838 CIndividualProcessNode* indiNode = indiProcNodeVec->getData(-tmpDelayedInitResolvingLabel->getIndividualID());
1839 CIndividualRepresentativeBackendCacheConceptSetLabelProcessingHasher hasher = getIndividualRepresentativeBackendCacheConceptSetLabelProcessingHasher(indiNode, calcAlgContext);
1840
1841
1842 CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* writeDataLinker = conceptSetLabelHasherWriteDataLinkerHasher->value(hasher);
1843 tmpDelayedInitResolvingLabel->setCompletelyHandled(true);
1844 tmpDelayedInitResolvingLabel->setCompletelyPropagated(true);
1845
1846 //CIndividualProcessNode* queuIndiNode = nullptr;
1847 //if (!writeDataLinker) {
1848 // CIndividualRepresentativeBackendCacheConceptSetLabelProcessingData data = useBackendConceptSetLabelProcessingHash->value(hasher);
1849 // queuIndiNode = indiProcNodeVec->getData(data.mLastInitScheduledIndiNodeId);
1850 // CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData* queuedBackSyncData = (CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData*)queuIndiNode->getIndividualBackendCacheSynchronisationData(false);
1851 //}
1852
1853
1854 tmpDelayedInitResolvingLabel->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, writeDataLinker->getReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL));
1855 tmpDelayedInitResolvingLabel->setReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, writeDataLinker->getReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL));
1856
1857 tmpDelayedInitResolvingLabel->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, writeDataLinker->getReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL));
1858 tmpDelayedInitResolvingLabel->setReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, writeDataLinker->getReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL));
1859
1860 tmpDelayedInitResolvingLabel->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL, writeDataLinker->getReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL));
1861 tmpDelayedInitResolvingLabel->setReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL, writeDataLinker->getReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL));
1862
1863
1864
1865 tmpAssWriteDataLinker = tmpDelayedInitResolvingLabel->append(tmpAssWriteDataLinker);
1866 }
1867 }
1868
1869
1870
1871 CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* tempNomIndirectConnDataLinker = nullptr;
1872 CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* lastTempNomIndirectConnDataLinker = nullptr;
1873
1874 for (CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinkerIt = tmpAssWriteDataLinker; tmpAssWriteDataLinkerIt; tmpAssWriteDataLinkerIt = tmpAssWriteDataLinkerIt->getNext()) {
1875 cint64 indiId = tmpAssWriteDataLinkerIt->getData()->getIndividualID();
1876 CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* nomIndiConnDataLinker = nominalIndirectConnectionUpdateDataLinkerHash->value(indiId);
1877 if (nomIndiConnDataLinker) {
1878 tmpAssWriteDataLinkerIt->setIndirectlyConnectedNominalIndividual(true);
1879 if (tempNomIndirectConnDataLinker) {
1880 lastTempNomIndirectConnDataLinker->setNext(nomIndiConnDataLinker);
1881 lastTempNomIndirectConnDataLinker = nomIndiConnDataLinker;
1882 } else {
1883 tempNomIndirectConnDataLinker = nomIndiConnDataLinker;
1884 lastTempNomIndirectConnDataLinker = nomIndiConnDataLinker;
1885 }
1886 nominalIndirectConnectionUpdateDataLinkerHash->remove(indiId);
1887 }
1888 }
1889 for (CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* >::const_iterator it = nominalIndirectConnectionUpdateDataLinkerHash->constBegin(), itEnd = nominalIndirectConnectionUpdateDataLinkerHash->constEnd(); it != itEnd; ++it) {
1890 cint64 nomIndiId = it.key();
1891 CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* nomIndiConnDataLinker = it.value();
1892 if (nomIndiConnDataLinker) {
1893 if (tempNomIndirectConnDataLinker) {
1894 lastTempNomIndirectConnDataLinker->setNext(nomIndiConnDataLinker);
1895 lastTempNomIndirectConnDataLinker = nomIndiConnDataLinker;
1896 } else {
1897 tempNomIndirectConnDataLinker = nomIndiConnDataLinker;
1898 lastTempNomIndirectConnDataLinker = nomIndiConnDataLinker;
1899 }
1900 }
1901 }
1902
1903
1904
1905 if (indiLoadedAssocHash) {
1906 for (CIndividualRepresentativeBackendCacheLoadedAssociationHash::const_iterator it = indiLoadedAssocHash->constBegin(), itEnd = indiLoadedAssocHash->constEnd(); it != itEnd; ++it) {
1907 cint64 indiAssoId = it.key();
1908 CIndividualRepresentativeBackendCacheLoadedAssociationData indiAssoLoadingData = it.value();
1909 if (indiAssoLoadingData.getLoadedIndividualAssociationData() && !indiAssoLoadingData.isIndividualIntegrated()) {
1910
1911 CBackendRepresentativeMemoryCacheTemporaryAssociationUseDataLinker* newTmpAssUseDataLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryAssociationUseDataLinker >::allocateAndConstruct(mMemAllocMan);
1912 newTmpAssUseDataLinker->initAccociationUseData(indiAssoId);
1913 newTmpAssUseDataLinker->setUsedAssociationUpdateId(indiAssoLoadingData.getLoadedIndividualAssociationData()->getAssociationDataUpdateId());
1914
1915 tmpAssUseDataLinker = newTmpAssUseDataLinker->append(tmpAssUseDataLinker);
1916 }
1917 }
1918 }
1919
1920 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* tempLabelWriteDataLinker = nullptr;
1921 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* lastTempLabelWriteDataLinker = nullptr;
1922 for (CPROCESSLIST< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* >::const_iterator it = mNewTmpLabelList->constBegin(), itEnd = mNewTmpLabelList->constEnd(); it != itEnd; ++it) {
1923 CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTmpLabelLinker = (*it);
1924 newTmpLabelLinker->clearNext();
1925 if (!lastTempLabelWriteDataLinker) {
1926 tempLabelWriteDataLinker = newTmpLabelLinker;
1927 lastTempLabelWriteDataLinker = tempLabelWriteDataLinker;
1928 } else {
1929 lastTempLabelWriteDataLinker->setNext(newTmpLabelLinker);
1930 lastTempLabelWriteDataLinker = newTmpLabelLinker;
1931 }
1932 }
1933
1934 CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* tempCardWriteDataLinker = nullptr;
1935 for (CPROCESSLIST< CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* >::const_iterator it = mNewTmpCardList->constBegin(), itEnd = mNewTmpCardList->constEnd(); it != itEnd; ++it) {
1936 CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* newTmpCardLinker = (*it);
1937 newTmpCardLinker->clearNext();
1938 tempCardWriteDataLinker = newTmpCardLinker->append(tempCardWriteDataLinker);
1939 }
1940
1941 CBackendRepresentativeMemoryCacheTemporaryInvolvedIndividualDataLinker* involvedIndiData = getInvolvedIndividualData(calcAlgContext);
1942
1943 cint64 ontologyIdentifier = calcAlgContext->getProcessingDataBox()->getOntology()->getOntologyID();
1944 cint64 repCompId = -1;
1945 if (repbackUpdAdapter) {
1946 repCompId = repbackUpdAdapter->getRepresentativeCacheRecomputationId();
1947 }
1948 CBackendRepresentativeMemoryCacheLabelAssociationWriteData* writeData = CObjectAllocator< CBackendRepresentativeMemoryCacheLabelAssociationWriteData >::allocateAndConstruct(mMemAllocMan);
1949 writeData->initWriteData(ontologyIdentifier, tmpAssWriteDataLinker, tempNomIndirectConnDataLinker, tmpAssUseDataLinker, tempLabelWriteDataLinker,tempCardWriteDataLinker, involvedIndiData, propCutData, repCompId);
1950 addCacheMessages(writeData,calcAlgContext);
1951 commitCacheMessages(calcAlgContext);
1952
1953 return false;
1954 }
1955
1956
1957 CBackendRepresentativeMemoryCacheTemporaryPropagationCutDataLinker* CIndividualNodeBackendCacheHandler::getPropagationCutIndividualData(QSet<cint64>*& propCutIndiSet, CSatisfiableTaskRepresentativeBackendUpdatingAdapter* repbackUpdAdapter, CCalculationAlgorithmContext* calcAlgContext) {
1958 CBackendRepresentativeMemoryCacheTemporaryPropagationCutDataLinker* propCutDataLinker = nullptr;
1959 CBackendNeighbourExpansionControllingData* expContData = calcAlgContext->getUsedProcessingDataBox()->getBackendNeighbourExpansionControllingData(false);
1960 if (expContData && expContData->getCutBackendNeighbourExpansionIndividualLinker()) {
1961
1962 repbackUpdAdapter->setExpansionPropagationCutted(true);
1963
1964 CCacheValue propMarkRoleValue = mAssBackCacheReader->getCacheValue(calcAlgContext->getProcessingDataBox()->getOntology()->getRBox()->getTopObjectRole(), false, false, false, true);
1965
1966 CXLinker<cint64>* expandedIndiLinker = nullptr;
1967 CXLinker<CIndividualProcessNode*>* expandedIndiNodeLinker = calcAlgContext->getUsedProcessingDataBox()->getLastBackendCacheIntegratedIndividualNodeLinker();
1968 for (CXLinker<CIndividualProcessNode*>* expandedIndiNodeLinkerIt = expandedIndiNodeLinker; expandedIndiNodeLinkerIt && expandedIndiNodeLinkerIt; expandedIndiNodeLinkerIt = expandedIndiNodeLinkerIt->getNext()) {
1969 cint64 indiId = expandedIndiNodeLinkerIt->getData()->getNominalIndividual()->getIndividualID();
1970 CXLinker<cint64>* tmpIndiLinker = CObjectAllocator< CXLinker<cint64> >::allocateAndConstruct(mMemAllocMan);
1971 expandedIndiLinker = tmpIndiLinker->initLinker(indiId, expandedIndiLinker);
1972 }
1973
1974
1975
1976 CIndividualProcessNodeVector* indiProcNodeVec = calcAlgContext->getProcessingDataBox()->getIndividualProcessNodeVector();
1977 for (CXLinker<CIndividualProcessNode*>* propCutIndiNodeLinkerIt = expContData->getCutBackendNeighbourExpansionIndividualLinker(); propCutIndiNodeLinkerIt; propCutIndiNodeLinkerIt = propCutIndiNodeLinkerIt->getNext()) {
1978 CIndividualProcessNode* propCutIndiNode = propCutIndiNodeLinkerIt->getData();
1979 propCutIndiNode = indiProcNodeVec->getData(propCutIndiNode->getIndividualNodeID());
1980 CIndividualProcessNode* mergedPropCutIndiNode = getMergedIntoIndividualNode(propCutIndiNode, false, calcAlgContext);
1981 cint64 propCutIndiId = propCutIndiNode->getNominalIndividual()->getIndividualID();
1982
1983 if (!propCutIndiSet) {
1984 propCutIndiSet = new QSet<cint64>();
1985 }
1986 propCutIndiSet->insert(propCutIndiId);
1987
1988 CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData* propCutIndiBackendSyncData = (CIndividualNodeRepresentativeMemoryBackendCacheSynchronisationData*)propCutIndiNode->getIndividualBackendCacheSynchronisationData(false);
1989 CBackendRepresentativeMemoryCacheIndividualAssociationData* propCutIndiAssocData = getIndividualAssociationDataFromIndividualNode(propCutIndiNode, calcAlgContext);
1990 cint64 assocUpdateId = propCutIndiAssocData->getAssociationDataUpdateId();
1991
1992 CBackendNeighbourExpansionQueue* remainNeighExpQueue = propCutIndiBackendSyncData->getBackendNeighbourExpansionQueue(false);
1993 if (remainNeighExpQueue) {
1994 remainNeighExpQueue->visitNeighbourExpansionQueueDataLinkers([&](CBackendNeighbourExpansionQueueDataLinker* expQueuedLinker)->bool {
1995 cint64 cursor = expQueuedLinker->getNeighbourVisitingCursor();
1996 cint64 arrayIndex = expQueuedLinker->getNeighbourArrayId();
1997 CConcept* concept = expQueuedLinker->getConcept();
1998 bool conceptNegation = expQueuedLinker->getConceptNegation();
1999 CCacheValue conCacheValue;
2000 if (concept) {
2001
2002 CConcept* opConcept = concept->getOperandList()->getData();
2003 bool opConceptNegation = concept->getOperandList()->isNegated();
2004 bool opConceptTestingNegation = opConceptNegation;
2005 if (conceptNegation && opConcept->getConceptOperator()->hasPartialOperatorCodeFlag(CConceptOperator::CCFS_ALL_AQALL_TYPE | CConceptOperator::CCFS_SOME_TYPE)) {
2006 opConceptTestingNegation = !opConceptTestingNegation;
2007 }
2008
2009 conCacheValue = getCacheValue(opConcept, opConceptTestingNegation);
2010 }
2011 CBackendRepresentativeMemoryCacheTemporaryPropagationCutDataLinker* newPropCutDataLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryPropagationCutDataLinker >::allocateAndConstruct(mMemAllocMan);
2012 newPropCutDataLinker->initPropagationCutData(propCutIndiId, arrayIndex, cursor, conCacheValue, assocUpdateId, expandedIndiLinker, propMarkRoleValue);
2013 if (expQueuedLinker->isMissingNondeterministicExpansionPropagation()) {
2014 newPropCutDataLinker->setMissingNondeterministicExpansionPropagation(true);
2015 }
2016 propCutDataLinker = newPropCutDataLinker->append(propCutDataLinker);
2017 return true;
2018 });
2019 }
2020 }
2021
2022 }
2023 return propCutDataLinker;
2024 }
2025
2026
2027 CBackendRepresentativeMemoryCacheTemporaryInvolvedIndividualDataLinker* CIndividualNodeBackendCacheHandler::getInvolvedIndividualData(CCalculationAlgorithmContext* calcAlgContext) {
2028 CBackendRepresentativeMemoryCacheTemporaryInvolvedIndividualDataLinker* involvedIndiDataLinker = nullptr;
2029 CBackendNeighbourExpansionControllingData* expContData = calcAlgContext->getUsedProcessingDataBox()->getBackendNeighbourExpansionControllingData(false);
2030 if (expContData && !expContData->isFixedReuseExpansionMode() && expContData->isPrioritizedReuseExpansionMode()) {
2031 CREUSEBACKENDEXPANSIONMODESDependencyNode* modesDepNode = expContData->getReuseModesDependencyNode();
2032 if (modesDepNode) {
2033 CXLinker<cint64>* indiLinker = modesDepNode->getInvolvedIndividualIdLinker();
2034 CXLinker<cint64>* copiedIndiLinker = nullptr;
2035 for (CXLinker<cint64>* indiLinkerIt = indiLinker; indiLinkerIt; indiLinkerIt = indiLinkerIt->getNext()) {
2036 cint64 indiId = indiLinkerIt->getData();
2037 CXLinker<cint64>* tmpIndiLinker = CObjectAllocator< CXLinker<cint64> >::allocateAndConstruct(mMemAllocMan);
2038 copiedIndiLinker = tmpIndiLinker->initLinker(indiId, copiedIndiLinker);
2039 }
2040 if (copiedIndiLinker) {
2041 involvedIndiDataLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryInvolvedIndividualDataLinker >::allocateAndConstruct(mMemAllocMan);
2042 involvedIndiDataLinker->initInvolvedIndividualData(copiedIndiLinker);
2043 }
2044 }
2045 }
2046 return involvedIndiDataLinker;
2047 }
2048
2049
2050
2051
2052
2053
2054 }; // end namespace Algorithm
2055
2056 }; // end namespace Kernel
2057
2058 }; // end namespace Reasoner
2059
2060 }; // end namespace Konclude