| 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 "CBackendRepresentativeMemoryCacheReader.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Cache { |
| 31 |
|
| 32 |
|
| 33 |
CBackendRepresentativeMemoryCacheReader::CBackendRepresentativeMemoryCacheReader() : CLinkerBase<CBackendRepresentativeMemoryCacheReader*,CBackendRepresentativeMemoryCacheReader>(this) { |
| 34 |
mCurrentSlot = nullptr; |
| 35 |
mFixedOntologyData = nullptr; |
| 36 |
mOntologyData = nullptr; |
| 37 |
mRecomputationId = 0; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
CBackendRepresentativeMemoryCacheReader* CBackendRepresentativeMemoryCacheReader::updateSlot(CBackendRepresentativeMemoryCacheSlotItem* updatedSlot) { |
| 42 |
CBackendRepresentativeMemoryCacheSlotItem* prevSlot = mUpdatedSlot.fetchAndStoreOrdered(updatedSlot); |
| 43 |
if (prevSlot != nullptr) { |
| 44 |
prevSlot->decReader(); |
| 45 |
} |
| 46 |
return this; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
CBackendRepresentativeMemoryCacheReader* CBackendRepresentativeMemoryCacheReader::checkRecomputationIdUsage(cint64 recomputationId) { |
| 51 |
mRecomputationId = recomputationId; |
| 52 |
if (hasUpdatedSlotItem()) { |
| 53 |
switchToUpdatedSlotItem(); |
| 54 |
} |
| 55 |
if (!mOntologyData && mCurrentSlot) { |
| 56 |
mOntologyData = mCurrentSlot->getOntologyData(mOntologyIdentifier); |
| 57 |
} |
| 58 |
if (mOntologyData) { |
| 59 |
if (recomputationId < mOntologyData->getMinimumValidRecomputationId()) { |
| 60 |
throw CCalculationErrorProcessingException(CCalculationErrorProcessingException::ECINVALIDRECOMPUATIONID); |
| 61 |
} |
| 62 |
CBackendRepresentativeMemoryCacheOntologyDataRecomputationReferenceLinker* recRefLinker = mOntologyData->getRecomputationReferenceLinker(); |
| 63 |
if (recRefLinker) { |
| 64 |
recRefLinker->updateUsedRecomputationId(recomputationId); |
| 65 |
} |
| 66 |
} |
| 67 |
return this; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
CBackendRepresentativeMemoryCacheReader* CBackendRepresentativeMemoryCacheReader::fixOntologyData(CBackendRepresentativeMemoryCacheOntologyData* ontologyData) { |
| 72 |
mFixedOntologyData = ontologyData; |
| 73 |
mOntologyData = ontologyData; |
| 74 |
return this; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
bool CBackendRepresentativeMemoryCacheReader::hasUpdatedSlotItem() { |
| 79 |
return mUpdatedSlot.fetchAndAddRelaxed(0) != nullptr; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
bool CBackendRepresentativeMemoryCacheReader::switchToUpdatedSlotItem() { |
| 84 |
CBackendRepresentativeMemoryCacheSlotItem* updatedSlot = mUpdatedSlot.fetchAndStoreOrdered(nullptr); |
| 85 |
if (updatedSlot) { |
| 86 |
CBackendRepresentativeMemoryCacheSlotItem* prevSlot = mCurrentSlot; |
| 87 |
mCurrentSlot = updatedSlot; |
| 88 |
if (prevSlot != nullptr) { |
| 89 |
prevSlot->decReader(); |
| 90 |
} |
| 91 |
mOntologyData = nullptr; |
| 92 |
if (mCurrentSlot) { |
| 93 |
mOntologyData = mCurrentSlot->getOntologyData(mOntologyIdentifier); |
| 94 |
} |
| 95 |
if (mOntologyData && mRecomputationId != 0) { |
| 96 |
CBackendRepresentativeMemoryCacheOntologyDataRecomputationReferenceLinker* recRefLinker = mOntologyData->getRecomputationReferenceLinker(); |
| 97 |
if (recRefLinker) { |
| 98 |
recRefLinker->updateUsedRecomputationId(mRecomputationId); |
| 99 |
} |
| 100 |
} |
| 101 |
return true; |
| 102 |
} |
| 103 |
return false; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
CBackendRepresentativeMemoryCacheReader* CBackendRepresentativeMemoryCacheReader::setWorkingOntology(cint64 ontologyIdentifier) { |
| 109 |
mOntologyIdentifier = ontologyIdentifier; |
| 110 |
if (hasUpdatedSlotItem()) { |
| 111 |
switchToUpdatedSlotItem(); |
| 112 |
} |
| 113 |
mOntologyData = nullptr; |
| 114 |
if (mCurrentSlot) { |
| 115 |
mOntologyData = mCurrentSlot->getOntologyData(mOntologyIdentifier); |
| 116 |
} |
| 117 |
if (mFixedOntologyData) { |
| 118 |
mOntologyData = mFixedOntologyData; |
| 119 |
} |
| 120 |
return this; |
| 121 |
} |
| 122 |
|
| 123 |
CBackendRepresentativeMemoryCacheReader* CBackendRepresentativeMemoryCacheReader::setWorkingOntology(CConcreteOntology* ontology) { |
| 124 |
return setWorkingOntology(ontology->getOntologyID()); |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
bool CBackendRepresentativeMemoryCacheReader::hasSameIndividualsMergings() { |
| 130 |
if (hasUpdatedSlotItem()) { |
| 131 |
switchToUpdatedSlotItem(); |
| 132 |
} |
| 133 |
if (mOntologyData) { |
| 134 |
return mOntologyData->hasSameIndividualsMergings(); |
| 135 |
} |
| 136 |
return false; |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
bool CBackendRepresentativeMemoryCacheReader::hasCacheEntry(cint64 labelType, cint64 signature) { |
| 142 |
if (hasUpdatedSlotItem()) { |
| 143 |
switchToUpdatedSlotItem(); |
| 144 |
} |
| 145 |
if (mOntologyData) { |
| 146 |
CCACHINGHASH<cint64,CBackendRepresentativeMemoryLabelSignatureResolveCacheItem>* sigItemHash = mOntologyData->getSignatureLabelItemHash(labelType); |
| 147 |
if (sigItemHash) { |
| 148 |
return sigItemHash->contains(signature); |
| 149 |
} |
| 150 |
} |
| 151 |
return false; |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
bool CBackendRepresentativeMemoryCacheReader::visitLabelCacheEntries(cint64 labelType, function<bool(CBackendRepresentativeMemoryLabelCacheItem* labelItem)> visitFunc) { |
| 157 |
if (hasUpdatedSlotItem()) { |
| 158 |
switchToUpdatedSlotItem(); |
| 159 |
} |
| 160 |
bool continueVisiting = true; |
| 161 |
bool visited = false; |
| 162 |
if (mOntologyData) { |
| 163 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelSignatureResolveCacheItem>* sigItemHash = mOntologyData->getSignatureLabelItemHash(labelType); |
| 164 |
if (sigItemHash) { |
| 165 |
for (CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelSignatureResolveCacheItem>::const_iterator sigHashIt = sigItemHash->constBegin(), sigHashItEnd = sigItemHash->constEnd(); sigHashIt != sigHashItEnd && continueVisiting; ++sigHashIt) { |
| 166 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem sigResolveCacheItem = sigHashIt.value(); |
| 167 |
for (CBackendRepresentativeMemoryLabelCacheItem* itemIt = sigResolveCacheItem.getLabelItems(); itemIt && continueVisiting; itemIt = itemIt->getNext()) { |
| 168 |
continueVisiting = visitFunc(itemIt); |
| 169 |
visited = true; |
| 170 |
} |
| 171 |
} |
| 172 |
} |
| 173 |
} |
| 174 |
return visited; |
| 175 |
} |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* CBackendRepresentativeMemoryCacheReader::getLabelCacheEntry(cint64 labelType, cint64 signature) { |
| 182 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* entry = &mEmptySigResCacheItem; |
| 183 |
if (hasUpdatedSlotItem()) { |
| 184 |
switchToUpdatedSlotItem(); |
| 185 |
} |
| 186 |
if (mOntologyData) { |
| 187 |
CCACHINGHASH<cint64,CBackendRepresentativeMemoryLabelSignatureResolveCacheItem>* sigItemHash = mOntologyData->getSignatureLabelItemHash(labelType); |
| 188 |
if (sigItemHash && sigItemHash->contains(signature)) { |
| 189 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem& item = (*sigItemHash)[signature]; |
| 190 |
entry = &item; |
| 191 |
} |
| 192 |
} |
| 193 |
return entry; |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* CBackendRepresentativeMemoryCacheReader::getIndividualAssociationData(CIndividual* individual) { |
| 199 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* assData = nullptr; |
| 200 |
if (!assData) { |
| 201 |
assData = getIndividualAssociationData(individual->getIndividualID()); |
| 202 |
} |
| 203 |
return assData; |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* CBackendRepresentativeMemoryCacheReader::getIndividualAssociationData(cint64 indiId) { |
| 208 |
|
| 209 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* assData = nullptr; |
| 210 |
if (hasUpdatedSlotItem()) { |
| 211 |
switchToUpdatedSlotItem(); |
| 212 |
} |
| 213 |
if (mOntologyData) { |
| 214 |
cint64 indiIdAssoDataVectorSize = mOntologyData->getIndividualIdAssoiationDataVectorSize(); |
| 215 |
CBackendRepresentativeMemoryCacheIndividualAssociationData** indiIdAssoDataVector = mOntologyData->getIndividualIdAssoiationDataVector(); |
| 216 |
|
| 217 |
if (mOntologyData->isBasicPrecomputationMode()) { |
| 218 |
indiIdAssoDataVectorSize = mOntologyData->getBasicPrecomputationIndividualIdAssoiationDataVectorSize(); |
| 219 |
indiIdAssoDataVector = mOntologyData->getBasicPrecomputationIndividualIdAssoiationDataVector(); |
| 220 |
} |
| 221 |
|
| 222 |
if (indiIdAssoDataVector && indiId < indiIdAssoDataVectorSize) { |
| 223 |
assData = indiIdAssoDataVector[indiId]; |
| 224 |
} |
| 225 |
//CCACHINGHASH<cint64, CBackendRepresentativeMemoryCacheIndividualAssociationData*>* indiIdAssoDataHash = mOntologyData->getIndividualIdAssociationDataHash(); |
| 226 |
//if (indiIdAssoDataHash) { |
| 227 |
// assData = indiIdAssoDataHash->value(indiId, nullptr); |
| 228 |
//} |
| 229 |
|
| 230 |
//TODO: create copy of data |
| 231 |
} |
| 232 |
|
| 233 |
return assData; |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getIndividualAssociatedCacheLabelItem(cint64 indiId, cint64 labelType) { |
| 239 |
if (hasUpdatedSlotItem()) { |
| 240 |
switchToUpdatedSlotItem(); |
| 241 |
} |
| 242 |
if (mOntologyData) { |
| 243 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* assData = nullptr; |
| 244 |
cint64 indiIdAssoDataVectorSize = mOntologyData->getIndividualIdAssoiationDataVectorSize(); |
| 245 |
CBackendRepresentativeMemoryCacheIndividualAssociationData** indiIdAssoDataVector = mOntologyData->getIndividualIdAssoiationDataVector(); |
| 246 |
|
| 247 |
if (mOntologyData->isBasicPrecomputationMode()) { |
| 248 |
indiIdAssoDataVectorSize = mOntologyData->getBasicPrecomputationIndividualIdAssoiationDataVectorSize(); |
| 249 |
indiIdAssoDataVector = mOntologyData->getBasicPrecomputationIndividualIdAssoiationDataVector(); |
| 250 |
} |
| 251 |
|
| 252 |
if (indiIdAssoDataVector && indiId < indiIdAssoDataVectorSize) { |
| 253 |
assData = indiIdAssoDataVector[indiId]; |
| 254 |
} |
| 255 |
if (assData) { |
| 256 |
return assData->getLabelCacheEntry(labelType); |
| 257 |
} |
| 258 |
} |
| 259 |
|
| 260 |
return nullptr; |
| 261 |
} |
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData* CBackendRepresentativeMemoryCacheReader::getNominalIndirectConnectionData(cint64 indiId) { |
| 266 |
|
| 267 |
CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData* nomConnData = nullptr; |
| 268 |
if (hasUpdatedSlotItem()) { |
| 269 |
switchToUpdatedSlotItem(); |
| 270 |
} |
| 271 |
if (mOntologyData) { |
| 272 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData* >* nominaIIndividualdIndirectConnectionDataHash = mOntologyData->getNominaIIndividualdIndirectConnectionDataHash(); |
| 273 |
if (nominaIIndividualdIndirectConnectionDataHash) { |
| 274 |
nomConnData = nominaIIndividualdIndirectConnectionDataHash->value(indiId); |
| 275 |
} |
| 276 |
|
| 277 |
//TODO: create copy of data |
| 278 |
} |
| 279 |
|
| 280 |
return nomConnData; |
| 281 |
} |
| 282 |
|
| 283 |
|
| 284 |
const CCacheValue CBackendRepresentativeMemoryCacheReader::getCacheValue(cint64 indiId, bool negation) { |
| 285 |
CCacheValue::CACHEVALUEIDENTIFIER cacheValueIdentifier = CCacheValue::CACHE_VALUE_INDIVIDUAL_ID; |
| 286 |
if (negation) { |
| 287 |
indiId = -indiId; |
| 288 |
cacheValueIdentifier = CCacheValue::CACHE_VALUE_NEGATED_INDIVIDUAL_ID; |
| 289 |
} |
| 290 |
CCacheValue cacheValue; |
| 291 |
cacheValue.initCacheValue(indiId, 0, cacheValueIdentifier); |
| 292 |
return cacheValue; |
| 293 |
} |
| 294 |
|
| 295 |
|
| 296 |
const CCacheValue CBackendRepresentativeMemoryCacheReader::getCacheValue(CConcept* concept, bool negation, bool deterministic) { |
| 297 |
cint64 conTag = concept->getConceptTag(); |
| 298 |
CCacheValue::CACHEVALUEIDENTIFIER cacheValueIdentifier = CCacheValue::CACHEVALTAGANDCONCEPT; |
| 299 |
if (negation) { |
| 300 |
conTag = -conTag; |
| 301 |
if (deterministic) { |
| 302 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGANDNEGATEDCONCEPT; |
| 303 |
} else { |
| 304 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_NEGATED_CONCEPT; |
| 305 |
} |
| 306 |
} else if (!deterministic) { |
| 307 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_CONCEPT; |
| 308 |
} |
| 309 |
CCacheValue cacheValue; |
| 310 |
cacheValue.initCacheValue(conTag, (cint64)concept, cacheValueIdentifier); |
| 311 |
return cacheValue; |
| 312 |
} |
| 313 |
|
| 314 |
const CCacheValue CBackendRepresentativeMemoryCacheReader::getCacheValue(CRole* role) { |
| 315 |
cint64 roleTag = role->getRoleTag(); |
| 316 |
CCacheValue::CACHEVALUEIDENTIFIER cacheValueIdentifier = CCacheValue::CACHEVALTAGANDROLE; |
| 317 |
CCacheValue cacheValue; |
| 318 |
cacheValue.initCacheValue(roleTag,(cint64)role,cacheValueIdentifier); |
| 319 |
return cacheValue; |
| 320 |
} |
| 321 |
|
| 322 |
|
| 323 |
bool CBackendRepresentativeMemoryCacheReader::isCacheValueRoleInverse(const CCacheValue& cacheValue) { |
| 324 |
CCacheValue::CACHEVALUEIDENTIFIER cacheValueIdentifier = cacheValue.getCacheValueIdentifier(); |
| 325 |
return cacheValueIdentifier == CCacheValue::CACHEVALTAGANDINVERSEDROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGANDINVERSEDASSERTEDROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGANDINVERSED_NOMINAL_CONNECTED_ROLE |
| 326 |
|| cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDASSERTEDROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSED_NOMINAL_CONNECTED_ROLE; |
| 327 |
} |
| 328 |
|
| 329 |
|
| 330 |
bool CBackendRepresentativeMemoryCacheReader::isCacheValueRoleNondeterministic(const CCacheValue& cacheValue) { |
| 331 |
CCacheValue::CACHEVALUEIDENTIFIER cacheValueIdentifier = cacheValue.getCacheValueIdentifier(); |
| 332 |
return cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_ROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_ASSERTEDROLE |
| 333 |
|| cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDASSERTEDROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_NOMINAL_CONNECTED_ROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSED_NOMINAL_CONNECTED_ROLE; |
| 334 |
} |
| 335 |
|
| 336 |
bool CBackendRepresentativeMemoryCacheReader::isCacheValueRoleNominal(const CCacheValue& cacheValue) { |
| 337 |
CCacheValue::CACHEVALUEIDENTIFIER cacheValueIdentifier = cacheValue.getCacheValueIdentifier(); |
| 338 |
return cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NOMINAL_CONNECTED_ROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGANDINVERSED_NOMINAL_CONNECTED_ROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_NOMINAL_CONNECTED_ROLE |
| 339 |
|| cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSED_NOMINAL_CONNECTED_ROLE; |
| 340 |
} |
| 341 |
|
| 342 |
bool CBackendRepresentativeMemoryCacheReader::isCacheValueRoleAssertion(const CCacheValue& cacheValue) { |
| 343 |
CCacheValue::CACHEVALUEIDENTIFIER cacheValueIdentifier = cacheValue.getCacheValueIdentifier(); |
| 344 |
return cacheValueIdentifier == CCacheValue::CACHEVALTAGANDASSERTEDROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGANDINVERSEDASSERTEDROLE || cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_ASSERTEDROLE |
| 345 |
|| cacheValueIdentifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDASSERTEDROLE; |
| 346 |
} |
| 347 |
|
| 348 |
const CCacheValue CBackendRepresentativeMemoryCacheReader::getCacheValue(CRole* role, bool inversed, bool assertionLinkBase, bool nominalConnected, bool nondeterministc) { |
| 349 |
cint64 roleTag = role->getRoleTag(); |
| 350 |
CCacheValue::CACHEVALUEIDENTIFIER cacheValueIdentifier = CCacheValue::CACHEVALTAGANDROLE; |
| 351 |
if (inversed) { |
| 352 |
roleTag = -roleTag; |
| 353 |
if (assertionLinkBase) { |
| 354 |
if (!nondeterministc) { |
| 355 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGANDINVERSEDASSERTEDROLE; |
| 356 |
} else { |
| 357 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDASSERTEDROLE; |
| 358 |
} |
| 359 |
} else if (nominalConnected) { |
| 360 |
if (!nondeterministc) { |
| 361 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGANDINVERSED_NOMINAL_CONNECTED_ROLE; |
| 362 |
} else { |
| 363 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSED_NOMINAL_CONNECTED_ROLE; |
| 364 |
} |
| 365 |
} else { |
| 366 |
if (!nondeterministc) { |
| 367 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGANDINVERSEDROLE; |
| 368 |
} else { |
| 369 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDROLE; |
| 370 |
} |
| 371 |
} |
| 372 |
} else { |
| 373 |
if (assertionLinkBase) { |
| 374 |
if (!nondeterministc) { |
| 375 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGANDASSERTEDROLE; |
| 376 |
} else { |
| 377 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_ASSERTEDROLE; |
| 378 |
} |
| 379 |
} else if (nominalConnected) { |
| 380 |
if (!nondeterministc) { |
| 381 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGAND_NOMINAL_CONNECTED_ROLE; |
| 382 |
} else { |
| 383 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_NOMINAL_CONNECTED_ROLE; |
| 384 |
} |
| 385 |
} else if (nondeterministc) { |
| 386 |
cacheValueIdentifier = CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_ROLE; |
| 387 |
} |
| 388 |
} |
| 389 |
CCacheValue cacheValue; |
| 390 |
cacheValue.initCacheValue(roleTag, (cint64)role, cacheValueIdentifier); |
| 391 |
return cacheValue; |
| 392 |
} |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
bool CBackendRepresentativeMemoryCacheReader::visitLabelsOfAssociatedNeigbourRoleSetCombinationLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetCompinationLabel, function<bool(CBackendRepresentativeMemoryLabelCacheItem* label)> visitFunc) { |
| 400 |
if (neighbourRoleSetCompinationLabel) { |
| 401 |
CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinker = neighbourRoleSetCompinationLabel->getCacheValueLinker(); |
| 402 |
if (lablelValueLinker) { |
| 403 |
bool continueVisiting = true; |
| 404 |
for (CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinkerIt = lablelValueLinker; lablelValueLinkerIt && continueVisiting; lablelValueLinkerIt = lablelValueLinkerIt->getNext()) { |
| 405 |
const CCacheValue& cacheValue = lablelValueLinkerIt->getCacheValue(); |
| 406 |
|
| 407 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSet = (CBackendRepresentativeMemoryLabelCacheItem*)cacheValue.getIdentification(); |
| 408 |
continueVisiting = visitFunc(neighbourRoleSet); |
| 409 |
} |
| 410 |
return true; |
| 411 |
} |
| 412 |
} |
| 413 |
return false; |
| 414 |
} |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
bool CBackendRepresentativeMemoryCacheReader::visitRolesOfAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, function<bool(CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)> visitFunc) { |
| 419 |
if (neighbourRoleSetLabel) { |
| 420 |
CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinker = neighbourRoleSetLabel->getCacheValueLinker(); |
| 421 |
|
| 422 |
if (lablelValueLinker) { |
| 423 |
bool continueVisiting = true; |
| 424 |
for (CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinkerIt = lablelValueLinker; lablelValueLinkerIt && continueVisiting; lablelValueLinkerIt = lablelValueLinkerIt->getNext()) { |
| 425 |
const CCacheValue& cacheValue = lablelValueLinkerIt->getCacheValue(); |
| 426 |
|
| 427 |
CRole* role = (CRole*)cacheValue.getIdentification(); |
| 428 |
|
| 429 |
CCacheValue::CACHEVALUEIDENTIFIER identifier = cacheValue.getCacheValueIdentifier(); |
| 430 |
bool roleInversed = identifier == CCacheValue::CACHEVALTAGANDINVERSEDROLE || identifier == CCacheValue::CACHEVALTAGANDINVERSEDASSERTEDROLE || identifier == CCacheValue::CACHEVALTAGANDINVERSED_NOMINAL_CONNECTED_ROLE || |
| 431 |
identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDASSERTEDROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSED_NOMINAL_CONNECTED_ROLE; |
| 432 |
|
| 433 |
bool assertionLinkBase = identifier == CCacheValue::CACHEVALTAGANDASSERTEDROLE || identifier == CCacheValue::CACHEVALTAGANDINVERSEDASSERTEDROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_ASSERTEDROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDASSERTEDROLE; |
| 434 |
|
| 435 |
bool nominalConnected = identifier == CCacheValue::CACHEVALTAGAND_NOMINAL_CONNECTED_ROLE || identifier == CCacheValue::CACHEVALTAGANDINVERSED_NOMINAL_CONNECTED_ROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_NOMINAL_CONNECTED_ROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSED_NOMINAL_CONNECTED_ROLE; |
| 436 |
|
| 437 |
bool nondeterministc = identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_ROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_ASSERTEDROLE || |
| 438 |
identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDASSERTEDROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_NOMINAL_CONNECTED_ROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSED_NOMINAL_CONNECTED_ROLE; |
| 439 |
|
| 440 |
continueVisiting = visitFunc(role, roleInversed, assertionLinkBase, nominalConnected, nondeterministc); |
| 441 |
} |
| 442 |
return true; |
| 443 |
} |
| 444 |
} |
| 445 |
return false; |
| 446 |
} |
| 447 |
|
| 448 |
|
| 449 |
cint64 CBackendRepresentativeMemoryCacheReader::getNeighbourCountForArrayPos(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 pos) { |
| 450 |
cint64 count = 0; |
| 451 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* neighbourArray = assData->getRoleSetNeighbourArray(); |
| 452 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourCombLabelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 453 |
if (neighbourCombLabelItem && neighbourArray) { |
| 454 |
count += neighbourArray->at(pos).getIndividualCount(); |
| 455 |
} |
| 456 |
return count; |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
cint64 CBackendRepresentativeMemoryCacheReader::getNeighbourCountForRole(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CRole* role) { |
| 461 |
cint64 count = 0; |
| 462 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* neighbourArray = assData->getRoleSetNeighbourArray(); |
| 463 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourCombLabelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 464 |
if (neighbourCombLabelItem && neighbourArray) { |
| 465 |
CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData* extensionData = (CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData*)neighbourCombLabelItem->getExtensionData(CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData::TAG_RESOLVING_HASH); |
| 466 |
if (extensionData) { |
| 467 |
for (CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingDataLinker* linkerIt = extensionData->getTagLabelResolvingDataLinker(role->getRoleTag()); linkerIt; linkerIt = linkerIt->getNext()) { |
| 468 |
cint64 index = linkerIt->getIndex(); |
| 469 |
count += neighbourArray->at(index).getIndividualCount(); |
| 470 |
} |
| 471 |
} |
| 472 |
} |
| 473 |
return count; |
| 474 |
} |
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
bool CBackendRepresentativeMemoryCacheReader::visitNeighbourIndividualIdsForNeighbourArrayIdFromCursor(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 arrayId, function<bool(cint64 neighbourIndividualId, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, bool nondeterministic, cint64 nextCursor)> visitFunc, bool visitOnlyDeterministicNeighbours, cint64 cursor) { |
| 479 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* neighbourArray = assData->getRoleSetNeighbourArray(); |
| 480 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourCombLabelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 481 |
if (neighbourCombLabelItem && neighbourArray) { |
| 482 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourLabel = neighbourArray->getIndexData()->getNeighbourRoleSetLabel(arrayId); |
| 483 |
bool continueVisiting = true; |
| 484 |
neighbourArray->at(arrayId).visitNeighbourIndividualIdsFromCursor([&](cint64 neighbourIndiId, cint64 cursor)->bool { |
| 485 |
continueVisiting = visitFunc(neighbourIndiId, neighbourLabel, neighbourLabel->hasNondeterministicElements(), cursor); |
| 486 |
return continueVisiting; |
| 487 |
}, cursor); |
| 488 |
return true; |
| 489 |
} |
| 490 |
return false; |
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
bool CBackendRepresentativeMemoryCacheReader::visitNeighbourIndividualIdsForRole(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CRole* role, function<bool(cint64 neighbourIndividualId, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, bool nondeterministic)> visitFunc, bool visitOnlyDeterministicNeighbours) { |
| 496 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* neighbourArray = assData->getRoleSetNeighbourArray(); |
| 497 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourCombLabelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 498 |
if (neighbourCombLabelItem && neighbourArray) { |
| 499 |
CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData* extensionData = (CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData*)neighbourCombLabelItem->getExtensionData(CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData::TAG_RESOLVING_HASH); |
| 500 |
if (extensionData) { |
| 501 |
bool continueVisiting = true; |
| 502 |
for (CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingDataLinker* linkerIt = extensionData->getTagLabelResolvingDataLinker(role->getRoleTag()); linkerIt && continueVisiting; linkerIt = linkerIt->getNext()) { |
| 503 |
cint64 index = linkerIt->getIndex(); |
| 504 |
if (!visitOnlyDeterministicNeighbours || linkerIt->isDeterministic()) { |
| 505 |
neighbourArray->at(index).visitNeighbourIndividualIds([&](cint64 neighbourIndiId)->bool { |
| 506 |
continueVisiting = visitFunc(neighbourIndiId, linkerIt->getLabelCacheItem(), !linkerIt->isDeterministic()); |
| 507 |
return continueVisiting; |
| 508 |
}); |
| 509 |
} |
| 510 |
} |
| 511 |
return true; |
| 512 |
} |
| 513 |
} |
| 514 |
return false; |
| 515 |
} |
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
bool CBackendRepresentativeMemoryCacheReader::visitNeighbourArrayIdsForRole(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CRole* role, function<bool(cint64 neighbourIndividualId, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, bool nondeterministic)> visitFunc, bool visitOnlyDeterministicNeighbours) { |
| 521 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* neighbourArray = assData->getRoleSetNeighbourArray(); |
| 522 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourCombLabelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 523 |
if (neighbourCombLabelItem && neighbourArray) { |
| 524 |
CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData* extensionData = (CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData*)neighbourCombLabelItem->getExtensionData(CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData::TAG_RESOLVING_HASH); |
| 525 |
if (extensionData) { |
| 526 |
bool continueVisiting = true; |
| 527 |
for (CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingDataLinker* linkerIt = extensionData->getTagLabelResolvingDataLinker(role->getRoleTag()); linkerIt && continueVisiting; linkerIt = linkerIt->getNext()) { |
| 528 |
cint64 index = linkerIt->getIndex(); |
| 529 |
if (!visitOnlyDeterministicNeighbours || linkerIt->isDeterministic()) { |
| 530 |
continueVisiting = visitFunc(index, linkerIt->getLabelCacheItem(), !linkerIt->isDeterministic()); |
| 531 |
} |
| 532 |
} |
| 533 |
return true; |
| 534 |
} |
| 535 |
} |
| 536 |
return false; |
| 537 |
} |
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
bool CBackendRepresentativeMemoryCacheReader::hasRoleInAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic) { |
| 544 |
if (neighbourRoleSetLabel) { |
| 545 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = neighbourRoleSetLabel->getTagCacheValueHash(false); |
| 546 |
if (labelValueHash) { |
| 547 |
cint64 tag = role->getRoleTag(); |
| 548 |
if (inversed) { |
| 549 |
tag = -tag; |
| 550 |
} |
| 551 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(tag); |
| 552 |
if (labelLinker && getCacheValue(role, inversed, assertionLinkBase, nominalLinkBase, nondeterministic) == labelLinker->getCacheValue()) { |
| 553 |
return true; |
| 554 |
} |
| 555 |
} |
| 556 |
} |
| 557 |
return false; |
| 558 |
} |
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
bool CBackendRepresentativeMemoryCacheReader::hasRoleInAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed) { |
| 564 |
if (neighbourRoleSetLabel) { |
| 565 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = neighbourRoleSetLabel->getTagCacheValueHash(false); |
| 566 |
if (labelValueHash) { |
| 567 |
cint64 tag = role->getRoleTag(); |
| 568 |
if (inversed) { |
| 569 |
tag = -tag; |
| 570 |
} |
| 571 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(tag); |
| 572 |
if (labelLinker) { |
| 573 |
return true; |
| 574 |
} |
| 575 |
} |
| 576 |
} |
| 577 |
return false; |
| 578 |
} |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
bool CBackendRepresentativeMemoryCacheReader::hasIndividualIdsInAssociatedIndividualSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* indiSetLabel, cint64 indiId) { |
| 584 |
if (indiSetLabel) { |
| 585 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = indiSetLabel->getTagCacheValueHash(false); |
| 586 |
if (labelValueHash) { |
| 587 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(indiId); |
| 588 |
if (labelLinker) { |
| 589 |
return true; |
| 590 |
} |
| 591 |
} |
| 592 |
} |
| 593 |
return false; |
| 594 |
} |
| 595 |
|
| 596 |
|
| 597 |
bool CBackendRepresentativeMemoryCacheReader::hasRoleInAssociatedCompinationRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* compinationRoleSetLabel, CRole* role, bool inversed) { |
| 598 |
if (compinationRoleSetLabel) { |
| 599 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = compinationRoleSetLabel->getTagCacheValueHash(false); |
| 600 |
if (labelValueHash) { |
| 601 |
cint64 tag = role->getRoleTag(); |
| 602 |
if (inversed) { |
| 603 |
tag = -tag; |
| 604 |
} |
| 605 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(tag); |
| 606 |
if (labelLinker) { |
| 607 |
return true; |
| 608 |
} |
| 609 |
} |
| 610 |
} |
| 611 |
return false; |
| 612 |
} |
| 613 |
|
| 614 |
|
| 615 |
bool CBackendRepresentativeMemoryCacheReader::hasRoleInAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed, bool nondeterministic) { |
| 616 |
if (neighbourRoleSetLabel) { |
| 617 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = neighbourRoleSetLabel->getTagCacheValueHash(false); |
| 618 |
if (labelValueHash) { |
| 619 |
cint64 tag = role->getRoleTag(); |
| 620 |
if (inversed) { |
| 621 |
tag = -tag; |
| 622 |
} |
| 623 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(tag); |
| 624 |
if (labelLinker) { |
| 625 |
CCacheValue::CACHEVALUEIDENTIFIER identifier = labelLinker->getCacheValue().getCacheValueIdentifier(); |
| 626 |
bool nondeterministcCached = identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_ROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_ASSERTEDROLE || |
| 627 |
identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSEDASSERTEDROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_NOMINAL_CONNECTED_ROLE || identifier == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_INVERSED_NOMINAL_CONNECTED_ROLE; |
| 628 |
|
| 629 |
return nondeterministcCached == nondeterministic; |
| 630 |
} |
| 631 |
} |
| 632 |
} |
| 633 |
return false; |
| 634 |
} |
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
bool CBackendRepresentativeMemoryCacheReaderhasRoleInAssociatedCombinedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed) { |
| 640 |
if (neighbourRoleSetLabel) { |
| 641 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = neighbourRoleSetLabel->getTagCacheValueHash(false); |
| 642 |
if (labelValueHash) { |
| 643 |
cint64 tag = role->getRoleTag(); |
| 644 |
if (inversed) { |
| 645 |
tag = -tag; |
| 646 |
} |
| 647 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(tag); |
| 648 |
if (labelLinker) { |
| 649 |
return true; |
| 650 |
} |
| 651 |
} |
| 652 |
} |
| 653 |
return false; |
| 654 |
} |
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
bool CBackendRepresentativeMemoryCacheReader::visitRolesOfAssociatedCompinationRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* combinationRoleSetLabel, function<bool(CRole* role, bool inversed)> visitFunc) { |
| 660 |
if (combinationRoleSetLabel) { |
| 661 |
CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinker = combinationRoleSetLabel->getCacheValueLinker(); |
| 662 |
|
| 663 |
if (lablelValueLinker) { |
| 664 |
bool continueVisiting = true; |
| 665 |
for (CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinkerIt = lablelValueLinker; lablelValueLinkerIt && continueVisiting; lablelValueLinkerIt = lablelValueLinkerIt->getNext()) { |
| 666 |
const CCacheValue& cacheValue = lablelValueLinkerIt->getCacheValue(); |
| 667 |
|
| 668 |
CRole* role = (CRole*)cacheValue.getIdentification(); |
| 669 |
bool roleInversed = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDINVERSEDROLE; |
| 670 |
continueVisiting = visitFunc(role, roleInversed); |
| 671 |
} |
| 672 |
return true; |
| 673 |
} |
| 674 |
} |
| 675 |
return false; |
| 676 |
} |
| 677 |
|
| 678 |
|
| 679 |
bool CBackendRepresentativeMemoryCacheReader::visitRolesOfAssociatedCombinedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, function<bool(CRole* role, bool inversed)> visitFunc) { |
| 680 |
if (neighbourRoleSetLabel) { |
| 681 |
CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinker = neighbourRoleSetLabel->getCacheValueLinker(); |
| 682 |
|
| 683 |
if (lablelValueLinker) { |
| 684 |
bool continueVisiting = true; |
| 685 |
for (CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinkerIt = lablelValueLinker; lablelValueLinkerIt && continueVisiting; lablelValueLinkerIt = lablelValueLinkerIt->getNext()) { |
| 686 |
const CCacheValue& cacheValue = lablelValueLinkerIt->getCacheValue(); |
| 687 |
|
| 688 |
CRole* role = (CRole*)cacheValue.getIdentification(); |
| 689 |
bool roleInversed = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDINVERSEDROLE || cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDINVERSEDASSERTEDROLE || cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDINVERSED_NOMINAL_CONNECTED_ROLE; |
| 690 |
continueVisiting = visitFunc(role, roleInversed); |
| 691 |
} |
| 692 |
return true; |
| 693 |
} |
| 694 |
} |
| 695 |
return false; |
| 696 |
} |
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
bool CBackendRepresentativeMemoryCacheReader::hasRoleInAssociatedCombinedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed) { |
| 702 |
if (neighbourRoleSetLabel) { |
| 703 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = neighbourRoleSetLabel->getTagCacheValueHash(false); |
| 704 |
|
| 705 |
if (labelValueHash) { |
| 706 |
cint64 tag = role->getRoleTag(); |
| 707 |
if (inversed) { |
| 708 |
tag = -tag; |
| 709 |
} |
| 710 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(tag); |
| 711 |
if (labelLinker && getCacheValue(role, inversed) == labelLinker->getCacheValue()) { |
| 712 |
return true; |
| 713 |
} |
| 714 |
} |
| 715 |
} |
| 716 |
return false; |
| 717 |
} |
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
bool CBackendRepresentativeMemoryCacheReader::hasRoleToNeigbourInAssociatedNeighbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 neighbourIndiId, CRole* role, bool inversed) { |
| 722 |
CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* neighbourRoleSetHash = assData->getNeighbourRoleSetHash(); |
| 723 |
if (neighbourRoleSetHash) { |
| 724 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel = neighbourRoleSetHash->getNeighbourRoleSetLabel(neighbourIndiId); |
| 725 |
if (neighbourRoleSetLabel) { |
| 726 |
return hasRoleInAssociatedNeigbourRoleSetLabel(assData, neighbourRoleSetLabel, role, inversed); |
| 727 |
} |
| 728 |
} |
| 729 |
return false; |
| 730 |
} |
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
bool CBackendRepresentativeMemoryCacheReader::visitRolesToNeigbourInAssociatedNeighbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 neighbourIndiId, function<bool(CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)> visitFunc) { |
| 735 |
if (assData) { |
| 736 |
CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* neighbourRoleSetHash = assData->getNeighbourRoleSetHash(); |
| 737 |
if (neighbourRoleSetHash) { |
| 738 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel = neighbourRoleSetHash->getNeighbourRoleSetLabel(neighbourIndiId); |
| 739 |
if (neighbourRoleSetLabel) { |
| 740 |
return visitRolesOfAssociatedNeigbourRoleSetLabel(assData, neighbourRoleSetLabel, visitFunc); |
| 741 |
} |
| 742 |
} |
| 743 |
} |
| 744 |
return false; |
| 745 |
} |
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
bool CBackendRepresentativeMemoryCacheReader::visitNominalIndirectlyConnectedIndividualIds(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData* nomConnData, function<bool(cint64 indiId)> visitFunc) { |
| 750 |
if (nomConnData) { |
| 751 |
CXLinker<cint64>* linker = nomConnData->getIndirectlyConnectedIndividualIdLinker(); |
| 752 |
if (linker) { |
| 753 |
bool continueVisiting = true; |
| 754 |
for (CXLinker<cint64>* connIndiIdIt = linker; connIndiIdIt && continueVisiting; connIndiIdIt = connIndiIdIt->getNext()) { |
| 755 |
cint64 indirectlyConnectedIndiId = connIndiIdIt->getData(); |
| 756 |
// TODO: these individuals are only candidates, check whether they are still valid |
| 757 |
continueVisiting = visitFunc(indirectlyConnectedIndiId); |
| 758 |
} |
| 759 |
return true; |
| 760 |
} |
| 761 |
} |
| 762 |
return false; |
| 763 |
} |
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
bool CBackendRepresentativeMemoryCacheReader::visitIndividualIdsOfAssociatedIndividualSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* indiSetLabel, function<bool(cint64 indiId)> visitFunc) { |
| 768 |
if (indiSetLabel) { |
| 769 |
CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinker = indiSetLabel->getCacheValueLinker(); |
| 770 |
|
| 771 |
if (lablelValueLinker) { |
| 772 |
bool continueVisiting = true; |
| 773 |
for (CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinkerIt = lablelValueLinker; lablelValueLinkerIt && continueVisiting; lablelValueLinkerIt = lablelValueLinkerIt->getNext()) { |
| 774 |
const CCacheValue& cacheValue = lablelValueLinkerIt->getCacheValue(); |
| 775 |
|
| 776 |
cint64 indiId = cacheValue.getTag(); |
| 777 |
continueVisiting = visitFunc(indiId); |
| 778 |
} |
| 779 |
return true; |
| 780 |
} |
| 781 |
} |
| 782 |
return false; |
| 783 |
} |
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
bool CBackendRepresentativeMemoryCacheReader::visitConceptsOfAssociatedDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, function<bool(CConcept*, bool)> visitFunc) { |
| 788 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = assData->getDeterministicConceptSetLabelCacheEntry(); |
| 789 |
return visitConceptsOfAssociatedConceptSetLabel(assData, labelItem, visitFunc); |
| 790 |
} |
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
bool CBackendRepresentativeMemoryCacheReader::hasConceptInAssociatedDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CConcept* concept, bool negation) { |
| 795 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = assData->getDeterministicConceptSetLabelCacheEntry(); |
| 796 |
return hasConceptInAssociatedConceptSetLabel(assData, labelItem, concept, negation); |
| 797 |
} |
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
bool CBackendRepresentativeMemoryCacheReader::visitConceptsOfAssociatedNonDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, function<bool(CConcept*, bool)> visitFunc) { |
| 802 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_CONCEPT_SET_LABEL); |
| 803 |
return visitConceptsOfAssociatedConceptSetLabel(assData, labelItem, visitFunc); |
| 804 |
} |
| 805 |
|
| 806 |
|
| 807 |
bool CBackendRepresentativeMemoryCacheReader::hasConceptInAssociatedNonDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CConcept* concept, bool negation) { |
| 808 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_CONCEPT_SET_LABEL); |
| 809 |
return hasConceptInAssociatedConceptSetLabel(assData, labelItem, concept, negation); |
| 810 |
} |
| 811 |
|
| 812 |
bool CBackendRepresentativeMemoryCacheReader::visitConceptsOfAssociatedConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, function<bool(CConcept*, bool)> visitFunc) { |
| 813 |
CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinker = labelItem->getCacheValueLinker(); |
| 814 |
|
| 815 |
if (lablelValueLinker) { |
| 816 |
bool continueVisiting = true; |
| 817 |
for (CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinkerIt = lablelValueLinker; lablelValueLinkerIt && continueVisiting; lablelValueLinkerIt = lablelValueLinkerIt->getNext()) { |
| 818 |
const CCacheValue& cacheValue = lablelValueLinkerIt->getCacheValue(); |
| 819 |
|
| 820 |
CConcept* concept = (CConcept*)cacheValue.getIdentification(); |
| 821 |
bool conceptNegation = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDNEGATEDCONCEPT; |
| 822 |
continueVisiting = visitFunc(concept, conceptNegation); |
| 823 |
} |
| 824 |
return true; |
| 825 |
} |
| 826 |
return false; |
| 827 |
} |
| 828 |
|
| 829 |
|
| 830 |
bool CBackendRepresentativeMemoryCacheReader::hasConceptInAssociatedConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, CConcept* concept, bool negation) { |
| 831 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = labelItem->getTagCacheValueHash(false); |
| 832 |
|
| 833 |
if (labelValueHash) { |
| 834 |
cint64 tag = concept->getConceptTag(); |
| 835 |
if (negation) { |
| 836 |
tag = -tag; |
| 837 |
} |
| 838 |
|
| 839 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(tag); |
| 840 |
if (labelLinker && getCacheValue(concept, negation) == labelLinker->getCacheValue()) { |
| 841 |
return true; |
| 842 |
} |
| 843 |
} |
| 844 |
return false; |
| 845 |
} |
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
bool CBackendRepresentativeMemoryCacheReader::visitLabelItemIndividualIdAssociations(CBackendRepresentativeMemoryLabelCacheItem* labelItem, function<bool(cint64 indiId, bool sameIndividualMerged)> visitFunc, bool ascending, bool visitBaseIndividual, bool visitSameMergedIndividuals) { |
| 855 |
CBackendRepresentativeMemoryLabelCacheItemIndividualAssociationMapExtensionData* indiAssMapExtensionData = (CBackendRepresentativeMemoryLabelCacheItemIndividualAssociationMapExtensionData*)labelItem->getExtensionData(CBackendRepresentativeMemoryLabelCacheItemIndividualAssociationMapExtensionData::INDIVIDUAL_ASSOCIATION_MAP); |
| 856 |
if (indiAssMapExtensionData) { |
| 857 |
return indiAssMapExtensionData->visitIndividualIdAssociations(visitFunc, ascending, visitBaseIndividual, visitSameMergedIndividuals); |
| 858 |
} |
| 859 |
return false; |
| 860 |
} |
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
bool CBackendRepresentativeMemoryCacheReader::visitConceptsOfAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, function<bool(CConcept* concept, bool negation, bool deterministic)> visitFunc, bool visitDeterministicConcepts, bool visitNonDeterministicConcepts) { |
| 866 |
return visitConceptsOfFullConceptSetLabel(labelItem, visitFunc, visitDeterministicConcepts, visitNonDeterministicConcepts); |
| 867 |
} |
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
bool CBackendRepresentativeMemoryCacheReader::visitConceptsOfFullConceptSetLabel(CBackendRepresentativeMemoryLabelCacheItem* labelItem, function<bool(CConcept* concept, bool negation, bool deterministic)> visitFunc, bool visitDeterministicConcepts, bool visitNonDeterministicConcepts) { |
| 873 |
if (labelItem) { |
| 874 |
CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinker = labelItem->getCacheValueLinker(); |
| 875 |
|
| 876 |
if (lablelValueLinker) { |
| 877 |
bool continueVisiting = true; |
| 878 |
for (CBackendRepresentativeMemoryLabelValueLinker* lablelValueLinkerIt = lablelValueLinker; lablelValueLinkerIt && continueVisiting; lablelValueLinkerIt = lablelValueLinkerIt->getNext()) { |
| 879 |
const CCacheValue& cacheValue = lablelValueLinkerIt->getCacheValue(); |
| 880 |
|
| 881 |
CConcept* concept = (CConcept*)cacheValue.getIdentification(); |
| 882 |
bool conceptNegation = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDNEGATEDCONCEPT || cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGAND_NONDETERMINISTIC_NEGATED_CONCEPT; |
| 883 |
bool deterministic = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDNEGATEDCONCEPT || cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDCONCEPT; |
| 884 |
if (deterministic && visitDeterministicConcepts || !deterministic && visitNonDeterministicConcepts) { |
| 885 |
continueVisiting = visitFunc(concept, conceptNegation, deterministic); |
| 886 |
} |
| 887 |
} |
| 888 |
return true; |
| 889 |
} |
| 890 |
} |
| 891 |
return false; |
| 892 |
} |
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
bool CBackendRepresentativeMemoryCacheReader::getConceptOccurrenceInAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, CConcept* concept, bool& negationFlag, bool& deterministicFlag) { |
| 898 |
if (labelItem) { |
| 899 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = labelItem->getTagCacheValueHash(false); |
| 900 |
cint64 tag = concept->getConceptTag(); |
| 901 |
if (labelValueHash) { |
| 902 |
|
| 903 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(tag); |
| 904 |
if (!labelLinker) { |
| 905 |
labelLinker = labelValueHash->value(-tag); |
| 906 |
if (labelLinker) { |
| 907 |
negationFlag = true; |
| 908 |
} |
| 909 |
} else { |
| 910 |
negationFlag = false; |
| 911 |
} |
| 912 |
|
| 913 |
if (labelLinker) { |
| 914 |
|
| 915 |
const CCacheValue& cacheValue = labelLinker->getCacheValue(); |
| 916 |
CConcept* concept = (CConcept*)cacheValue.getIdentification(); |
| 917 |
bool deterministicFlag = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDNEGATEDCONCEPT || cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDCONCEPT; |
| 918 |
|
| 919 |
return true; |
| 920 |
} |
| 921 |
} |
| 922 |
} |
| 923 |
return false; |
| 924 |
} |
| 925 |
|
| 926 |
|
| 927 |
bool CBackendRepresentativeMemoryCacheReader::hasConceptInAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, CConcept* concept, bool negation) { |
| 928 |
if (labelItem) { |
| 929 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = labelItem->getTagCacheValueHash(false); |
| 930 |
if (labelValueHash) { |
| 931 |
cint64 tag = concept->getConceptTag(); |
| 932 |
if (negation) { |
| 933 |
tag = -tag; |
| 934 |
} |
| 935 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(tag); |
| 936 |
if (labelLinker) { |
| 937 |
return true; |
| 938 |
} |
| 939 |
} |
| 940 |
} |
| 941 |
return false; |
| 942 |
} |
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
bool CBackendRepresentativeMemoryCacheReader::hasConceptInAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, CConcept* concept, bool negation, bool deterministic) { |
| 948 |
if (labelItem) { |
| 949 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* labelValueHash = labelItem->getTagCacheValueHash(false); |
| 950 |
if (labelValueHash) { |
| 951 |
cint64 tag = concept->getConceptTag(); |
| 952 |
if (negation) { |
| 953 |
tag = -tag; |
| 954 |
} |
| 955 |
CBackendRepresentativeMemoryLabelValueLinker* labelLinker = labelValueHash->value(tag); |
| 956 |
if (labelLinker && getCacheValue(concept, negation, deterministic) == labelLinker->getCacheValue()) { |
| 957 |
return true; |
| 958 |
} |
| 959 |
} |
| 960 |
} |
| 961 |
return false; |
| 962 |
} |
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getLabelCacheEntryViaProvidedCacheValues(cint64 labelType, cint64 signature, cint64 count, function<bool(bool, cint64&, CCacheValue&)> provFunc) { |
| 980 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = nullptr; |
| 981 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* sigResEntry = getLabelCacheEntry(labelType, signature); |
| 982 |
if (sigResEntry) { |
| 983 |
for (CBackendRepresentativeMemoryLabelCacheItem* itemIt = sigResEntry->getLabelItems(); itemIt && !labelItem; itemIt = itemIt->getNext()) { |
| 984 |
if (itemIt->getCacheValueCount() == count) { |
| 985 |
bool compatible = true; |
| 986 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* cacheValueHash = itemIt->getTagCacheValueHash(false); |
| 987 |
CCacheValue cacheValue; |
| 988 |
cint64 tag; |
| 989 |
bool resetProviding = true; |
| 990 |
while (compatible) { |
| 991 |
if (!provFunc(resetProviding, tag, cacheValue)) { |
| 992 |
break; |
| 993 |
} |
| 994 |
resetProviding = false; |
| 995 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = cacheValueHash->value(tag); |
| 996 |
if (!labelValueLinker || labelValueLinker->getCacheValue() != cacheValue) { |
| 997 |
compatible = false; |
| 998 |
} |
| 999 |
} |
| 1000 |
if (compatible) { |
| 1001 |
labelItem = itemIt; |
| 1002 |
} |
| 1003 |
} |
| 1004 |
} |
| 1005 |
} |
| 1006 |
return labelItem; |
| 1007 |
} |
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getLabelCacheEntryViaRoleLinker(cint64 labelType, cint64 signature, cint64 count, CSortedNegLinker<CRole*>* roleLinker, bool inversed, CRole* assertedRole) { |
| 1014 |
CSortedNegLinker<CRole*>* roleLinkerIt = roleLinker; |
| 1015 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = getLabelCacheEntryViaProvidedCacheValues(labelType, signature, count, [&](bool resetProviding, cint64& tag, CCacheValue& cacheValue)->bool { |
| 1016 |
if (resetProviding) { |
| 1017 |
roleLinkerIt = roleLinker; |
| 1018 |
} |
| 1019 |
if (!roleLinkerIt) { |
| 1020 |
return false; |
| 1021 |
} |
| 1022 |
CRole* role = roleLinkerIt->getData(); |
| 1023 |
bool roleInversion = roleLinkerIt->isNegated() ^ inversed; |
| 1024 |
bool assertionLinkBase = role == assertedRole && roleInversion == inversed; |
| 1025 |
cacheValue = getCacheValue(role, roleInversion, assertionLinkBase, false); |
| 1026 |
tag = cacheValue.getTag(); |
| 1027 |
roleLinkerIt = roleLinkerIt->getNext(); |
| 1028 |
return true; |
| 1029 |
}); |
| 1030 |
return labelItem; |
| 1031 |
} |
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getLabelCacheEntryViaRoleAssertionLinker(cint64 labelType, cint64 signature, cint64 count, CBackendRepresentativeMemoryCacheRoleAssertionLinker* roleAssertionLinker) { |
| 1036 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker* roleAssertionLinkerIt = roleAssertionLinker; |
| 1037 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = getLabelCacheEntryViaProvidedCacheValues(labelType, signature, count, [&](bool resetProviding, cint64& tag, CCacheValue& cacheValue)->bool { |
| 1038 |
if (resetProviding) { |
| 1039 |
roleAssertionLinkerIt = roleAssertionLinker; |
| 1040 |
} |
| 1041 |
if (!roleAssertionLinkerIt) { |
| 1042 |
return false; |
| 1043 |
} |
| 1044 |
CRole* role = roleAssertionLinkerIt->getData(); |
| 1045 |
bool roleInversion = roleAssertionLinkerIt->isNegated(); |
| 1046 |
bool assertionLinkBase = roleAssertionLinkerIt->isABoxAsserted(); |
| 1047 |
bool nominalConnected = roleAssertionLinkerIt->isNominalConnected(); |
| 1048 |
bool nondeterministic = roleAssertionLinkerIt->isNondeterministic(); |
| 1049 |
cacheValue = getCacheValue(role, roleInversion, assertionLinkBase, nominalConnected, nondeterministic); |
| 1050 |
tag = cacheValue.getTag(); |
| 1051 |
roleAssertionLinkerIt = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)roleAssertionLinkerIt->getNext(); |
| 1052 |
return true; |
| 1053 |
}); |
| 1054 |
return labelItem; |
| 1055 |
} |
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
const CCacheValue CBackendRepresentativeMemoryCacheReader::getCacheValue(CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker* neigbourRoleInstantiatedSetTmpLabelLinker) { |
| 1063 |
CBackendRepresentativeMemoryLabelCacheItem* labelCacheItem = neigbourRoleInstantiatedSetTmpLabelLinker->getReferredLabelData(); |
| 1064 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* tmpLabelWriteData = neigbourRoleInstantiatedSetTmpLabelLinker->getReferredTemporaryLabelData(); |
| 1065 |
|
| 1066 |
cint64 tag = 0; |
| 1067 |
CCacheValue::CACHEVALUEIDENTIFIER cacheValueIdentifier = CCacheValue::CACHE_VALUE_TAG_AND_ENTRY; |
| 1068 |
cint64 value = (cint64)labelCacheItem; |
| 1069 |
if (tmpLabelWriteData) { |
| 1070 |
cacheValueIdentifier = CCacheValue::CACHE_VALUE_TAG_AND_TEMPORARY_ENTRY; |
| 1071 |
value = (cint64)tmpLabelWriteData; |
| 1072 |
} else { |
| 1073 |
tag = labelCacheItem->getCacheEntryID(); |
| 1074 |
} |
| 1075 |
CCacheValue cacheValue; |
| 1076 |
cacheValue.initCacheValue(tag, (cint64)value, cacheValueIdentifier); |
| 1077 |
|
| 1078 |
return cacheValue; |
| 1079 |
} |
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getNeighbourRoleInstantiatedSetCompinationLabelCacheEntry(cint64 signature, cint64 count, CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker* neigbourRoleInstantiatedSetTmpLabelLinker) { |
| 1084 |
CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker* neigbourRoleInstantiatedSetTmpLabelLinkerIt = neigbourRoleInstantiatedSetTmpLabelLinker; |
| 1085 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = getLabelCacheEntryViaProvidedCacheValues(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL, signature, count, [&](bool resetProviding, cint64& tag, CCacheValue& cacheValue)->bool { |
| 1086 |
if (resetProviding) { |
| 1087 |
neigbourRoleInstantiatedSetTmpLabelLinkerIt = neigbourRoleInstantiatedSetTmpLabelLinker; |
| 1088 |
} |
| 1089 |
if (!neigbourRoleInstantiatedSetTmpLabelLinkerIt) { |
| 1090 |
return false; |
| 1091 |
} |
| 1092 |
cacheValue = getCacheValue(neigbourRoleInstantiatedSetTmpLabelLinkerIt); |
| 1093 |
tag = (cint64)cacheValue.getTag(); |
| 1094 |
|
| 1095 |
neigbourRoleInstantiatedSetTmpLabelLinkerIt = (CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker*)neigbourRoleInstantiatedSetTmpLabelLinkerIt->getNext(); |
| 1096 |
return true; |
| 1097 |
}); |
| 1098 |
return labelItem; |
| 1099 |
} |
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getConceptSetLabelCacheEntry(cint64 labelType, cint64 signature, cint64 conCount, CConceptSaturationDescriptor* conDesLinker) { |
| 1106 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = nullptr; |
| 1107 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* sigResEntry = getLabelCacheEntry(labelType, signature); |
| 1108 |
if (sigResEntry) { |
| 1109 |
for (CBackendRepresentativeMemoryLabelCacheItem* itemIt = sigResEntry->getLabelItems(); itemIt && !labelItem; itemIt = itemIt->getNext()) { |
| 1110 |
if (itemIt->getCacheValueCount() == conCount) { |
| 1111 |
bool compatible = true; |
| 1112 |
CCACHINGHASH<cint64,CBackendRepresentativeMemoryLabelValueLinker*>* cacheValueHash = itemIt->getTagCacheValueHash(false); |
| 1113 |
for (CConceptSaturationDescriptor* conDesIt = conDesLinker; conDesIt && compatible; conDesIt = conDesIt->getNext()) { |
| 1114 |
cint64 conTag = conDesIt->getConceptTag(); |
| 1115 |
CConcept* concept = conDesIt->getConcept(); |
| 1116 |
bool negation = conDesIt->isNegated(); |
| 1117 |
if (negation) { |
| 1118 |
conTag = -conTag; |
| 1119 |
} |
| 1120 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = cacheValueHash->value(conTag); |
| 1121 |
if (!labelValueLinker || labelValueLinker->getCacheValue() != getCacheValue(concept,negation)) { |
| 1122 |
compatible = false; |
| 1123 |
} |
| 1124 |
} |
| 1125 |
if (compatible) { |
| 1126 |
labelItem = itemIt; |
| 1127 |
} |
| 1128 |
} |
| 1129 |
} |
| 1130 |
} |
| 1131 |
return labelItem; |
| 1132 |
} |
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getDeterministicConceptSetLabelCacheEntry(cint64 signature, cint64 conCount, CConceptDescriptor* conDesLinker, cint64 maxDeterministicBranchTag, bool excludePositiveNominalConcepts) { |
| 1137 |
return getConceptSetLabelCacheEntry(signature, conCount, conDesLinker, true, maxDeterministicBranchTag, excludePositiveNominalConcepts); |
| 1138 |
} |
| 1139 |
|
| 1140 |
|
| 1141 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getNondeterministicConceptSetLabelCacheEntry(cint64 signature, cint64 conCount, CConceptDescriptor* conDesLinker, cint64 maxDeterministicBranchTag, bool excludePositiveNominalConcepts) { |
| 1142 |
return getConceptSetLabelCacheEntry(signature, conCount, conDesLinker, false, maxDeterministicBranchTag, excludePositiveNominalConcepts); |
| 1143 |
} |
| 1144 |
|
| 1145 |
|
| 1146 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getConceptSetLabelCacheEntry(cint64 signature, cint64 conCount, CConceptDescriptor* conDesLinker, bool deterministic, cint64 maxDeterministicBranchTag, bool excludePositiveNominalConcepts) { |
| 1147 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = nullptr; |
| 1148 |
cint64 labelType = CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_CONCEPT_SET_LABEL; |
| 1149 |
if (!deterministic) { |
| 1150 |
labelType = CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_CONCEPT_SET_LABEL; |
| 1151 |
} |
| 1152 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* sigResEntry = getLabelCacheEntry(labelType, signature); |
| 1153 |
if (sigResEntry) { |
| 1154 |
for (CBackendRepresentativeMemoryLabelCacheItem* itemIt = sigResEntry->getLabelItems(); itemIt && !labelItem; itemIt = itemIt->getNext()) { |
| 1155 |
if (itemIt->getCacheValueCount() == conCount) { |
| 1156 |
bool compatible = true; |
| 1157 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* cacheValueHash = itemIt->getTagCacheValueHash(false); |
| 1158 |
for (CConceptDescriptor* conDesIt = conDesLinker; conDesIt && compatible; conDesIt = conDesIt->getNext()) { |
| 1159 |
cint64 conTag = conDesIt->getConceptTag(); |
| 1160 |
CConcept* concept = conDesIt->getConcept(); |
| 1161 |
bool negation = conDesIt->isNegated(); |
| 1162 |
if (negation) { |
| 1163 |
conTag = -conTag; |
| 1164 |
} |
| 1165 |
bool deterministicallyDerived = true; |
| 1166 |
if (!conDesIt->getDependencyTrackPoint() || conDesIt->getDependencyTrackPoint()->getBranchingTag() > maxDeterministicBranchTag) { |
| 1167 |
deterministicallyDerived = false; |
| 1168 |
} |
| 1169 |
bool considerConcept = deterministicallyDerived == deterministic; |
| 1170 |
if (excludePositiveNominalConcepts && concept->getOperatorCode() == CCNOMINAL && !negation) { |
| 1171 |
considerConcept = false; |
| 1172 |
} |
| 1173 |
if (considerConcept) { |
| 1174 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = cacheValueHash->value(conTag); |
| 1175 |
if (!labelValueLinker || labelValueLinker->getCacheValue() != getCacheValue(concept, negation)) { |
| 1176 |
compatible = false; |
| 1177 |
} |
| 1178 |
} |
| 1179 |
} |
| 1180 |
if (compatible) { |
| 1181 |
labelItem = itemIt; |
| 1182 |
} |
| 1183 |
} |
| 1184 |
} |
| 1185 |
} |
| 1186 |
return labelItem; |
| 1187 |
} |
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
|
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getFullConceptSetLabelCacheEntry(cint64 labelType, cint64 signature, cint64 conCount, CConceptDescriptor* conDesLinker, function<bool(CConcept* concept, bool negation)> exclusionDetermineFunction, function<bool(CConcept* concept, bool negation, CDependencyTrackPoint* depTrackPoint)> nondeterministicDetermineFunction) { |
| 1207 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = nullptr; |
| 1208 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* sigResEntry = getLabelCacheEntry(labelType, signature); |
| 1209 |
if (sigResEntry) { |
| 1210 |
for (CBackendRepresentativeMemoryLabelCacheItem* itemIt = sigResEntry->getLabelItems(); itemIt && !labelItem; itemIt = itemIt->getNext()) { |
| 1211 |
if (itemIt->getCacheValueCount() == conCount) { |
| 1212 |
bool compatible = true; |
| 1213 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* cacheValueHash = itemIt->getTagCacheValueHash(false); |
| 1214 |
for (CConceptDescriptor* conDesIt = conDesLinker; conDesIt && compatible; conDesIt = conDesIt->getNext()) { |
| 1215 |
cint64 conTag = conDesIt->getConceptTag(); |
| 1216 |
CConcept* concept = conDesIt->getConcept(); |
| 1217 |
bool negation = conDesIt->isNegated(); |
| 1218 |
if (negation) { |
| 1219 |
conTag = -conTag; |
| 1220 |
} |
| 1221 |
bool considerConcept = exclusionDetermineFunction(concept, negation); |
| 1222 |
if (considerConcept) { |
| 1223 |
bool deterministicConcept = nondeterministicDetermineFunction(concept, negation, conDesIt->getDependencyTrackPoint()); |
| 1224 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = cacheValueHash->value(conTag); |
| 1225 |
if (!labelValueLinker || labelValueLinker->getCacheValue() != getCacheValue(concept, negation, deterministicConcept)) { |
| 1226 |
compatible = false; |
| 1227 |
} |
| 1228 |
} |
| 1229 |
} |
| 1230 |
if (compatible) { |
| 1231 |
labelItem = itemIt; |
| 1232 |
} |
| 1233 |
} |
| 1234 |
} |
| 1235 |
} |
| 1236 |
return labelItem; |
| 1237 |
} |
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getConceptSetLabelCacheEntry(cint64 labelType, cint64 signature, cint64 conCount, CConceptDescriptor* conDesLinker, function<bool(CConcept* concept, bool negation)> exclusionDetermineFunction) { |
| 1245 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = nullptr; |
| 1246 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* sigResEntry = getLabelCacheEntry(labelType, signature); |
| 1247 |
if (sigResEntry) { |
| 1248 |
for (CBackendRepresentativeMemoryLabelCacheItem* itemIt = sigResEntry->getLabelItems(); itemIt && !labelItem; itemIt = itemIt->getNext()) { |
| 1249 |
if (itemIt->getCacheValueCount() == conCount) { |
| 1250 |
bool compatible = true; |
| 1251 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* cacheValueHash = itemIt->getTagCacheValueHash(false); |
| 1252 |
for (CConceptDescriptor* conDesIt = conDesLinker; conDesIt && compatible; conDesIt = conDesIt->getNext()) { |
| 1253 |
cint64 conTag = conDesIt->getConceptTag(); |
| 1254 |
CConcept* concept = conDesIt->getConcept(); |
| 1255 |
bool negation = conDesIt->isNegated(); |
| 1256 |
if (negation) { |
| 1257 |
conTag = -conTag; |
| 1258 |
} |
| 1259 |
bool considerConcept = exclusionDetermineFunction(concept, negation); |
| 1260 |
if (considerConcept) { |
| 1261 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = cacheValueHash->value(conTag); |
| 1262 |
if (!labelValueLinker || labelValueLinker->getCacheValue() != getCacheValue(concept, negation)) { |
| 1263 |
compatible = false; |
| 1264 |
} |
| 1265 |
} |
| 1266 |
} |
| 1267 |
if (compatible) { |
| 1268 |
labelItem = itemIt; |
| 1269 |
} |
| 1270 |
} |
| 1271 |
} |
| 1272 |
} |
| 1273 |
return labelItem; |
| 1274 |
} |
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getIndividualSetLabelCacheEntry(cint64 labelType, cint64 signature, cint64 indiId, CDistinctHash* indiDistinctHash, cint64& count, bool onlyDeterministic, cint64 maxDeterministicBranchTag) { |
| 1284 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = nullptr; |
| 1285 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* sigResEntry = getLabelCacheEntry(labelType, signature); |
| 1286 |
if (sigResEntry) { |
| 1287 |
for (CBackendRepresentativeMemoryLabelCacheItem* itemIt = sigResEntry->getLabelItems(); itemIt && !labelItem; itemIt = itemIt->getNext()) { |
| 1288 |
if (itemIt->getCacheValueCount() == count) { |
| 1289 |
bool compatible = true; |
| 1290 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* cacheValueHash = itemIt->getTagCacheValueHash(false); |
| 1291 |
for (CDistinctHash::const_iterator it = indiDistinctHash->constBegin(), itEnd = indiDistinctHash->constEnd(); it != itEnd; ++it) { |
| 1292 |
cint64 distinctIndiId = -it.key(); |
| 1293 |
if (distinctIndiId >= 0 && distinctIndiId != indiId) { |
| 1294 |
CDistinctEdge* distinctEdge = it.value(); |
| 1295 |
bool deterministicallyDerived = true; |
| 1296 |
if (!distinctEdge->getDependencyTrackPoint() || distinctEdge->getDependencyTrackPoint()->getBranchingTag() > maxDeterministicBranchTag) { |
| 1297 |
deterministicallyDerived = false; |
| 1298 |
} |
| 1299 |
bool considerIndividual = deterministicallyDerived || !onlyDeterministic; |
| 1300 |
if (considerIndividual) { |
| 1301 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = cacheValueHash->value(distinctIndiId); |
| 1302 |
if (!labelValueLinker || labelValueLinker->getCacheValue() != getCacheValue(distinctIndiId, false)) { |
| 1303 |
compatible = false; |
| 1304 |
} |
| 1305 |
} |
| 1306 |
} |
| 1307 |
} |
| 1308 |
if (compatible && indiId >= 0) { |
| 1309 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = cacheValueHash->value(indiId); |
| 1310 |
if (!labelValueLinker || labelValueLinker->getCacheValue() != getCacheValue(indiId, false)) { |
| 1311 |
compatible = false; |
| 1312 |
} |
| 1313 |
} |
| 1314 |
if (compatible) { |
| 1315 |
labelItem = itemIt; |
| 1316 |
} |
| 1317 |
} |
| 1318 |
} |
| 1319 |
} |
| 1320 |
return labelItem; |
| 1321 |
} |
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getIndividualSetLabelCacheEntry(cint64 labelType, cint64 signature, cint64 indiId, CIndividualMergingHash* indiMerginghash, cint64& count, bool onlyDeterministic, cint64 maxDeterministicBranchTag) { |
| 1329 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = nullptr; |
| 1330 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* sigResEntry = getLabelCacheEntry(labelType, signature); |
| 1331 |
if (sigResEntry) { |
| 1332 |
for (CBackendRepresentativeMemoryLabelCacheItem* itemIt = sigResEntry->getLabelItems(); itemIt && !labelItem; itemIt = itemIt->getNext()) { |
| 1333 |
if (itemIt->getCacheValueCount() == count) { |
| 1334 |
bool compatible = true; |
| 1335 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* cacheValueHash = itemIt->getTagCacheValueHash(false); |
| 1336 |
for (CIndividualMergingHash::const_iterator it = indiMerginghash->constBegin(), itEnd = indiMerginghash->constEnd(); it != itEnd; ++it) { |
| 1337 |
if (it.value().isMergedWithIndividual()) { |
| 1338 |
cint64 mergedIndiId = it.key(); |
| 1339 |
if (mergedIndiId != indiId) { |
| 1340 |
CIndividualMergingHashData mergedData = it.value(); |
| 1341 |
bool deterministicallyDerived = true; |
| 1342 |
if (!mergedData.getDependencyTrackPoint() || mergedData.getDependencyTrackPoint()->getBranchingTag() > maxDeterministicBranchTag) { |
| 1343 |
deterministicallyDerived = false; |
| 1344 |
} |
| 1345 |
bool considerIndividual = deterministicallyDerived || !onlyDeterministic; |
| 1346 |
if (considerIndividual) { |
| 1347 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = cacheValueHash->value(mergedIndiId); |
| 1348 |
if (!labelValueLinker || labelValueLinker->getCacheValue() != getCacheValue(mergedIndiId, false)) { |
| 1349 |
compatible = false; |
| 1350 |
} |
| 1351 |
} |
| 1352 |
} |
| 1353 |
} |
| 1354 |
} |
| 1355 |
if (compatible && indiId >= 0) { |
| 1356 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = cacheValueHash->value(indiId); |
| 1357 |
if (!labelValueLinker || labelValueLinker->getCacheValue() != getCacheValue(indiId, false)) { |
| 1358 |
compatible = false; |
| 1359 |
} |
| 1360 |
} |
| 1361 |
if (compatible) { |
| 1362 |
labelItem = itemIt; |
| 1363 |
} |
| 1364 |
} |
| 1365 |
} |
| 1366 |
} |
| 1367 |
return labelItem; |
| 1368 |
} |
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryCacheReader::getIndividualSetLabelCacheEntry(cint64 labelType, cint64 signature, CPROCESSSET<cint64>* individualSet, cint64& count) { |
| 1375 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = nullptr; |
| 1376 |
CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* sigResEntry = getLabelCacheEntry(labelType, signature); |
| 1377 |
if (sigResEntry) { |
| 1378 |
for (CBackendRepresentativeMemoryLabelCacheItem* itemIt = sigResEntry->getLabelItems(); itemIt && !labelItem; itemIt = itemIt->getNext()) { |
| 1379 |
if (itemIt->getCacheValueCount() == count) { |
| 1380 |
bool compatible = true; |
| 1381 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelValueLinker*>* cacheValueHash = itemIt->getTagCacheValueHash(false); |
| 1382 |
for (CPROCESSSET<cint64>::const_iterator it = individualSet->constBegin(), itEnd = individualSet->constEnd(); it != itEnd; ++it) { |
| 1383 |
cint64 indiId = *it; |
| 1384 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = cacheValueHash->value(indiId); |
| 1385 |
if (!labelValueLinker || labelValueLinker->getCacheValue() != getCacheValue(indiId, false)) { |
| 1386 |
compatible = false; |
| 1387 |
} |
| 1388 |
} |
| 1389 |
if (compatible) { |
| 1390 |
labelItem = itemIt; |
| 1391 |
} |
| 1392 |
} |
| 1393 |
} |
| 1394 |
} |
| 1395 |
return labelItem; |
| 1396 |
} |
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
}; // end namespace Cache |
| 1401 |
|
| 1402 |
}; // end namespace Kernel |
| 1403 |
|
| 1404 |
}; // end namespace Reasoner |
| 1405 |
|
| 1406 |
}; // end namespace Konclude |