| 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 "CBackendAssociationCacheHandler.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Algorithm { |
| 31 |
|
| 32 |
CBackendAssociationCacheHandler::CBackendAssociationCacheHandler(CBackendRepresentativeMemoryCacheReader* backAssCacheReader, CBackendRepresentativeMemoryCacheWriter* backAssCacheWriter) { |
| 33 |
mAssBackCacheReader = backAssCacheReader; |
| 34 |
mAssBackCacheWriter = backAssCacheWriter; |
| 35 |
|
| 36 |
mStatCreatedTempLabels = 0; |
| 37 |
mStatReusedTempLabels = 0; |
| 38 |
mStatReusedCachedLabels = 0; |
| 39 |
mStatReusedHashedIndiLabels = 0; |
| 40 |
mStatReusedHashedSignatureLabels = 0; |
| 41 |
|
| 42 |
mTmpContext = nullptr; |
| 43 |
mMemAllocMan = nullptr; |
| 44 |
mWriteData = nullptr; |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
CBackendRepresentativeMemoryCache* CBackendAssociationCacheHandler::getCache() { |
| 49 |
return mAssBackCacheWriter->getCache(); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
CBackendAssociationCacheHandler* CBackendAssociationCacheHandler::setWorkingOntology(CConcreteOntology* ontology) { |
| 55 |
mAssBackCacheReader->setWorkingOntology(ontology); |
| 56 |
return this; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
CBackendAssociationCacheHandler* CBackendAssociationCacheHandler::checkRecomputationIdUsage(cint64 recomputationId) { |
| 61 |
mAssBackCacheReader->checkRecomputationIdUsage(recomputationId); |
| 62 |
return this; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* CBackendAssociationCacheHandler::getIndividualRepresentativeIdResolvedAssociationData(cint64 indiId, CCalculationAlgorithmContext* calcAlgContext) { |
| 67 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* assocData = getIndividualAssociationData(indiId, calcAlgContext); |
| 68 |
if (assocData->hasRepresentativeSameIndividualMerging()) { |
| 69 |
assocData = getIndividualAssociationData(assocData->getRepresentativeSameIndividualId(), calcAlgContext); |
| 70 |
} |
| 71 |
return assocData; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* CBackendAssociationCacheHandler::getIndividualAssociationData(cint64 indiId, CCalculationAlgorithmContext* calcAlgContext) { |
| 76 |
return getIndividualAssociationData(indiId, true, calcAlgContext); |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* CBackendAssociationCacheHandler::getIndividualAssociationData(cint64 indiId, bool recordAccess, CCalculationAlgorithmContext* calcAlgContext) { |
| 82 |
|
| 83 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* assData = nullptr; |
| 84 |
|
| 85 |
CIndividualRepresentativeBackendCacheLoadedAssociationHash* indiLoadedAssocHash = calcAlgContext->getUsedProcessingDataBox()->getBackendCacheLoadedAssociationHash(false); |
| 86 |
if (indiLoadedAssocHash) { |
| 87 |
CIndividualRepresentativeBackendCacheLoadedAssociationData loadedAssoData = indiLoadedAssocHash->value(indiId); |
| 88 |
assData = loadedAssoData.getLoadedIndividualAssociationData(); |
| 89 |
} |
| 90 |
|
| 91 |
if (!assData) { |
| 92 |
assData = mAssBackCacheReader->getIndividualAssociationData(indiId); |
| 93 |
if (recordAccess) { |
| 94 |
CIndividualRepresentativeBackendCacheLoadedAssociationHash* locIndiLoadedAssocHash = calcAlgContext->getUsedProcessingDataBox()->getBackendCacheLoadedAssociationHash(true); |
| 95 |
CIndividualRepresentativeBackendCacheLoadedAssociationData& loadedAssoData = (*locIndiLoadedAssocHash)[indiId]; |
| 96 |
loadedAssoData.setLoadedIndividualAssociationData(assData); |
| 97 |
} |
| 98 |
} |
| 99 |
return assData; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
CIndividualRepresentativeBackendCacheLoadedAssociationData* CBackendAssociationCacheHandler::getIndividualAssociationLoadingData(cint64 indiId, CCalculationAlgorithmContext* calcAlgContext) { |
| 104 |
CIndividualRepresentativeBackendCacheLoadedAssociationHash* locIndiLoadedAssocHash = calcAlgContext->getUsedProcessingDataBox()->getBackendCacheLoadedAssociationHash(true); |
| 105 |
CIndividualRepresentativeBackendCacheLoadedAssociationData& loadedAssoData = (*locIndiLoadedAssocHash)[indiId]; |
| 106 |
|
| 107 |
if (!loadedAssoData.getLoadedIndividualAssociationData()) { |
| 108 |
loadedAssoData.setLoadedIndividualAssociationData(mAssBackCacheReader->getIndividualAssociationData(indiId)); |
| 109 |
} |
| 110 |
|
| 111 |
if (loadedAssoData.getLoadedIndividualAssociationData()) { |
| 112 |
return &loadedAssoData; |
| 113 |
} else { |
| 114 |
return nullptr; |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData* CBackendAssociationCacheHandler::getLoadedNominalIndividualIndirectConnectionData(cint64 indiId, CIndividualRepresentativeBackendCacheLoadedAssociationData* indiLoadedAssoData, CCalculationAlgorithmContext* calcAlgContext) { |
| 120 |
if (!indiLoadedAssoData) { |
| 121 |
indiLoadedAssoData = getIndividualAssociationLoadingData(indiId, calcAlgContext); |
| 122 |
} |
| 123 |
if (!indiLoadedAssoData->getLoadedNominalIndirectConnectionData()) { |
| 124 |
indiLoadedAssoData->setLoadedNominalIndirectConnectionData(mAssBackCacheReader->getNominalIndirectConnectionData(indiId)); |
| 125 |
indiLoadedAssoData->setIndirectlyConnectedIndividualsIntegration(true); |
| 126 |
} |
| 127 |
return indiLoadedAssoData->getLoadedNominalIndirectConnectionData(); |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
CIndividualRepresentativeBackendCacheLoadedAssociationData* CBackendAssociationCacheHandler::getIndividualAssociationLoadingData(CIndividual* individual, CCalculationAlgorithmContext* calcAlgContext) { |
| 132 |
return getIndividualAssociationLoadingData(individual->getIndividualID(), calcAlgContext); |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* CBackendAssociationCacheHandler::getIndividualAssociationData(CIndividual* individual, CCalculationAlgorithmContext* calcAlgContext) { |
| 137 |
return getIndividualAssociationData(individual->getIndividualID(), calcAlgContext); |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
bool CBackendAssociationCacheHandler::prepareCacheMessages(CCalculationAlgorithmContext* calcAlgContext) { |
| 143 |
if (!mMemAllocMan) { |
| 144 |
CTaskMemoryPoolAllocationManager satCacheMemManCreaterMemMan(&mMemPoolCon,calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 145 |
mMemAllocMan = CObjectAllocator<CTaskMemoryPoolAllocationManager>::allocateAndConstruct(&satCacheMemManCreaterMemMan); |
| 146 |
mMemAllocMan->initTaskMemoryPoolAllocationManager(&mMemPoolCon,calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 147 |
mTmpContext = CObjectParameterizingAllocator< CContextBase,CMemoryAllocationManager* >::allocateAndConstructAndParameterize(mMemAllocMan,mMemAllocMan); |
| 148 |
return true; |
| 149 |
} |
| 150 |
return false; |
| 151 |
} |
| 152 |
|
| 153 |
bool CBackendAssociationCacheHandler::commitCacheMessages(CCalculationAlgorithmContext* calcAlgContext) { |
| 154 |
if (mWriteData) { |
| 155 |
CBackendRepresentativeMemoryCacheLabelAssociationWriteData* commitWriteData = nullptr; |
| 156 |
CBackendRepresentativeMemoryCacheLabelAssociationWriteData* writeDataIt = mWriteData; |
| 157 |
while (writeDataIt) { |
| 158 |
CBackendRepresentativeMemoryCacheLabelAssociationWriteData* tmpWriteData = writeDataIt; |
| 159 |
writeDataIt = (CBackendRepresentativeMemoryCacheLabelAssociationWriteData*)writeDataIt->getNext(); |
| 160 |
tmpWriteData->clearNext(); |
| 161 |
if (commitWriteData) { |
| 162 |
commitWriteData = (CBackendRepresentativeMemoryCacheLabelAssociationWriteData*)tmpWriteData->append(commitWriteData); |
| 163 |
} else { |
| 164 |
commitWriteData = tmpWriteData; |
| 165 |
} |
| 166 |
} |
| 167 |
mAssBackCacheWriter->writeCachedData(commitWriteData,mMemPoolCon.takeMemoryPools()); |
| 168 |
mWriteData = nullptr; |
| 169 |
mMemAllocMan = nullptr; |
| 170 |
mTmpContext = nullptr; |
| 171 |
return true; |
| 172 |
} |
| 173 |
return false; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
bool CBackendAssociationCacheHandler::addCacheMessages(CBackendRepresentativeMemoryCacheLabelAssociationWriteData* backAssWriteData, CCalculationAlgorithmContext* calcAlgContext) { |
| 179 |
if (mWriteData) { |
| 180 |
mWriteData = (CBackendRepresentativeMemoryCacheLabelAssociationWriteData*)backAssWriteData->append(mWriteData); |
| 181 |
} else { |
| 182 |
mWriteData = backAssWriteData; |
| 183 |
} |
| 184 |
return true; |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
bool CBackendAssociationCacheHandler::determineCardinalityAssociationBackendItem(function<void(CPROCESSHASH<cint64, CBackendAssociationCacheHandler::CRoleCardinalityCountData>* superRoleTagUsedCardCountHash)> initFunc, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, bool superRolePropagation, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 193 |
|
| 194 |
CPROCESSHASH<cint64, CRoleCardinalityCountData>* superRoleTagUsedCardCountHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64, CRoleCardinalityCountData>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 195 |
|
| 196 |
initFunc(superRoleTagUsedCardCountHash); |
| 197 |
|
| 198 |
for (CPROCESSHASH<CRole*, cint64>::const_iterator it = roleUsedCardHash->constBegin(), itEnd = roleUsedCardHash->constEnd(); it != itEnd; ++it) { |
| 199 |
CRole* role = it.key(); |
| 200 |
cint64 count = it.value(); |
| 201 |
if (superRolePropagation) { |
| 202 |
for (CSortedNegLinker<CRole*>* superRoleIt = role->getIndirectSuperRoleList(); superRoleIt; superRoleIt = superRoleIt->getNext()) { |
| 203 |
if (!superRoleIt->isNegated()) { |
| 204 |
CRole* superRole = superRoleIt->getData(); |
| 205 |
CRoleCardinalityCountData& roleCardCountData = (*superRoleTagUsedCardCountHash)[superRole->getRoleTag()]; |
| 206 |
if (roleCardCountData.mHasRestrictingCardinality) { |
| 207 |
roleCardCountData.mExistentialUsedCardinality += count; |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
} else { |
| 212 |
CRoleCardinalityCountData& roleCardCountData = (*superRoleTagUsedCardCountHash)[role->getRoleTag()]; |
| 213 |
if (roleCardCountData.mHasRestrictingCardinality) { |
| 214 |
roleCardCountData.mExistentialUsedCardinality += count; |
| 215 |
} |
| 216 |
} |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
CBackendRepresentativeMemoryLabelCacheItem* conSetLabelItem = tmpAssWriteDataLinker->getReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL); |
| 221 |
if (conSetLabelItem) { |
| 222 |
CBackendRepresentativeMemoryLabelCacheItemCardinalityExtensionData* cardExtData = (CBackendRepresentativeMemoryLabelCacheItemCardinalityExtensionData*)conSetLabelItem->getExtensionData(CBackendRepresentativeMemoryLabelCacheItemExtensionData::CARDINALITY_HASH); |
| 223 |
KONCLUDE_ASSERT_X(cardExtData, "cardinality association updater", "cardinality extension data missing"); |
| 224 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelCacheItemCardinalityData*>* roleCardinalityDataHash = cardExtData->getRoleCardinalityDataHash(); |
| 225 |
for (CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelCacheItemCardinalityData*>::const_iterator it = roleCardinalityDataHash->constBegin(), itEnd = roleCardinalityDataHash->constEnd(); it != itEnd; ++it) { |
| 226 |
cint64 roleTag = it.key(); |
| 227 |
CBackendRepresentativeMemoryLabelCacheItemCardinalityData* cardData = it.value(); |
| 228 |
CRoleCardinalityCountData& roleCardCountData = (*superRoleTagUsedCardCountHash)[roleTag]; |
| 229 |
cardData->updateExistentialMaxUsedCardinality(roleCardCountData.mExistentialUsedCardinality); |
| 230 |
cardData->updateMinimumRestrictingCardinality(roleCardCountData.mRestrictingCardinality); |
| 231 |
} |
| 232 |
} else { |
| 233 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* conSetTmpLabelItem = tmpAssWriteDataLinker->getReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL); |
| 234 |
CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* extCardWriteData = nullptr; |
| 235 |
if (mTmpConceptLabelTmpCardDataHash) { |
| 236 |
extCardWriteData = mTmpConceptLabelTmpCardDataHash->value(conSetTmpLabelItem); |
| 237 |
} |
| 238 |
if (extCardWriteData) { |
| 239 |
for (CBackendRepresentativeMemoryCardinalityValueLinker* cardValueLinkerIt = extCardWriteData->getCardinalityCacheValueLinker(); cardValueLinkerIt; cardValueLinkerIt = cardValueLinkerIt->getNext()) { |
| 240 |
CRoleCardinalityCountData& roleCardCountData = (*superRoleTagUsedCardCountHash)[cardValueLinkerIt->getRoleTag()]; |
| 241 |
cardValueLinkerIt->updateExistentialMaxUsedCardinality(roleCardCountData.mExistentialUsedCardinality); |
| 242 |
cardValueLinkerIt->updateMinimalRestrictingCardinality(roleCardCountData.mRestrictingCardinality); |
| 243 |
} |
| 244 |
} else { |
| 245 |
|
| 246 |
CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* newTempRefCard = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 247 |
newTempRefCard->initLabelWriteData(conSetTmpLabelItem); |
| 248 |
for (CPROCESSHASH<cint64, CRoleCardinalityCountData>::const_iterator it = superRoleTagUsedCardCountHash->constBegin(), itEnd = superRoleTagUsedCardCountHash->constEnd(); it != itEnd; ++it) { |
| 249 |
cint64 roleTag(it.key()); |
| 250 |
CRoleCardinalityCountData cadCountData = it.value(); |
| 251 |
if (cadCountData.mHasRestrictingCardinality) { |
| 252 |
CBackendRepresentativeMemoryCardinalityValueLinker* cardValueLinker = CObjectAllocator< CBackendRepresentativeMemoryCardinalityValueLinker >::allocateAndConstruct(mMemAllocMan); |
| 253 |
cardValueLinker->initCardinalityValueLinker(roleTag, cadCountData.mExistentialUsedCardinality, cadCountData.mRestrictingCardinality); |
| 254 |
newTempRefCard->appendCardinalityCacheValueLinker(cardValueLinker); |
| 255 |
} |
| 256 |
} |
| 257 |
mNewTmpCardList->append(newTempRefCard); |
| 258 |
mTmpConceptLabelTmpCardDataHash->insert(conSetTmpLabelItem, newTempRefCard); |
| 259 |
++mStatCreatedTempLabels; |
| 260 |
|
| 261 |
} |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
return true; |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference CBackendAssociationCacheHandler::getRoleInstantiatedSetLabelAssociationBackendItem(cint64 labelType, CSortedNegLinker<CRole*>* roleLinker, CPROCESSSET<TRoleInversionPair>* roleInversionSet, bool extendBySuperRoles, CPROCESSHASH< CProcessSetHasher<TRoleInversionPair>, CBackendRepresentativeMemoryCacheTemporaryLabelReference* >* roleInstantiatedSetLabelHash, CCalculationAlgorithmContext* calcAlgContext) { |
| 272 |
|
| 273 |
CRole* topRole = calcAlgContext->getProcessingDataBox()->getOntology()->getRBox()->getTopObjectRole(); |
| 274 |
if (roleLinker && !roleInversionSet) { |
| 275 |
roleInversionSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 276 |
for (CSortedNegLinker<CRole*>* roleLinkerIt = roleLinker; roleLinkerIt; roleLinkerIt = roleLinkerIt->getNext()) { |
| 277 |
CRole* role = roleLinkerIt->getData(); |
| 278 |
bool inversed = roleLinkerIt->isNegated(); |
| 279 |
roleInversionSet->insert(TRoleInversionPair(role, inversed)); |
| 280 |
} |
| 281 |
} |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference*& tmpLabelRefData = (*roleInstantiatedSetLabelHash)[CProcessSetHasher<TRoleInversionPair>(roleInversionSet)]; |
| 286 |
if (tmpLabelRefData) { |
| 287 |
return *tmpLabelRefData; |
| 288 |
} else { |
| 289 |
tmpLabelRefData = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelReference >::allocateAndConstruct(mMemAllocMan); |
| 290 |
} |
| 291 |
|
| 292 |
|
| 293 |
if (!roleLinker && roleInversionSet) { |
| 294 |
for (CPROCESSSET<TRoleInversionPair>::const_iterator it = roleInversionSet->constBegin(), itEnd = roleInversionSet->constEnd(); it != itEnd; ++it) { |
| 295 |
TRoleInversionPair roleInvPair(*it); |
| 296 |
CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager()); |
| 297 |
newRoleLinker->init(roleInvPair.first, roleInvPair.second); |
| 298 |
roleLinker = (CSortedNegLinker<CRole*>*)newRoleLinker->append(roleLinker); |
| 299 |
} |
| 300 |
} |
| 301 |
|
| 302 |
CSortedNegLinker<CRole*>* superRoleLinker = nullptr; |
| 303 |
CPROCESSSET<TRoleInversionPair>* superRoleInversionSet = nullptr; |
| 304 |
if (extendBySuperRoles) { |
| 305 |
superRoleInversionSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 306 |
for (CSortedNegLinker<CRole*>* roleLinkerIt = roleLinker; roleLinkerIt; roleLinkerIt = roleLinkerIt->getNext()) { |
| 307 |
CRole* role = roleLinkerIt->getData(); |
| 308 |
bool inversed = roleLinkerIt->isNegated(); |
| 309 |
if (!superRoleInversionSet->contains(TRoleInversionPair(role, inversed))) { |
| 310 |
for (CSortedNegLinker<CRole*>* superRoleLinkerIt = role->getIndirectSuperRoleList(); superRoleLinkerIt; superRoleLinkerIt = superRoleLinkerIt->getNext()) { |
| 311 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 312 |
bool superRoleNegation = superRoleLinkerIt->isNegated() ^ inversed; |
| 313 |
if (superRole != topRole && !superRoleInversionSet->contains(TRoleInversionPair(superRole, superRoleNegation))) { |
| 314 |
superRoleInversionSet->insert(TRoleInversionPair(superRole, superRoleNegation)); |
| 315 |
CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager()); |
| 316 |
newRoleLinker->init(superRole, superRoleNegation); |
| 317 |
superRoleLinker = (CSortedNegLinker<CRole*>*)newRoleLinker->append(superRoleLinker); |
| 318 |
} |
| 319 |
} |
| 320 |
} |
| 321 |
} |
| 322 |
} else { |
| 323 |
superRoleLinker = roleLinker; |
| 324 |
superRoleInversionSet = roleInversionSet; |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
cint64 superRoleCount = superRoleLinker->getCount(); |
| 329 |
cint64 signature = CBackendRepresentativeMemoryCacheUtilities::getRoleInversedLinkerSignature(superRoleLinker, false, superRoleCount); |
| 330 |
|
| 331 |
CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getLabelCacheEntryViaRoleLinker(labelType, signature, superRoleCount, superRoleLinker, false); |
| 332 |
if (cachedLabelItem) { |
| 333 |
++mStatReusedCachedLabels; |
| 334 |
tmpLabelRefData->setReferredLabelData(cachedLabelItem); |
| 335 |
} else { |
| 336 |
// create new temporary label item |
| 337 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 338 |
newTempRefLabel->initLabelWriteData(signature, labelType); |
| 339 |
|
| 340 |
for (CSortedNegLinker<CRole*>* superRoleLinkerIt = superRoleLinker; superRoleLinkerIt; superRoleLinkerIt = superRoleLinkerIt->getNext()) { |
| 341 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 342 |
bool roleInversed = superRoleLinkerIt->isNegated(); |
| 343 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan); |
| 344 |
labelValueLinker->initLabelValueLinker(mAssBackCacheReader->getCacheValue(superRole, roleInversed)); |
| 345 |
newTempRefLabel->appendCacheValueLinker(labelValueLinker); |
| 346 |
} |
| 347 |
mNewTmpLabelList->append(newTempRefLabel); |
| 348 |
++mStatCreatedTempLabels; |
| 349 |
tmpLabelRefData->setReferredTemporaryLabelData(newTempRefLabel); |
| 350 |
} |
| 351 |
|
| 352 |
return *tmpLabelRefData; |
| 353 |
|
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
bool CBackendAssociationCacheHandler::visitRolesOfAssociatedCompinationRoleSetLabel(CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef, function<bool(CRole* role, bool inversed)> visitFunc, CCalculationAlgorithmContext* calcAlgContext) { |
| 362 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = labelRef.getReferredLabelData(); |
| 363 |
if (labelItem) { |
| 364 |
return visitRolesOfAssociatedCompinationRoleSetLabel(nullptr, labelItem, visitFunc, calcAlgContext); |
| 365 |
} |
| 366 |
bool visited = false; |
| 367 |
bool continueVisiting = true; |
| 368 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* labelWriteDataLinker = labelRef.getReferredTemporaryLabelData(); |
| 369 |
for (CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* labelWriteDataLinkerIt = labelWriteDataLinker; labelWriteDataLinkerIt && continueVisiting; labelWriteDataLinkerIt = labelWriteDataLinkerIt->getNext()) { |
| 370 |
for (CBackendRepresentativeMemoryLabelValueLinker* labelValueLinkerIt = labelWriteDataLinkerIt->getCacheValueLinker(); labelValueLinkerIt && continueVisiting; labelValueLinkerIt = labelValueLinkerIt->getNext()) { |
| 371 |
const CCacheValue& cacheValue = labelValueLinkerIt->getCacheValue(); |
| 372 |
|
| 373 |
CRole* role = (CRole*)cacheValue.getIdentification(); |
| 374 |
bool roleInversed = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDINVERSEDROLE; |
| 375 |
continueVisiting = visitFunc(role, roleInversed); |
| 376 |
visited = true; |
| 377 |
} |
| 378 |
} |
| 379 |
return visited; |
| 380 |
} |
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
bool CBackendAssociationCacheHandler::visitNeighbourArrayIdsForRole(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CRole* role, function<bool(cint64 neighbourArrayId, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, bool nondeterministic)> visitFunc, bool visitOnlyDeterministicNeighbours, CCalculationAlgorithmContext* calcAlgContext) { |
| 395 |
return mAssBackCacheReader->visitNeighbourArrayIdsForRole(assData, role, visitFunc, visitOnlyDeterministicNeighbours); |
| 396 |
} |
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
bool CBackendAssociationCacheHandler::visitNeighbourIndividualIdsForRole(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CRole* role, function<bool(cint64 neighbourIndividualId, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, bool nondeterministic)> visitFunc, bool visitOnlyDeterministicNeighbours, CCalculationAlgorithmContext* calcAlgContext) { |
| 401 |
return mAssBackCacheReader->visitNeighbourIndividualIdsForRole(assData, role, visitFunc, visitOnlyDeterministicNeighbours); |
| 402 |
} |
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
bool CBackendAssociationCacheHandler::visitNeighbourIndividualIdsForNeighbourArrayIdFromCursor(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 id, function<bool(cint64 neighbourIndividualId, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, bool nondeterministic, cint64 cursor)> visitFunc, bool visitOnlyDeterministicNeighbours, cint64 cursor, CCalculationAlgorithmContext* calcAlgContext) { |
| 407 |
return mAssBackCacheReader->visitNeighbourIndividualIdsForNeighbourArrayIdFromCursor(assData, id, visitFunc, visitOnlyDeterministicNeighbours, cursor); |
| 408 |
} |
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
cint64 CBackendAssociationCacheHandler::getNeighbourCountForRole(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CRole* role, CCalculationAlgorithmContext* calcAlgContext) { |
| 413 |
return mAssBackCacheReader->getNeighbourCountForRole(assData, role); |
| 414 |
} |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
cint64 CBackendAssociationCacheHandler::getNeighbourCountForArrayPos(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 pos, CCalculationAlgorithmContext* calcAlgContext) { |
| 421 |
return mAssBackCacheReader->getNeighbourCountForArrayPos(assData, pos); |
| 422 |
} |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
bool CBackendAssociationCacheHandler::determineIndirectlyConnectedNominalIndividualSetLabelAssociationBackendItem(CPROCESSSET<cint64>* existentialIndirectlyConnectedNominalIndividualSet, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 439 |
|
| 440 |
|
| 441 |
cint64 indiCount = existentialIndirectlyConnectedNominalIndividualSet->size(); |
| 442 |
cint64 indiSetSigValue = CBackendRepresentativeMemoryCacheUtilities::getIndividualSetSignature(existentialIndirectlyConnectedNominalIndividualSet, indiCount); |
| 443 |
|
| 444 |
if (indiCount > 0) { |
| 445 |
|
| 446 |
CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getIndividualSetLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::INDIRECTLY_CONNECTED_NOMINAL_INDIVIDUAL_SET_LABEL, indiSetSigValue, existentialIndirectlyConnectedNominalIndividualSet, indiCount); |
| 447 |
if (cachedLabelItem) { |
| 448 |
++mStatReusedCachedLabels; |
| 449 |
tmpAssWriteDataLinker->setReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::INDIRECTLY_CONNECTED_NOMINAL_INDIVIDUAL_SET_LABEL, cachedLabelItem); |
| 450 |
return true; |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*& prevTempRefLabels = (*mSignatureTmpIndiConnIndiSetRefLabelHash)[indiSetSigValue]; |
| 455 |
if (prevTempRefLabels) { |
| 456 |
for (CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* prevTempRefLabelIt = prevTempRefLabels; prevTempRefLabelIt; prevTempRefLabelIt = prevTempRefLabelIt->getNext()) { |
| 457 |
if (prevTempRefLabelIt->getCacheValueCount() == indiCount) { |
| 458 |
bool compatibleIndividuals = true; |
| 459 |
for (CBackendRepresentativeMemoryLabelValueLinker* labelValueLinkerIt = prevTempRefLabelIt->getCacheValueLinker(); labelValueLinkerIt && compatibleIndividuals; labelValueLinkerIt = labelValueLinkerIt->getNext()) { |
| 460 |
CCacheValue cacheValue = labelValueLinkerIt->getCacheValue(); |
| 461 |
cint64 indiId = cacheValue.getIdentification(); |
| 462 |
|
| 463 |
if (!existentialIndirectlyConnectedNominalIndividualSet->contains(indiId)) { |
| 464 |
compatibleIndividuals = false; |
| 465 |
} |
| 466 |
} |
| 467 |
if (compatibleIndividuals) { |
| 468 |
++mStatReusedHashedSignatureLabels; |
| 469 |
++mStatReusedTempLabels; |
| 470 |
tmpAssWriteDataLinker->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::INDIRECTLY_CONNECTED_NOMINAL_INDIVIDUAL_SET_LABEL, prevTempRefLabelIt); |
| 471 |
return true; |
| 472 |
} |
| 473 |
} |
| 474 |
} |
| 475 |
} |
| 476 |
|
| 477 |
|
| 478 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 479 |
newTempRefLabel->initLabelWriteData(indiSetSigValue, CBackendRepresentativeMemoryLabelCacheItem::INDIRECTLY_CONNECTED_NOMINAL_INDIVIDUAL_SET_LABEL); |
| 480 |
newTempRefLabel->setCompletelySaturated(false); |
| 481 |
newTempRefLabel->setCompletelyHandled(true); |
| 482 |
for (CPROCESSSET<cint64>::const_iterator it = existentialIndirectlyConnectedNominalIndividualSet->constBegin(), itEnd = existentialIndirectlyConnectedNominalIndividualSet->constEnd(); it != itEnd; ++it) { |
| 483 |
cint64 indiId = *it; |
| 484 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan); |
| 485 |
labelValueLinker->initLabelValueLinker(mAssBackCacheReader->getCacheValue(indiId, false)); |
| 486 |
newTempRefLabel->appendCacheValueLinker(labelValueLinker); |
| 487 |
} |
| 488 |
mNewTmpLabelList->append(newTempRefLabel); |
| 489 |
++mStatCreatedTempLabels; |
| 490 |
|
| 491 |
tmpAssWriteDataLinker->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::INDIRECTLY_CONNECTED_NOMINAL_INDIVIDUAL_SET_LABEL, newTempRefLabel); |
| 492 |
prevTempRefLabels = newTempRefLabel->append(prevTempRefLabels); |
| 493 |
return true; |
| 494 |
} else { |
| 495 |
return false; |
| 496 |
} |
| 497 |
} |
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference CBackendAssociationCacheHandler::getNeighbourRoleInstantiatedSetLabelAssociationBackendItem(CRole* role, bool inversed, CCalculationAlgorithmContext* calcAlgContext) { |
| 509 |
|
| 510 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference*& tmpLabelRefData = (*mRoleInversionTmpRefNeighbourInstantiatedRoleSetLabelHash)[TRoleInversionPair(role, inversed)]; |
| 511 |
|
| 512 |
if (tmpLabelRefData) { |
| 513 |
return *tmpLabelRefData; |
| 514 |
} else { |
| 515 |
tmpLabelRefData = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelReference >::allocateAndConstruct(mMemAllocMan); |
| 516 |
} |
| 517 |
|
| 518 |
CSortedNegLinker<CRole*>* superRoleLinker = role->getIndirectSuperRoleList(); |
| 519 |
cint64 superRoleCount = superRoleLinker->getCount(); |
| 520 |
cint64 signature = CBackendRepresentativeMemoryCacheUtilities::getRoleInversedLinkerSignature(superRoleLinker, inversed, superRoleCount); |
| 521 |
|
| 522 |
CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getLabelCacheEntryViaRoleLinker(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, signature, superRoleCount, superRoleLinker, inversed, role); |
| 523 |
if (cachedLabelItem) { |
| 524 |
++mStatReusedCachedLabels; |
| 525 |
tmpLabelRefData->setReferredLabelData(cachedLabelItem); |
| 526 |
} else { |
| 527 |
// create new temporary label item |
| 528 |
CLinkedNeighbourRoleAssertionLinker linkedRoleAssertedLinker; |
| 529 |
linkedRoleAssertedLinker.initLinkedNeighbourRoleAssertionLinker(role, inversed); |
| 530 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference newTempLabelRef = getNeighbourRoleInstantiatedSetLabelAssociationBackendItem(&linkedRoleAssertedLinker, nullptr, nullptr, calcAlgContext); |
| 531 |
*tmpLabelRefData = newTempLabelRef; |
| 532 |
} |
| 533 |
|
| 534 |
return *tmpLabelRefData; |
| 535 |
|
| 536 |
} |
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
bool CBackendAssociationCacheHandler::determineNeighbourRoleInstantiatedSetCompinationLabelAssociationBackendItem(CPROCESSSET<CBackendRepresentativeMemoryCacheTemporaryLabelReference>* neigbourRoleInstantiatedSetCompination, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 545 |
|
| 546 |
bool hasTemporaryLabelReferences = false; |
| 547 |
|
| 548 |
cint64 neighbourRoleInstantiatedSetCount = 0; |
| 549 |
CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker* neigbourRoleInstantiatedSetTmpLabelLinker = nullptr; |
| 550 |
for (CPROCESSSET<CBackendRepresentativeMemoryCacheTemporaryLabelReference>::const_iterator it = neigbourRoleInstantiatedSetCompination->constBegin(), itEnd = neigbourRoleInstantiatedSetCompination->constEnd(); it != itEnd; ++it) { |
| 551 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef(*it); |
| 552 |
if (labelRef.getReferredTemporaryLabelData()) { |
| 553 |
hasTemporaryLabelReferences = true; |
| 554 |
} |
| 555 |
CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker* newNeigbourRoleInstantiatedSetTmpLabelLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 556 |
newNeigbourRoleInstantiatedSetTmpLabelLinker->initLabelReferenceDataLinker(labelRef); |
| 557 |
neigbourRoleInstantiatedSetTmpLabelLinker = newNeigbourRoleInstantiatedSetTmpLabelLinker->append(neigbourRoleInstantiatedSetTmpLabelLinker); |
| 558 |
++neighbourRoleInstantiatedSetCount; |
| 559 |
} |
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
cint64 signature = CBackendRepresentativeMemoryCacheUtilities::getNeighbourRoleInstantiatedSetLinkerSignature(neigbourRoleInstantiatedSetTmpLabelLinker, neighbourRoleInstantiatedSetCount); |
| 564 |
|
| 565 |
|
| 566 |
CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getNeighbourRoleInstantiatedSetCompinationLabelCacheEntry(signature, neighbourRoleInstantiatedSetCount, neigbourRoleInstantiatedSetTmpLabelLinker); |
| 567 |
if (cachedLabelItem) { |
| 568 |
++mStatReusedCachedLabels; |
| 569 |
tmpAssWriteDataLinker->setReferredLabelData(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL, cachedLabelItem); |
| 570 |
return true; |
| 571 |
} |
| 572 |
|
| 573 |
|
| 574 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*& prevTempRefLabels = (*mSignatureTmpRefNeigbourRoleInstantiatedSetCombinationLabelHash)[signature]; |
| 575 |
if (prevTempRefLabels) { |
| 576 |
for (CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* prevTempRefLabelIt = prevTempRefLabels; prevTempRefLabelIt; prevTempRefLabelIt = prevTempRefLabelIt->getNext()) { |
| 577 |
if (prevTempRefLabelIt->getCacheValueCount() == neighbourRoleInstantiatedSetCount) { |
| 578 |
|
| 579 |
bool compatibleLabels = true; |
| 580 |
for (CBackendRepresentativeMemoryLabelValueLinker* labelValueLinkerIt = prevTempRefLabelIt->getCacheValueLinker(); labelValueLinkerIt && compatibleLabels; labelValueLinkerIt = labelValueLinkerIt->getNext()) { |
| 581 |
CCacheValue& cacheValue = labelValueLinkerIt->getCacheValue(); |
| 582 |
|
| 583 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef; |
| 584 |
if (cacheValue.getCacheValueIdentifier() == CCacheValue::CACHE_VALUE_TAG_AND_ENTRY) { |
| 585 |
CBackendRepresentativeMemoryLabelCacheItem* labelCacheItem = (CBackendRepresentativeMemoryLabelCacheItem*)cacheValue.getIdentification(); |
| 586 |
labelRef.setReferredLabelData(labelCacheItem); |
| 587 |
} |
| 588 |
else { |
| 589 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* tmpLabelWriteData = (CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*)cacheValue.getIdentification(); |
| 590 |
labelRef.setReferredTemporaryLabelData(tmpLabelWriteData); |
| 591 |
} |
| 592 |
|
| 593 |
if (!neigbourRoleInstantiatedSetCompination->contains(labelRef)) { |
| 594 |
compatibleLabels = false; |
| 595 |
} |
| 596 |
} |
| 597 |
|
| 598 |
if (compatibleLabels) { |
| 599 |
++mStatReusedHashedSignatureLabels; |
| 600 |
++mStatReusedTempLabels; |
| 601 |
tmpAssWriteDataLinker->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL, prevTempRefLabelIt); |
| 602 |
return true; |
| 603 |
} |
| 604 |
} |
| 605 |
} |
| 606 |
} |
| 607 |
|
| 608 |
|
| 609 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 610 |
newTempRefLabel->initLabelWriteData(signature, CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 611 |
|
| 612 |
|
| 613 |
bool hasNondeterministicElementsLabel = false; |
| 614 |
for (CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker* neigbourRoleInstantiatedSetTmpLabelLinkerIt = neigbourRoleInstantiatedSetTmpLabelLinker; neigbourRoleInstantiatedSetTmpLabelLinkerIt; neigbourRoleInstantiatedSetTmpLabelLinkerIt = neigbourRoleInstantiatedSetTmpLabelLinkerIt->getNext()) { |
| 615 |
CCacheValue cacheValue = mAssBackCacheReader->getCacheValue(neigbourRoleInstantiatedSetTmpLabelLinkerIt); |
| 616 |
if (neigbourRoleInstantiatedSetTmpLabelLinkerIt->getReferredLabelData() && neigbourRoleInstantiatedSetTmpLabelLinkerIt->getReferredLabelData()->hasStatusFlagsPartially(CBackendRepresentativeMemoryCachingFlags::FLAG_NONDETERMINISTIC_ELEMENTS)) { |
| 617 |
hasNondeterministicElementsLabel = true; |
| 618 |
} |
| 619 |
if (neigbourRoleInstantiatedSetTmpLabelLinkerIt->getReferredTemporaryLabelData() && neigbourRoleInstantiatedSetTmpLabelLinkerIt->getReferredTemporaryLabelData()->hasStatusFlagsPartially(CBackendRepresentativeMemoryCachingFlags::FLAG_NONDETERMINISTIC_ELEMENTS)) { |
| 620 |
hasNondeterministicElementsLabel = true; |
| 621 |
} |
| 622 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan); |
| 623 |
labelValueLinker->initLabelValueLinker(cacheValue); |
| 624 |
newTempRefLabel->appendCacheValueLinker(labelValueLinker); |
| 625 |
} |
| 626 |
if (hasNondeterministicElementsLabel) { |
| 627 |
newTempRefLabel->addStatusFlags(CBackendRepresentativeMemoryCachingFlags::FLAG_NONDETERMINISTIC_ELEMENTS); |
| 628 |
} |
| 629 |
|
| 630 |
mNewTmpLabelList->append(newTempRefLabel); |
| 631 |
++mStatCreatedTempLabels; |
| 632 |
|
| 633 |
tmpAssWriteDataLinker->setReferredTemporaryLabelData(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL, newTempRefLabel); |
| 634 |
prevTempRefLabels = newTempRefLabel->append(prevTempRefLabels); |
| 635 |
return true; |
| 636 |
} |
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference CBackendAssociationCacheHandler::getNeighbourRoleInstantiatedSetLabelAssociationBackendItem(CLinkedNeighbourRoleAssertionLinker* linkedRoleAssertedLinker, CBackendRepresentativeMemoryCacheRoleAssertionLinker* linkedRoleAssertionConnectionLinker, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnectionData, CCalculationAlgorithmContext* calcAlgContext) { |
| 644 |
|
| 645 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference** tmpCachingLabelRefData = nullptr; |
| 646 |
if (linkedRoleAssertedLinker && !linkedRoleAssertionConnectionLinker && !nominalConnectionData) { |
| 647 |
CPROCESSSET<TRoleInversionPair>* roleInversionSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 648 |
for (CLinkedNeighbourRoleAssertionLinker* linkedRoleAssertedLinkerIt = linkedRoleAssertedLinker; linkedRoleAssertedLinkerIt; linkedRoleAssertedLinkerIt = linkedRoleAssertedLinkerIt->getNext()) { |
| 649 |
CRole* role = linkedRoleAssertedLinkerIt->getAssertedRole(); |
| 650 |
bool inversed = linkedRoleAssertedLinkerIt->isAssertedRoleInversed(); |
| 651 |
roleInversionSet->insert(TRoleInversionPair(role, inversed)); |
| 652 |
} |
| 653 |
|
| 654 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference*& tmpLabelRefData = (*(mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL]))[CProcessSetHasher<TRoleInversionPair>(roleInversionSet)]; |
| 655 |
if (tmpLabelRefData) { |
| 656 |
return *tmpLabelRefData; |
| 657 |
} else { |
| 658 |
tmpLabelRefData = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelReference >::allocateAndConstruct(mMemAllocMan); |
| 659 |
} |
| 660 |
tmpCachingLabelRefData = &tmpLabelRefData; |
| 661 |
} |
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker* superRoleAssertionLinker = nullptr; |
| 666 |
CPROCESSHASH<TRoleInversionPair, CBackendRepresentativeMemoryCacheRoleAssertionLinker*>* superRoleInversionLinkerHash = CObjectParameterizingAllocator< CPROCESSHASH<TRoleInversionPair, CBackendRepresentativeMemoryCacheRoleAssertionLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
CRole* topRole = calcAlgContext->getProcessingDataBox()->getOntology()->getRBox()->getTopObjectRole(); |
| 672 |
for (CLinkedNeighbourRoleAssertionLinker* linkedRoleAssertedLinkerIt = linkedRoleAssertedLinker; linkedRoleAssertedLinkerIt; linkedRoleAssertedLinkerIt = linkedRoleAssertedLinkerIt->getNext()) { |
| 673 |
CRole* role = linkedRoleAssertedLinkerIt->getAssertedRole(); |
| 674 |
bool inversed = linkedRoleAssertedLinkerIt->isAssertedRoleInversed(); |
| 675 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker*& assertionLinker = (*superRoleInversionLinkerHash)[TRoleInversionPair(role, inversed)]; |
| 676 |
if (!assertionLinker) { |
| 677 |
for (CSortedNegLinker<CRole*>* superRoleLinkerIt = role->getIndirectSuperRoleList(); superRoleLinkerIt; superRoleLinkerIt = superRoleLinkerIt->getNext()) { |
| 678 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 679 |
bool superRoleNegation = superRoleLinkerIt->isNegated() ^ inversed; |
| 680 |
if (superRole != topRole && superRoleInversionLinkerHash->value(TRoleInversionPair(superRole, superRoleNegation)) == nullptr) { |
| 681 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker* newRoleLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheRoleAssertionLinker >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager()); |
| 682 |
newRoleLinker->initRoleAssertionLinker(superRole, superRoleNegation, superRole == role && superRoleNegation == inversed, false, false); |
| 683 |
superRoleInversionLinkerHash->insert(TRoleInversionPair(superRole, superRoleNegation), newRoleLinker); |
| 684 |
superRoleAssertionLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)newRoleLinker->append(superRoleAssertionLinker); |
| 685 |
} |
| 686 |
} |
| 687 |
} else { |
| 688 |
assertionLinker->setABoxAsserted(true); |
| 689 |
} |
| 690 |
} |
| 691 |
|
| 692 |
for (CBackendRepresentativeMemoryCacheRoleAssertionLinker* linkedRoleAssertionConnectionLinkerIt = linkedRoleAssertionConnectionLinker; linkedRoleAssertionConnectionLinkerIt; linkedRoleAssertionConnectionLinkerIt = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)linkedRoleAssertionConnectionLinkerIt->getNext()) { |
| 693 |
CRole* role = linkedRoleAssertionConnectionLinkerIt->getData(); |
| 694 |
bool inversed = linkedRoleAssertionConnectionLinkerIt->isNegated(); |
| 695 |
bool aboxAsserted = linkedRoleAssertionConnectionLinkerIt->isABoxAsserted(); |
| 696 |
bool nominalConnected = linkedRoleAssertionConnectionLinkerIt->isNominalConnected(); |
| 697 |
bool nondeterministic = linkedRoleAssertionConnectionLinkerIt->isNondeterministic(); |
| 698 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker*& assertionLinker = (*superRoleInversionLinkerHash)[TRoleInversionPair(role, inversed)]; |
| 699 |
if (!assertionLinker) { |
| 700 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker* newRoleLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheRoleAssertionLinker >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager()); |
| 701 |
newRoleLinker->initRoleAssertionLinker(role, inversed, aboxAsserted, nominalConnected, nondeterministic); |
| 702 |
assertionLinker = newRoleLinker; |
| 703 |
superRoleAssertionLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)newRoleLinker->append(superRoleAssertionLinker); |
| 704 |
} |
| 705 |
} |
| 706 |
|
| 707 |
|
| 708 |
for (CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnectionDataIt = nominalConnectionData; nominalConnectionDataIt; nominalConnectionDataIt = nominalConnectionDataIt->getNext()) { |
| 709 |
CIndividualReference nomConnIndi = nominalConnectionDataIt->getConnectedIndividual(); |
| 710 |
CRole* role = nominalConnectionDataIt->getConnectionRole(); |
| 711 |
bool inversed = nominalConnectionDataIt->isInversedConnection(); |
| 712 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker*& assertionLinker = (*superRoleInversionLinkerHash)[TRoleInversionPair(role, inversed)]; |
| 713 |
if (!assertionLinker) { |
| 714 |
for (CSortedNegLinker<CRole*>* superRoleLinkerIt = role->getIndirectSuperRoleList(); superRoleLinkerIt; superRoleLinkerIt = superRoleLinkerIt->getNext()) { |
| 715 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 716 |
bool superRoleNegation = superRoleLinkerIt->isNegated() ^ inversed; |
| 717 |
if (superRole != topRole && superRoleInversionLinkerHash->value(TRoleInversionPair(superRole, superRoleNegation)) == nullptr) { |
| 718 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker* newRoleLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheRoleAssertionLinker >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager()); |
| 719 |
newRoleLinker->initRoleAssertionLinker(superRole, superRoleNegation, false, true, false); |
| 720 |
superRoleInversionLinkerHash->insert(TRoleInversionPair(superRole, superRoleNegation), newRoleLinker); |
| 721 |
superRoleAssertionLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)newRoleLinker->append(superRoleAssertionLinker); |
| 722 |
} |
| 723 |
} |
| 724 |
} |
| 725 |
} |
| 726 |
|
| 727 |
|
| 728 |
cint64 superRoleCount = superRoleAssertionLinker->getCount(); |
| 729 |
cint64 signature = CBackendRepresentativeMemoryCacheUtilities::getRoleInversedLinkerSignature(superRoleAssertionLinker, false, superRoleCount); |
| 730 |
|
| 731 |
CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getLabelCacheEntryViaRoleAssertionLinker(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, signature, superRoleCount, superRoleAssertionLinker); |
| 732 |
if (cachedLabelItem) { |
| 733 |
++mStatReusedCachedLabels; |
| 734 |
if (tmpCachingLabelRefData) { |
| 735 |
(*tmpCachingLabelRefData)->setReferredLabelData(cachedLabelItem); |
| 736 |
} |
| 737 |
return CBackendRepresentativeMemoryCacheTemporaryLabelReference(cachedLabelItem); |
| 738 |
} else { |
| 739 |
// create new temporary label item |
| 740 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = getNeighbourRoleInstantiatedSetLabelFromAssertionLinker(signature, superRoleCount, superRoleAssertionLinker, calcAlgContext); |
| 741 |
if (tmpCachingLabelRefData) { |
| 742 |
(*tmpCachingLabelRefData)->setReferredTemporaryLabelData(newTempRefLabel); |
| 743 |
} |
| 744 |
return CBackendRepresentativeMemoryCacheTemporaryLabelReference(newTempRefLabel); |
| 745 |
} |
| 746 |
|
| 747 |
} |
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* CBackendAssociationCacheHandler::getNeighbourRoleInstantiatedSetLabelFromAssertionLinker(cint64 signature, cint64 superRoleCount, CBackendRepresentativeMemoryCacheRoleAssertionLinker* superRoleAssertionLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 752 |
|
| 753 |
CCacheValueTmpLabelReferenceData*& cacheValuesTmpLabelRefData = (*mSuperRoleSignatureCacheValueTmpRefNeighbourInstantiatedRoleSetLabelPairHash)[signature]; |
| 754 |
|
| 755 |
for (CCacheValueTmpLabelReferenceData* cacheValuesTmpLabelRefDataIt = cacheValuesTmpLabelRefData; cacheValuesTmpLabelRefDataIt; cacheValuesTmpLabelRefDataIt = cacheValuesTmpLabelRefDataIt->mNext) { |
| 756 |
|
| 757 |
if (superRoleCount == cacheValuesTmpLabelRefDataIt->mCacheValues->size()) { |
| 758 |
bool matching = true; |
| 759 |
for (CBackendRepresentativeMemoryCacheRoleAssertionLinker* superRoleLinkerIt = superRoleAssertionLinker; superRoleLinkerIt && matching; superRoleLinkerIt = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)superRoleLinkerIt->getNext()) { |
| 760 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 761 |
bool roleInversed = superRoleLinkerIt->isNegated(); |
| 762 |
bool asserted = superRoleLinkerIt->isABoxAsserted(); |
| 763 |
bool nomConnected = superRoleLinkerIt->isNominalConnected(); |
| 764 |
bool nondeterministic = superRoleLinkerIt->isNondeterministic(); |
| 765 |
CCacheValue cacheValue = mAssBackCacheReader->getCacheValue(superRole, roleInversed, asserted, nomConnected, nondeterministic); |
| 766 |
|
| 767 |
if (!cacheValuesTmpLabelRefDataIt->mCacheValues->contains(cacheValue)) { |
| 768 |
matching = false; |
| 769 |
} |
| 770 |
} |
| 771 |
if (matching) { |
| 772 |
return cacheValuesTmpLabelRefDataIt->mTmpLabelRef; |
| 773 |
} |
| 774 |
} |
| 775 |
} |
| 776 |
|
| 777 |
|
| 778 |
CPROCESSSET<CCacheValue>* superRoleCacheValueSet = CObjectParameterizingAllocator< CPROCESSSET<CCacheValue>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 779 |
CCacheValueTmpLabelReferenceData* newCacheValuesTmpLabelRefData = CObjectAllocator< CCacheValueTmpLabelReferenceData >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 780 |
newCacheValuesTmpLabelRefData->mCacheValues = superRoleCacheValueSet; |
| 781 |
newCacheValuesTmpLabelRefData->mNext = cacheValuesTmpLabelRefData; |
| 782 |
cacheValuesTmpLabelRefData = newCacheValuesTmpLabelRefData; |
| 783 |
|
| 784 |
|
| 785 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 786 |
newTempRefLabel->initLabelWriteData(signature, CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL); |
| 787 |
|
| 788 |
bool hasNondeterministicRoles = false; |
| 789 |
for (CBackendRepresentativeMemoryCacheRoleAssertionLinker* superRoleLinkerIt = superRoleAssertionLinker; superRoleLinkerIt; superRoleLinkerIt = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)superRoleLinkerIt->getNext()) { |
| 790 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 791 |
bool roleInversed = superRoleLinkerIt->isNegated(); |
| 792 |
bool asserted = superRoleLinkerIt->isABoxAsserted(); |
| 793 |
bool nomConnected = superRoleLinkerIt->isNominalConnected(); |
| 794 |
bool nondeterministic = superRoleLinkerIt->isNondeterministic(); |
| 795 |
hasNondeterministicRoles |= nondeterministic; |
| 796 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan); |
| 797 |
CCacheValue cacheValue = mAssBackCacheReader->getCacheValue(superRole, roleInversed, asserted, nomConnected, nondeterministic); |
| 798 |
|
| 799 |
newCacheValuesTmpLabelRefData->mCacheValues->insert(cacheValue); |
| 800 |
|
| 801 |
labelValueLinker->initLabelValueLinker(cacheValue); |
| 802 |
newTempRefLabel->appendCacheValueLinker(labelValueLinker); |
| 803 |
} |
| 804 |
if (hasNondeterministicRoles) { |
| 805 |
newTempRefLabel->addStatusFlags(CBackendRepresentativeMemoryCachingFlags::FLAG_NONDETERMINISTIC_ELEMENTS); |
| 806 |
} |
| 807 |
mNewTmpLabelList->append(newTempRefLabel); |
| 808 |
|
| 809 |
newCacheValuesTmpLabelRefData->mTmpLabelRef = newTempRefLabel; |
| 810 |
|
| 811 |
++mStatCreatedTempLabels; |
| 812 |
return newTempRefLabel; |
| 813 |
} |
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
const CCacheValue CBackendAssociationCacheHandler::getCacheValue(CConcept* concept, bool negation, bool deterministic) { |
| 824 |
return mAssBackCacheReader->getCacheValue(concept,negation, deterministic); |
| 825 |
} |
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
const CCacheValue CBackendAssociationCacheHandler::getCacheValue(CRole* role) { |
| 830 |
return mAssBackCacheReader->getCacheValue(role); |
| 831 |
} |
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
bool CBackendAssociationCacheHandler::visitConceptsOfAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, function<bool(CConcept* concept, bool negation, bool deterministic)> visitFunc, bool visitDeterministicConcepts, bool visitNonDeterministicConcepts, CCalculationAlgorithmContext* calcAlgContext) { |
| 836 |
return mAssBackCacheReader->visitConceptsOfAssociatedFullConceptSetLabel(assData, labelItem, visitFunc, visitDeterministicConcepts, visitNonDeterministicConcepts); |
| 837 |
} |
| 838 |
|
| 839 |
bool CBackendAssociationCacheHandler::hasConceptInAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, CConcept* concept, bool negation, CCalculationAlgorithmContext* calcAlgContext) { |
| 840 |
return mAssBackCacheReader->hasConceptInAssociatedFullConceptSetLabel(assData, labelItem, concept, negation); |
| 841 |
} |
| 842 |
|
| 843 |
bool CBackendAssociationCacheHandler::hasConceptInAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, CConcept* concept, bool negation, bool deterministic, CCalculationAlgorithmContext* calcAlgContext) { |
| 844 |
return mAssBackCacheReader->hasConceptInAssociatedFullConceptSetLabel(assData, labelItem, concept, negation, deterministic); |
| 845 |
} |
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
bool CBackendAssociationCacheHandler::visitIndividualIdsOfAssociatedIndividualSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* indiSetLabel, function<bool(cint64 indiId)> visitFunc, CCalculationAlgorithmContext* calcAlgContext) { |
| 851 |
return mAssBackCacheReader->visitIndividualIdsOfAssociatedIndividualSetLabel(assData, indiSetLabel, visitFunc); |
| 852 |
} |
| 853 |
|
| 854 |
bool CBackendAssociationCacheHandler::visitNominalIndirectlyConnectedIndividualIds(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 indiId, function<bool(cint64 indiId)> visitFunc, CCalculationAlgorithmContext* calcAlgContext) { |
| 855 |
CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData* nomConnData = getLoadedNominalIndividualIndirectConnectionData(indiId, nullptr, calcAlgContext); |
| 856 |
return mAssBackCacheReader->visitNominalIndirectlyConnectedIndividualIds(assData, nomConnData, visitFunc); |
| 857 |
} |
| 858 |
|
| 859 |
bool CBackendAssociationCacheHandler::visitConceptsOfAssociatedDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, function<bool(CConcept*, bool)> visitFunc, CCalculationAlgorithmContext* calcAlgContext) { |
| 860 |
return mAssBackCacheReader->visitConceptsOfAssociatedDeterministicConceptSetLabel(assData, visitFunc); |
| 861 |
} |
| 862 |
|
| 863 |
bool CBackendAssociationCacheHandler::visitConceptsOfAssociatedConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* conSetLabel, function<bool(CConcept*, bool)> visitFunc, CCalculationAlgorithmContext* calcAlgContext) { |
| 864 |
return mAssBackCacheReader->visitConceptsOfAssociatedConceptSetLabel(assData, conSetLabel, visitFunc); |
| 865 |
} |
| 866 |
|
| 867 |
bool CBackendAssociationCacheHandler::hasConceptInAssociatedDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CConcept* concept, bool negation, CCalculationAlgorithmContext* calcAlgContext) { |
| 868 |
return mAssBackCacheReader->hasConceptInAssociatedDeterministicConceptSetLabel(assData, concept, negation); |
| 869 |
} |
| 870 |
|
| 871 |
|
| 872 |
bool CBackendAssociationCacheHandler::visitConceptsOfAssociatedNonDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, function<bool(CConcept*, bool)> visitFunc, CCalculationAlgorithmContext* calcAlgContext) { |
| 873 |
return mAssBackCacheReader->visitConceptsOfAssociatedNonDeterministicConceptSetLabel(assData, visitFunc); |
| 874 |
} |
| 875 |
|
| 876 |
bool CBackendAssociationCacheHandler::hasConceptInAssociatedNonDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CConcept* concept, bool negation, CCalculationAlgorithmContext* calcAlgContext) { |
| 877 |
return mAssBackCacheReader->hasConceptInAssociatedNonDeterministicConceptSetLabel(assData, concept, negation); |
| 878 |
} |
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
bool CBackendAssociationCacheHandler::visitRolesOfAssociatedCombinedNeighbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, function<bool(CRole* role, bool inversed)> visitFunc, CCalculationAlgorithmContext* calcAlgContext) { |
| 883 |
return mAssBackCacheReader->visitRolesOfAssociatedCombinedNeigbourRoleSetLabel(assData, neighbourRoleSetLabel, visitFunc); |
| 884 |
} |
| 885 |
|
| 886 |
|
| 887 |
bool CBackendAssociationCacheHandler::visitLabelsOfAssociatedNeigbourRoleSetCombinationLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetCompinationLabel, function<bool(CBackendRepresentativeMemoryLabelCacheItem* label)> visitFunc) { |
| 888 |
return mAssBackCacheReader->visitLabelsOfAssociatedNeigbourRoleSetCombinationLabel(assData, neighbourRoleSetCompinationLabel, visitFunc); |
| 889 |
} |
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
bool CBackendAssociationCacheHandler::visitRolesOfAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, function<bool(CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)> visitFunc) { |
| 894 |
return mAssBackCacheReader->visitRolesOfAssociatedNeigbourRoleSetLabel(assData, neighbourRoleSetLabel, visitFunc); |
| 895 |
} |
| 896 |
|
| 897 |
bool CBackendAssociationCacheHandler::hasRoleInAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic) { |
| 898 |
return mAssBackCacheReader->hasRoleInAssociatedNeigbourRoleSetLabel(assData, neighbourRoleSetLabel, role, inversed, assertionLinkBase, nominalLinkBase, nondeterministic); |
| 899 |
} |
| 900 |
|
| 901 |
bool CBackendAssociationCacheHandler::hasRoleInAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed, bool nondeterministic) { |
| 902 |
return mAssBackCacheReader->hasRoleInAssociatedNeigbourRoleSetLabel(assData, neighbourRoleSetLabel, role, inversed, nondeterministic); |
| 903 |
} |
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
bool CBackendAssociationCacheHandler::hasRoleInAssociatedCombinedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed) { |
| 908 |
return mAssBackCacheReader->hasRoleInAssociatedCombinedNeigbourRoleSetLabel(assData, neighbourRoleSetLabel, role, inversed); |
| 909 |
} |
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
bool CBackendAssociationCacheHandler::hasRoleInAssociatedCompinationRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed) { |
| 914 |
return mAssBackCacheReader->hasRoleInAssociatedCompinationRoleSetLabel(assData, neighbourRoleSetLabel, role, inversed); |
| 915 |
} |
| 916 |
|
| 917 |
|
| 918 |
bool CBackendAssociationCacheHandler::hasIndividualIdsInAssociatedIndividualSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* indiSetLabel, cint64 indiId) { |
| 919 |
return mAssBackCacheReader->hasIndividualIdsInAssociatedIndividualSetLabel(assData, indiSetLabel, indiId); |
| 920 |
} |
| 921 |
|
| 922 |
bool CBackendAssociationCacheHandler::hasRoleToNeigbourInAssociatedNeighbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 neighbourIndiId, CRole* role, bool inversed) { |
| 923 |
return mAssBackCacheReader->hasRoleToNeigbourInAssociatedNeighbourRoleSetLabel(assData, neighbourIndiId, role, inversed); |
| 924 |
} |
| 925 |
|
| 926 |
bool CBackendAssociationCacheHandler::visitRolesToNeigbourInAssociatedNeighbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 neighbourIndiId, function<bool(CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)> visitFunc, CCalculationAlgorithmContext* calcAlgContext) { |
| 927 |
return mAssBackCacheReader->visitRolesToNeigbourInAssociatedNeighbourRoleSetLabel(assData, neighbourIndiId, visitFunc); |
| 928 |
} |
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
bool CBackendAssociationCacheHandler::visitRolesOfAssociatedCompinationRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* combinationRoleSetLabel, function<bool(CRole* role, bool inversed)> visitFunc, CCalculationAlgorithmContext* calcAlgContext) { |
| 935 |
return mAssBackCacheReader->visitRolesOfAssociatedCompinationRoleSetLabel(assData, combinationRoleSetLabel, visitFunc); |
| 936 |
} |
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
bool CBackendAssociationCacheHandler::checkLabelContainsCacheValue(CBackendRepresentativeMemoryLabelCacheItem* cacheItemLabel, const CCacheValue& cacheValue, CCalculationAlgorithmContext* calcAlgContext) { |
| 943 |
if (cacheItemLabel) { |
| 944 |
CBackendRepresentativeMemoryLabelValueLinker* containedValueLinker = cacheItemLabel->getTagCacheValueHash(false)->value(cacheValue.getTag()); |
| 945 |
if (containedValueLinker && containedValueLinker->getCacheValue() == cacheValue) { |
| 946 |
return true; |
| 947 |
} |
| 948 |
} |
| 949 |
return false; |
| 950 |
} |
| 951 |
|
| 952 |
bool CBackendAssociationCacheHandler::checkLabelContainsAllLinkedCacheValues(CBackendRepresentativeMemoryLabelCacheItem* cacheItemLabel, CBackendRepresentativeMemoryLabelValueLinker* cacheValueLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 953 |
for (CBackendRepresentativeMemoryLabelValueLinker* cacheValueLinkerIt = cacheValueLinker; cacheValueLinkerIt; cacheValueLinkerIt = cacheValueLinkerIt->getNext()) { |
| 954 |
if (!checkLabelContainsCacheValue(cacheItemLabel, cacheValueLinkerIt->getCacheValue(), calcAlgContext)) { |
| 955 |
return false; |
| 956 |
} |
| 957 |
} |
| 958 |
return true; |
| 959 |
} |
| 960 |
|
| 961 |
|
| 962 |
bool CBackendAssociationCacheHandler::checkNeighbourRoleInstantiatedSetCompinationLabelContainsNeighbourRoleInstantiatedSet(CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleInstantiatedSetCompinationLabel, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleInstantiatedSetLabel, CCalculationAlgorithmContext* calcAlgContext) { |
| 963 |
if (neighbourRoleInstantiatedSetCompinationLabel) { |
| 964 |
CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker tempLabelRefDataLinker; |
| 965 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference tempLabelRef; |
| 966 |
tempLabelRef.setReferredLabelData(neighbourRoleInstantiatedSetLabel); |
| 967 |
tempLabelRefDataLinker.initLabelReferenceDataLinker(tempLabelRef); |
| 968 |
return checkLabelContainsCacheValue(neighbourRoleInstantiatedSetCompinationLabel, mAssBackCacheReader->getCacheValue(&tempLabelRefDataLinker), calcAlgContext); |
| 969 |
} |
| 970 |
return false; |
| 971 |
} |
| 972 |
|
| 973 |
bool CBackendAssociationCacheHandler::checkNeighbourRoleInstantiatedSetCompinationLabelContainsNeighbourRoleInstantiatedSet(CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleInstantiatedSetCompinationLabel, CBackendRepresentativeMemoryCacheTemporaryLabelReference& tempLabelRef, CCalculationAlgorithmContext* calcAlgContext) { |
| 974 |
if (neighbourRoleInstantiatedSetCompinationLabel) { |
| 975 |
CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker tempLabelRefDataLinker; |
| 976 |
tempLabelRefDataLinker.initLabelReferenceDataLinker(tempLabelRef); |
| 977 |
return checkLabelContainsCacheValue(neighbourRoleInstantiatedSetCompinationLabel, mAssBackCacheReader->getCacheValue(&tempLabelRefDataLinker), calcAlgContext); |
| 978 |
} |
| 979 |
return false; |
| 980 |
} |
| 981 |
|
| 982 |
|
| 983 |
bool CBackendAssociationCacheHandler::checkNeighbourRoleInstantiatedSetCompinationLabelContainsNeighbourRoleInstantiatedSet(CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleInstantiatedSetCompinationLabel, CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker* neighbourRoleInstantiatedSetLabelDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 984 |
return checkLabelContainsCacheValue(neighbourRoleInstantiatedSetCompinationLabel, mAssBackCacheReader->getCacheValue(neighbourRoleInstantiatedSetLabelDataLinker), calcAlgContext); |
| 985 |
} |
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
}; // end namespace Algorithm |
| 1003 |
|
| 1004 |
}; // end namespace Kernel |
| 1005 |
|
| 1006 |
}; // end namespace Reasoner |
| 1007 |
|
| 1008 |
}; // end namespace Konclude |