| 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 "CIncrementalPrecomputationThread.h" |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#ifndef KONCLUDE_FORCE_STATISTIC_DEACTIVATED |
| 26 |
#define KONCLUDE_PRECOMPUTATION_SATURATION_STATISTIC_OUTPUT |
| 27 |
#endif |
| 28 |
|
| 29 |
|
| 30 |
namespace Konclude { |
| 31 |
|
| 32 |
namespace Reasoner { |
| 33 |
|
| 34 |
namespace Consistiser { |
| 35 |
|
| 36 |
|
| 37 |
CIncrementalPrecomputationThread::CIncrementalPrecomputationThread(CReasonerManager *reasonerManager) : CPrecomputationThread(reasonerManager),CLogIdentifier("::Konclude::Reasoner::Kernel::Precomputator",this) { |
| 38 |
mReuseCompletionGraphCacheWriter = nullptr; |
| 39 |
CCompletionGraphCache* complGraphCache = reasonerManager->getCompletionGraphCache(); |
| 40 |
if (complGraphCache) { |
| 41 |
CReuseCompletionGraphCache* reuseComplGraphCache = dynamic_cast<CReuseCompletionGraphCache*>(complGraphCache); |
| 42 |
if (reuseComplGraphCache) { |
| 43 |
mReuseCompletionGraphCacheWriter = reuseComplGraphCache->createCacheWriter(); |
| 44 |
} |
| 45 |
} |
| 46 |
mBackendAssocCache = nullptr; |
| 47 |
CBackendCache* backendCache = reasonerManager->getBackendAssociationCache(); |
| 48 |
if (backendCache) { |
| 49 |
mBackendAssocCache = dynamic_cast<CBackendRepresentativeMemoryCache*>(backendCache); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
CIncrementalPrecomputationThread::~CIncrementalPrecomputationThread() { |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
COntologyPrecomputationItem* CIncrementalPrecomputationThread::initializeOntologyPrecomputionItem(CConcreteOntology* ontology, CConfigurationBase* config) { |
| 59 |
CIncrementalOntologyPrecomputationItem* item = new CIncrementalOntologyPrecomputationItem(); |
| 60 |
item->initTotallyPrecomputationItem(ontology,config); |
| 61 |
|
| 62 |
|
| 63 |
if (config) { |
| 64 |
bool configErrorFlag = false; |
| 65 |
cint64 processorCount = 1; |
| 66 |
QString processorCountString = CConfigDataReader::readConfigString(config,"Konclude.Calculation.ProcessorCount",QString(),&configErrorFlag); |
| 67 |
if (!configErrorFlag) { |
| 68 |
if (processorCountString == "AUTO") { |
| 69 |
processorCount = CThread::idealThreadCount(); |
| 70 |
} else { |
| 71 |
qint64 convertedWorkerCount = processorCountString.toInt(&configErrorFlag); |
| 72 |
if (configErrorFlag) { |
| 73 |
processorCount = convertedWorkerCount; |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
bool mulConfigErrorFlag = false; |
| 79 |
cint64 multiplicator = CConfigDataReader::readConfigInteger(config,"Konclude.Calculation.Precomputation.TotalPrecomputor.MultipliedUnitsParallelCalculationCount",1,&mulConfigErrorFlag); |
| 80 |
mConfMaxTestParallelCount = processorCount*multiplicator; |
| 81 |
bool maxConfigErrorFlag = false; |
| 82 |
cint64 maxParallel = CConfigDataReader::readConfigInteger(config,"Konclude.Calculation.Precomputation.TotalPrecomputor.MaximumParallelCalculationCount",1,&maxConfigErrorFlag); |
| 83 |
if (!maxConfigErrorFlag) { |
| 84 |
if (!mulConfigErrorFlag) { |
| 85 |
mConfMaxTestParallelCount = qMin(mConfMaxTestParallelCount,maxParallel); |
| 86 |
} else { |
| 87 |
mConfMaxTestParallelCount = maxParallel; |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
} else { |
| 92 |
mConfMaxTestParallelCount = 1; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
return item; |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
bool CIncrementalPrecomputationThread::createNextTest() { |
| 102 |
|
| 103 |
|
| 104 |
COntologyPrecomputationItem* loopOntPreCompItem = 0; |
| 105 |
bool workTestCreated = false; |
| 106 |
while (!workTestCreated && !mProcessingOntItemList.isEmpty()) { |
| 107 |
COntologyPrecomputationItem* ontPreCompItem = mProcessingOntItemList.first(); |
| 108 |
|
| 109 |
if (ontPreCompItem == loopOntPreCompItem) { |
| 110 |
// don't run into infinite loop without doing something |
| 111 |
break; |
| 112 |
} |
| 113 |
|
| 114 |
CIncrementalOntologyPrecomputationItem* incPreCompItem = (CIncrementalOntologyPrecomputationItem*)ontPreCompItem; |
| 115 |
|
| 116 |
|
| 117 |
bool failDebug = false; |
| 118 |
if (!workTestCreated && incPreCompItem->isConsistenceStepRequired()) { |
| 119 |
if (!incPreCompItem->isConsistenceStepFinished()) { |
| 120 |
if (incPreCompItem->areConsistenceStepProcessingRequirementSatisfied()) { |
| 121 |
|
| 122 |
|
| 123 |
if (!failDebug && !incPreCompItem->hasConsistenceCheckCreated()) { |
| 124 |
LOG(INFO,getLogDomain(),logTr("Incrementally precompute ontology consistency."),this); |
| 125 |
incPreCompItem->setConsistenceCheckCreated(true); |
| 126 |
workTestCreated = createConsistencePrecomputationCheck(incPreCompItem); |
| 127 |
} |
| 128 |
|
| 129 |
if (incPreCompItem->hasConsistenceCheched()) { |
| 130 |
incPreCompItem->getConsistencePrecomputationStep()->setStepFinished(true); |
| 131 |
|
| 132 |
if (incPreCompItem->getOntology()->getConsistence()->isOntologyConsistent()) { |
| 133 |
incPreCompItem->getConsistencePrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSSUCESSFULL); |
| 134 |
} else { |
| 135 |
incPreCompItem->getConsistencePrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSSUCESSFULL | COntologyProcessingStatus::PSINCONSITENT); |
| 136 |
} |
| 137 |
|
| 138 |
} |
| 139 |
|
| 140 |
} else { |
| 141 |
incPreCompItem->getConsistencePrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSFAILED | COntologyProcessingStatus::PSFAILEDREQUIREMENT); |
| 142 |
incPreCompItem->getConsistencePrecomputationStep()->setStepFinished(true); |
| 143 |
} |
| 144 |
} else { |
| 145 |
incPreCompItem->getConsistencePrecomputationStep()->submitRequirementsUpdate(); |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
if (!workTestCreated && incPreCompItem->isIndividualStepRequired() && incPreCompItem->isConsistenceStepFinished()) { |
| 156 |
if (!incPreCompItem->isIndividualStepFinished()) { |
| 157 |
if (incPreCompItem->areIndividualStepProcessingRequirementSatisfied()) { |
| 158 |
|
| 159 |
|
| 160 |
if (!incPreCompItem->hasIndividualPrecomputationCreated()) { |
| 161 |
incPreCompItem->setIndividualPrecomputationCreated(true); |
| 162 |
workTestCreated = createIndividualPrecomputationCheck(incPreCompItem); |
| 163 |
} |
| 164 |
|
| 165 |
|
| 166 |
if (incPreCompItem->hasIndividualPrecomputationChecked() && !incPreCompItem->isIndividualComputationRunning()) { |
| 167 |
incPreCompItem->setIndividualStepRunning(false); |
| 168 |
incPreCompItem->getIndividualPrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSSUCESSFULL); |
| 169 |
incPreCompItem->getIndividualPrecomputationStep()->setStepFinished(true); |
| 170 |
} |
| 171 |
|
| 172 |
} else { |
| 173 |
incPreCompItem->setIndividualStepRunning(false); |
| 174 |
incPreCompItem->getIndividualPrecomputationStep()->setStepFinished(true); |
| 175 |
incPreCompItem->getIndividualPrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSFAILED | COntologyProcessingStatus::PSFAILEDREQUIREMENT); |
| 176 |
} |
| 177 |
} else { |
| 178 |
incPreCompItem->getIndividualPrecomputationStep()->submitRequirementsUpdate(); |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
if (!workTestCreated && incPreCompItem->isSaturationStepRequired() && incPreCompItem->isConsistenceStepFinished() && incPreCompItem->isIndividualStepFinished()) { |
| 190 |
if (!incPreCompItem->isSaturationStepFinished()) { |
| 191 |
if (incPreCompItem->areSaturationStepProcessingRequirementSatisfied()) { |
| 192 |
|
| 193 |
incPreCompItem->getSaturationPrecomputationStep()->setStepFinished(true); |
| 194 |
incPreCompItem->getSaturationPrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSSUCESSFULL); |
| 195 |
|
| 196 |
} else { |
| 197 |
incPreCompItem->getSaturationPrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSFAILED | COntologyProcessingStatus::PSFAILEDREQUIREMENT); |
| 198 |
} |
| 199 |
} else { |
| 200 |
incPreCompItem->getSaturationPrecomputationStep()->submitRequirementsUpdate(); |
| 201 |
} |
| 202 |
} |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
if (!workTestCreated && incPreCompItem->isCycleStepRequired() && incPreCompItem->isConsistenceStepFinished()) { |
| 211 |
if (!incPreCompItem->isCycleStepFinished()) { |
| 212 |
if (incPreCompItem->areCycleStepProcessingRequirementSatisfied()) { |
| 213 |
incPreCompItem->getCyclePrecomputationStep()->setStepFinished(true); |
| 214 |
incPreCompItem->getCyclePrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSSUCESSFULL); |
| 215 |
} else { |
| 216 |
incPreCompItem->getCyclePrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSFAILED | COntologyProcessingStatus::PSFAILEDREQUIREMENT); |
| 217 |
incPreCompItem->getCyclePrecomputationStep()->setStepFinished(true); |
| 218 |
} |
| 219 |
} else { |
| 220 |
incPreCompItem->getCyclePrecomputationStep()->submitRequirementsUpdate(); |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
|
| 225 |
if (!workTestCreated) { |
| 226 |
if (!incPreCompItem->hasRemainingProcessingRequirements()) { |
| 227 |
finishOntologyPrecomputation(incPreCompItem); |
| 228 |
mProcessingOntItemList.removeFirst(); |
| 229 |
} else { |
| 230 |
mProcessingOntItemList.removeFirst(); |
| 231 |
mProcessingOntItemList.append(incPreCompItem); |
| 232 |
loopOntPreCompItem = ontPreCompItem; |
| 233 |
} |
| 234 |
} |
| 235 |
} |
| 236 |
return workTestCreated; |
| 237 |
} |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
bool CIncrementalPrecomputationThread::createIndividualPrecomputationCheck(CIncrementalOntologyPrecomputationItem* incPreCompItem) { |
| 248 |
CConcreteOntology* onto = incPreCompItem->getOntology(); |
| 249 |
CSatisfiableCalculationJob* satCalcJob = nullptr; |
| 250 |
return false; |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
QSet<CIndividual*>* CIncrementalPrecomputationThread::getDirectlyChangedIndividualsFromLastConsistentlyTestedOntology(CIncrementalOntologyPrecomputationItem* incPreCompItem) { |
| 257 |
CConcreteOntology* lastConOntVer = getLastConsistentlyTestedOntologyVersion(incPreCompItem); |
| 258 |
return getDirectlyChangedIndividuals(lastConOntVer,incPreCompItem); |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
QSet<CIndividual*>* CIncrementalPrecomputationThread::getDirectlyChangedIndividuals(CConcreteOntology* lastOntologyVersion, CIncrementalOntologyPrecomputationItem* incPreCompItem) { |
| 264 |
QSet<CIndividual*>* indiSet = incPreCompItem->getDirectlyChangedIndividualSet(); |
| 265 |
if (!incPreCompItem->hasDirectlyChangedIndividualsIdentified()) { |
| 266 |
CConcreteOntology* ontology = incPreCompItem->getOntology(); |
| 267 |
CIndividualVector* indiVec = ontology->getABox()->getIndividualVector(false); |
| 268 |
if (indiVec) { |
| 269 |
cint64 indiCount = indiVec->getItemCount(); |
| 270 |
CIndividualVector* prevIndiVec = lastOntologyVersion->getABox()->getIndividualVector(false); |
| 271 |
if (!prevIndiVec) { |
| 272 |
for (cint64 i = 0; i < indiCount; ++i) { |
| 273 |
CIndividual* individual = indiVec->getData(i); |
| 274 |
if (individual) { |
| 275 |
indiSet->insert(individual); |
| 276 |
} |
| 277 |
} |
| 278 |
} else { |
| 279 |
for (cint64 i = 0; i < indiCount; ++i) { |
| 280 |
CIndividual* individual = indiVec->getData(i); |
| 281 |
if (individual) { |
| 282 |
CIndividual* prevIndividual = prevIndiVec->getData(i); |
| 283 |
if (individual != prevIndividual) { |
| 284 |
indiSet->insert(individual); |
| 285 |
} |
| 286 |
} |
| 287 |
} |
| 288 |
} |
| 289 |
} |
| 290 |
incPreCompItem->setDirectlyChangedIndividualsIdentified(true); |
| 291 |
} |
| 292 |
return indiSet; |
| 293 |
} |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
CConcreteOntology* CIncrementalPrecomputationThread::getLastConsistentlyTestedOntologyVersion(CIncrementalOntologyPrecomputationItem* incPreCompItem) { |
| 299 |
CConcreteOntology* lastConsOntology = incPreCompItem->getLastConsistentlyTestedVersion(); |
| 300 |
if (!lastConsOntology) { |
| 301 |
CConcreteOntology* ontology = incPreCompItem->getOntology(); |
| 302 |
CConcreteOntology* prevOntology = ontology->getIncrementalRevisionData()->getPreviousOntologyVersion(); |
| 303 |
while (prevOntology && !lastConsOntology) { |
| 304 |
CConsistence* prevConsistenceData = prevOntology->getConsistence(); |
| 305 |
if (prevConsistenceData && prevConsistenceData->isOntologyConsistent()) { |
| 306 |
if (prevConsistenceData->areAllIndividualsRepresentativelyStored() || prevConsistenceData->hasConsistenceModelData()) { |
| 307 |
lastConsOntology = prevOntology; |
| 308 |
} |
| 309 |
} |
| 310 |
if (!lastConsOntology) { |
| 311 |
prevOntology = prevOntology->getIncrementalRevisionData()->getPreviousOntologyVersion(); |
| 312 |
} |
| 313 |
} |
| 314 |
incPreCompItem->setLastConsistentlyTestedVersion(lastConsOntology); |
| 315 |
} |
| 316 |
return lastConsOntology; |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
bool CIncrementalPrecomputationThread::createConsistencePrecomputationCheck(CIncrementalOntologyPrecomputationItem* incPreCompItem) { |
| 323 |
CConcreteOntology* onto = incPreCompItem->getOntology(); |
| 324 |
CSatisfiableCalculationJob* satCalcJob = nullptr; |
| 325 |
|
| 326 |
CConcreteOntology* lastConsistentlyTestedOnto = getLastConsistentlyTestedOntologyVersion(incPreCompItem); |
| 327 |
|
| 328 |
CIndividualVector* indiVec = onto->getABox()->getIndividualVector(false); |
| 329 |
cint64 indiCount = 0; |
| 330 |
if (indiVec) { |
| 331 |
indiCount = indiVec->getItemCount(); |
| 332 |
} |
| 333 |
|
| 334 |
bool consistencyDetected = false; |
| 335 |
bool detectedConsistency = true; |
| 336 |
if (false) { |
| 337 |
consistencyDetected = true; |
| 338 |
detectedConsistency = true; |
| 339 |
LOG(INFO,getLogDomain(),logTr("Trivial consistency detected with merged individual."),getLogObject()); |
| 340 |
} else { |
| 341 |
|
| 342 |
QSet<CIndividual*>* changedIndividualSet = getDirectlyChangedIndividuals(lastConsistentlyTestedOnto,incPreCompItem); |
| 343 |
|
| 344 |
QList<CIndividual*> indiList; |
| 345 |
for (QSet<CIndividual*>::const_iterator it = changedIndividualSet->constBegin(), itEnd = changedIndividualSet->constEnd(); it != itEnd; ++it) { |
| 346 |
CIndividual* individual(*it); |
| 347 |
indiList.append(individual); |
| 348 |
} |
| 349 |
|
| 350 |
CSatisfiableCalculationJobGenerator satCalcJobGen(onto); |
| 351 |
if (indiList.isEmpty()) { |
| 352 |
CConcept* topConcept = onto->getTBox()->getTopConcept(); |
| 353 |
if (topConcept->getOperandCount() > 0) { |
| 354 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(topConcept); |
| 355 |
} else { |
| 356 |
consistencyDetected = true; |
| 357 |
detectedConsistency = true; |
| 358 |
} |
| 359 |
} else { |
| 360 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(indiList); |
| 361 |
} |
| 362 |
} |
| 363 |
|
| 364 |
|
| 365 |
CConsistence* consistence = onto->getConsistence(); |
| 366 |
if (!consistence) { |
| 367 |
consistence = new CConsistence(); |
| 368 |
onto->setConsistence(consistence); |
| 369 |
} |
| 370 |
incPreCompItem->setConsistence(consistence); |
| 371 |
|
| 372 |
if (consistencyDetected) { |
| 373 |
consistence->setOntologyConsistent(detectedConsistency); |
| 374 |
incPreCompItem->setConsistenceCheched(true); |
| 375 |
return false; |
| 376 |
} else { |
| 377 |
cint64 incRevID = incPreCompItem->getIncrementalExpansionID(); |
| 378 |
CIncrementalConsistencePrecomputationTestingItem* consTestItem = new CIncrementalConsistencePrecomputationTestingItem(incPreCompItem,lastConsistentlyTestedOnto,incRevID,incPreCompItem); |
| 379 |
CCalculationConfigurationExtension* calcConfig = incPreCompItem->getCalculationConfiguration(); |
| 380 |
satCalcJob->setCalculationConfiguration(calcConfig); |
| 381 |
satCalcJob->setSatisfiableTaskIncrementalConsistencyTestingAdapter(consTestItem->getIncrementalConsistencyTestingAdapter()); |
| 382 |
|
| 383 |
processCalculationJob(satCalcJob,incPreCompItem,consTestItem); |
| 384 |
return true; |
| 385 |
} |
| 386 |
} |
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
bool CIncrementalPrecomputationThread::precomputationIndividualsRetrieved(COntologyPrecomputationItem* ontPreCompItem, CRetrievedPrecomputationIndividualsCallbackEvent* pcce) { |
| 397 |
return false; |
| 398 |
} |
| 399 |
|
| 400 |
|
| 401 |
bool CIncrementalPrecomputationThread::precomputationTested(COntologyPrecomputationItem* ontPreCompItem, CPrecomputationTestingItem* preTestItem, CSaturationPrecomputationCalculatedCallbackEvent* pcce) { |
| 402 |
return false; |
| 403 |
} |
| 404 |
|
| 405 |
|
| 406 |
bool CIncrementalPrecomputationThread::precomputationTested(COntologyPrecomputationItem* ontPreCompItem, CPrecomputationTestingItem* preTestItem, CPrecomputationCalculatedCallbackEvent* pcce) { |
| 407 |
CIncrementalOntologyPrecomputationItem* incPreCompItem = (CIncrementalOntologyPrecomputationItem*)ontPreCompItem; |
| 408 |
if (preTestItem->getPrecomputationTestingType() == CPrecomputationTestingItem::CONSISTENCEPRECOMPUTATIONTYPE) { |
| 409 |
CIncrementalConsistencePrecomputationTestingItem* consPreTestItem = (CIncrementalConsistencePrecomputationTestingItem*)preTestItem; |
| 410 |
incPreCompItem->setIndividualStepRunning(false); |
| 411 |
incPreCompItem->setIndividualPrecomputationChecked(true); |
| 412 |
incPreCompItem->setConsistenceCheched(true); |
| 413 |
|
| 414 |
if (pcce->hasCalculationError()) { |
| 415 |
LOG(ERROR,getLogDomain(),logTr("Error in computation, consistence testing for ontology '%1' failed.").arg(ontPreCompItem->getOntology()->getTerminologyName()),getLogObject()); |
| 416 |
incPreCompItem->getConsistencePrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSFAILED); |
| 417 |
incPreCompItem->getIndividualPrecomputationStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSFAILED); |
| 418 |
} else { |
| 419 |
CConsistence* consistence = incPreCompItem->getConsistence(); |
| 420 |
consistence->setConsistenceModelData(incPreCompItem->getConsistenceData()); |
| 421 |
consistence->setOntologyConsistent(pcce->getTestResultSatisfiable()); |
| 422 |
} |
| 423 |
logIncrementalReasoningInfos(incPreCompItem); |
| 424 |
return true; |
| 425 |
} |
| 426 |
return false; |
| 427 |
} |
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
bool CIncrementalPrecomputationThread::logIncrementalReasoningInfos(CIncrementalOntologyPrecomputationItem* incPreCompItem) { |
| 433 |
CConsistenceData* consData = incPreCompItem->getConsistenceData(); |
| 434 |
if (consData) { |
| 435 |
CIncrementalConsistenceTaskData* incConsTaskData = dynamic_cast<CIncrementalConsistenceTaskData*>(consData); |
| 436 |
if (incConsTaskData) { |
| 437 |
cint64 directlyChangedNodeCount = incPreCompItem->getDirectlyChangedIndividualSet()->count(); |
| 438 |
cint64 deterministicallyChangedNodeCount = incConsTaskData->getDeterministicallyChangedNodeCount(); |
| 439 |
cint64 indirectlyChangedNodeCount = incConsTaskData->getIndirectlyChangedCount(); |
| 440 |
cint64 changedCompatibleNodeCount = incConsTaskData->getChangedCompatibleNodeCount(); |
| 441 |
COntologyProcessingStatistics* ontProcStats = incPreCompItem->getConsistencePrecomputationStep()->getProcessingStepData()->getProcessingStatistics(true); |
| 442 |
ontProcStats->setProcessingCountStatisticValue("incremental-consistency-checking-directly-changed-individual-count",directlyChangedNodeCount); |
| 443 |
ontProcStats->setProcessingCountStatisticValue("incremental-consistency-checking-deterministically-changed-node-count",deterministicallyChangedNodeCount); |
| 444 |
ontProcStats->setProcessingCountStatisticValue("incremental-consistency-checking-indirectly-changed-node-count",indirectlyChangedNodeCount); |
| 445 |
ontProcStats->setProcessingCountStatisticValue("incremental-consistency-checking-changed-compatible-node-count",changedCompatibleNodeCount); |
| 446 |
ontProcStats->setProcessingCountStatisticValue("incremental-consistency-checking-added-node-count",incConsTaskData->getAddedNodeCount()); |
| 447 |
ontProcStats->setProcessingCountStatisticValue("incremental-consistency-checking-new-total-node-count",incConsTaskData->getTotalNodeCount()); |
| 448 |
ontProcStats->setProcessingCountStatisticValue("incremental-consistency-checking-previous-total-node-count",incConsTaskData->getPreviousNodeCount()); |
| 449 |
ontProcStats->setProcessingCountStatisticValue("incremental-consistency-checking-time",incPreCompItem->getInitializationTime()->elapsed()); |
| 450 |
LOG(INFO,getLogDomain(),logTr("Established consistency incrementally, %1 individuals directly changed, %2 nodes deterministically changed, %3 nodes indirectly changed.").arg(directlyChangedNodeCount).arg(deterministicallyChangedNodeCount).arg(indirectlyChangedNodeCount),this); |
| 451 |
} |
| 452 |
} |
| 453 |
return false; |
| 454 |
} |
| 455 |
|
| 456 |
|
| 457 |
bool CIncrementalPrecomputationThread::finishOntologyPrecomputation(CIncrementalOntologyPrecomputationItem* incPreCompItem) { |
| 458 |
if (incPreCompItem->areAllStepFinished()) { |
| 459 |
incPreCompItem->setPrecomputationFinished(true); |
| 460 |
CConcreteOntology* ontology = incPreCompItem->getOntology(); |
| 461 |
|
| 462 |
CPrecomputation* precomputation = ontology->getPrecomputation(); |
| 463 |
precomputation->setPrecomputed(true); |
| 464 |
} |
| 465 |
|
| 466 |
incPreCompItem->doPrecomputationFinishedCallback(true); |
| 467 |
|
| 468 |
mActiveOntItemSet.remove(incPreCompItem); |
| 469 |
mInactiveOntItemSet.insert(incPreCompItem); |
| 470 |
return true; |
| 471 |
} |
| 472 |
|
| 473 |
|
| 474 |
}; // end namespace Consistiser |
| 475 |
|
| 476 |
}; // end namespace Reasoner |
| 477 |
|
| 478 |
}; // end namespace Konclude |