| 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 |
#ifndef KONCLUDE_REASONER_KERNEL_CACHE_CBACKENDREPRESENTATIVEMEMORYCACHE_H |
| 22 |
#define KONCLUDE_REASONER_KERNEL_CACHE_CBACKENDREPRESENTATIVEMEMORYCACHE_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
#include <QHash> |
| 26 |
#include <QSet> |
| 27 |
#include <QMutex> |
| 28 |
#include <QSemaphore> |
| 29 |
#include <QtConcurrent> |
| 30 |
|
| 31 |
// Namespace includes |
| 32 |
#include "CacheSettings.h" |
| 33 |
#include "CBackendCache.h" |
| 34 |
#include "CBackendRepresentativeMemoryCacheSlotItem.h" |
| 35 |
#include "CBackendRepresentativeMemoryCacheContext.h" |
| 36 |
#include "CBackendRepresentativeMemoryCacheBaseContext.h" |
| 37 |
#include "CBackendRepresentativeMemoryCacheReader.h" |
| 38 |
#include "CBackendRepresentativeMemoryCacheWriter.h" |
| 39 |
#include "CBackendRepresentativeMemoryCacheLabelAssociationWriteData.h" |
| 40 |
#include "CBackendRepresentativeMemoryCacheIndividualAssociationData.h" |
| 41 |
#include "CBackendRepresentativeMemoryCacheUtilities.h" |
| 42 |
#include "CCacheStatistics.h" |
| 43 |
#include "CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData.h" |
| 44 |
#include "CBackendRepresentativeMemoryLabelCacheItemIndividualAssociationMapExtensionData.h" |
| 45 |
#include "CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData.h" |
| 46 |
#include "CBackendRepresentativeMemoryLabelCacheItemCardinalityExtensionData.h" |
| 47 |
|
| 48 |
#include "CBackendRepresentativeMemoryCacheOntologyData.h" |
| 49 |
|
| 50 |
// Other includes |
| 51 |
#include "Concurrent/CThread.h" |
| 52 |
#include "Concurrent/CConcurrentTaskScheduler.h" |
| 53 |
|
| 54 |
#include "Reasoner/Ontology/CIndividualProcessData.h" |
| 55 |
#include "Reasoner/Ontology/CIRIName.h" |
| 56 |
|
| 57 |
#include "Reasoner/Kernel/Cache/Events/CWriteCachedDataEvent.h" |
| 58 |
#include "Reasoner/Kernel/Cache/Events/CWriteBackendAssociationCachedEvent.h" |
| 59 |
#include "Reasoner/Kernel/Cache/Events/CRetrieveIncompletelyAssociationCachedEvent.h" |
| 60 |
#include "Reasoner/Kernel/Cache/Events/CInitializeIndividualAssociationsCacheEvent.h" |
| 61 |
#include "Reasoner/Kernel/Cache/Events/CReportMaximumHandledRecomputationIdsEvent.h" |
| 62 |
|
| 63 |
#include "Utilities/Memory/CObjectMemoryPoolAllocator.h" |
| 64 |
#include "Utilities/Memory/CObjectParameterizingAllocator.h" |
| 65 |
#include "Utilities/Memory/CMemoryPoolContainerAllocationManager.h" |
| 66 |
|
| 67 |
#include "Context/CContextBase.h" |
| 68 |
#include "Context/CMemoryPoolNewAllocationIncreasingContext.h" |
| 69 |
|
| 70 |
#include "Config/CConfiguration.h" |
| 71 |
#include "Config/CConfigDataReader.h" |
| 72 |
|
| 73 |
|
| 74 |
// Logger includes |
| 75 |
#include "Logger/CLogger.h" |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
namespace Konclude { |
| 81 |
|
| 82 |
using namespace Concurrent; |
| 83 |
using namespace Context; |
| 84 |
using namespace Config; |
| 85 |
using namespace Utilities::Memory; |
| 86 |
|
| 87 |
namespace Reasoner { |
| 88 |
|
| 89 |
using namespace Ontology; |
| 90 |
|
| 91 |
namespace Kernel { |
| 92 |
|
| 93 |
namespace Cache { |
| 94 |
|
| 95 |
using namespace Events; |
| 96 |
|
| 97 |
/*! |
| 98 |
* |
| 99 |
* \class CBackendRepresentativeMemoryCache |
| 100 |
* \author Andreas Steigmiller |
| 101 |
* \version 0.1 |
| 102 |
* \brief TODO |
| 103 |
* |
| 104 |
*/ |
| 105 |
class CBackendRepresentativeMemoryCache : public CThread, public CBackendCache { |
| 106 |
// public methods |
| 107 |
public: |
| 108 |
//! Constructor |
| 109 |
CBackendRepresentativeMemoryCache(CConfiguration* config = nullptr, QString threadIdentifierName = "Backend-Representative-Cache", CWatchDog *watchDogThread = nullptr); |
| 110 |
|
| 111 |
//! Destructor |
| 112 |
virtual ~CBackendRepresentativeMemoryCache(); |
| 113 |
|
| 114 |
CBackendRepresentativeMemoryCacheReader* createCacheReader(); |
| 115 |
CBackendRepresentativeMemoryCacheReader* createOntologyFixedCacheReader(cint64 ontologyIdentifier); |
| 116 |
CBackendRepresentativeMemoryCacheWriter* createCacheWriter(); |
| 117 |
|
| 118 |
|
| 119 |
CBackendRepresentativeMemoryCache* writeCachedData(CBackendRepresentativeMemoryCacheWriteData* writeData, CMemoryPool* memoryPools); |
| 120 |
|
| 121 |
CCacheStatistics* getCacheStatistics(); |
| 122 |
|
| 123 |
bool getIncompletlyAssociationCachedIndividuals(cint64 ontologyIdentifier, CBackendIndividualRetrievalComputationUpdateCoordinationHash* prevCoordHash, CBackendIndividualRetrievalComputationUpdateCoordinationHash* newCoordHash, bool allIndividualsAdded, bool refillRetrievalCoordHash, cint64 limit = -1, CCallbackData* callbackData = nullptr); |
| 124 |
bool initializeIndividualsAssociationCaching(cint64 ontologyIdentifier, cint64 individualCount); |
| 125 |
bool reportMaximumHandledRecomputationId(cint64 ontologyIdentifier, cint64 maximumRecomputationId); |
| 126 |
|
| 127 |
void writeStringifiedRepresentativeCacheToFile(); |
| 128 |
|
| 129 |
CConcreteOntology* mDebugOntology; |
| 130 |
|
| 131 |
// protected methods |
| 132 |
protected: |
| 133 |
|
| 134 |
void createReaderSlotUpdate(CBackendRepresentativeMemoryCacheOntologyData* ontologyData, CBackendRepresentativeMemoryCacheBaseContext* context); |
| 135 |
void cleanUnusedSlots(CBackendRepresentativeMemoryCacheBaseContext* context); |
| 136 |
|
| 137 |
void deleteExpiredIndividualAssociationMemoryContexts(CBackendRepresentativeMemoryCacheOntologyData* ontologyData, CBackendRepresentativeMemoryCacheBaseContext* context); |
| 138 |
void queueIndividualAssociationMemoryContextDeletion(CBackendRepresentativeMemoryCacheIndividualAssociationContext* indiAssMemContext, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 139 |
cint64 getMinimumSlotReferreringInstalledValidRecomputationId(CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 140 |
|
| 141 |
|
| 142 |
virtual bool processCustomsEvents(QEvent::Type type, CCustomEvent *event); |
| 143 |
|
| 144 |
void checkAssociationComplete(CBackendRepresentativeMemoryCacheOntologyData* ontologyData, bool forceCompletion); |
| 145 |
|
| 146 |
|
| 147 |
void installTemporaryCardinalities(CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* tempCardWriteDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 148 |
void installTemporaryLabels(CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* tempLabelWriteDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 149 |
bool installAssociationUpdates(CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tempAssWriteDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 150 |
bool installAssociationUpdate(cint64 individualID, CBackendRepresentativeMemoryCacheIndividualAssociationData* associationData, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tempAssWriteDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 151 |
|
| 152 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourIndividualIdLinker* copyNeighbourIndividualIdLinkers(CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourIndividualIdLinker* indiIdLinker, CBackendRepresentativeMemoryCacheContext* context, CBackendRepresentativeMemoryCacheIndividualAssociationData* locAssociationData, cint64 pos); |
| 153 |
|
| 154 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* createLocalizedIndividualAssociationData(cint64 individualID, CBackendRepresentativeMemoryCacheIndividualAssociationData* associationData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData, bool allowSeparatedManagement, bool incrementUpdateId = true); |
| 155 |
CBackendRepresentativeMemoryCacheContext* getIndividualAssociationDataMemoryContext(CBackendRepresentativeMemoryCacheIndividualAssociationData* associationData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData, bool* requiresDataCopying = nullptr); |
| 156 |
|
| 157 |
bool updateIndexedAssociationCount(CBackendRepresentativeMemoryCacheIndividualAssociationData* locAssociationData, CBackendRepresentativeMemoryCacheIndividualAssociationData* associationData, cint64 i, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 158 |
bool updateIndexedAssociationCount(CBackendRepresentativeMemoryCacheIndividualAssociationData* locAssociationData, CBackendRepresentativeMemoryLabelCacheItem* prevLabelItem, cint64 i, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 159 |
|
| 160 |
bool installDeterministicSameAsAssociationUpdates(CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tempAssWriteDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 161 |
bool installDeterministicSameAsAssociationUpdate(CBackendRepresentativeMemoryCacheIndividualAssociationData* associationData, cint64 individualID, CBackendRepresentativeMemoryCacheIndividualAssociationData* detSameAsAssociationData, cint64 sameAsIndividualId, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 162 |
bool checkRequiresDeterministicSameAsAssociationUpdateInstallation(CBackendRepresentativeMemoryCacheIndividualAssociationData* associationData, cint64 individualID, CBackendRepresentativeMemoryCacheIndividualAssociationData* detSameAsAssociationData, cint64 sameAsIndividualId, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 163 |
|
| 164 |
|
| 165 |
bool completeSameAsNeighbours(CBackendRepresentativeMemoryCacheIndividualAssociationData* locAssociationData, QSet<cint64> newCompletingDetSameNeighbours, QSet<cint64>& newlyCompletedDetSameNeighbours, bool completeOnlyCompatibleNeighbourRoleLabels, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 166 |
bool completeNeighboursForSameAsMerging(QSet<cint64>& tmpCompleteNeighbourSameIndiMergingSet, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 167 |
bool completeDeterministicSameAsMergingInformation(QHash<cint64, cint64>& tmpDetSameMergingCompletionReferenceHash, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 168 |
|
| 169 |
bool udateDeterministicSameAssociations(CBackendRepresentativeMemoryCacheIndividualAssociationData* locNeighbourAssociationData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 170 |
|
| 171 |
bool debugTestingPrioritizedExpansionLinkDuplicates(CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* testingArray, CBackendRepresentativeMemoryLabelCacheItem* propMarkLabelItem); |
| 172 |
|
| 173 |
bool installNominalIndirectConncetionUpdates(CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* tempNomIndirectConnDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 174 |
bool checkAssociationUsage(CBackendRepresentativeMemoryCacheTemporaryAssociationUseDataLinker* tempAssUseDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 175 |
|
| 176 |
|
| 177 |
CBackendRepresentativeMemoryLabelCacheItem* getAdditionMergedLabel(cint64 labelType, CBackendRepresentativeMemoryLabelCacheItem* additionLabel, CBackendRepresentativeMemoryLabelCacheItem* associatedlabel, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 178 |
CBackendRepresentativeMemoryLabelCacheItem* getReducedLabel(cint64 labelType, CBackendRepresentativeMemoryLabelCacheItem* label, function<bool(const CCacheValue& cacheValue)> reduceCheckFunction, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 179 |
CBackendRepresentativeMemoryLabelCacheItem* getExtendedLabel(cint64 labelType, CBackendRepresentativeMemoryLabelCacheItem* label, CCacheValue extendingCacheValue, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 180 |
CBackendRepresentativeMemoryCache* addCreatedLabelStatistics(cint64 labelType, CBackendRepresentativeMemoryLabelCacheItem* label, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 181 |
|
| 182 |
|
| 183 |
void setUpdatedIndividualAssociationData(cint64 individualID, CBackendRepresentativeMemoryCacheIndividualAssociationData* locAssociationData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 184 |
|
| 185 |
bool markRepresentativeReferencedIndividualAssociationIncompletelyHandled(cint64 indiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* associationData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 186 |
bool markIndividualAssociationIncompletelyHandled(cint64 indiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* associationData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 187 |
bool markIndividualAssociationCompletelyHandled(cint64 indiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* associationData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 188 |
|
| 189 |
|
| 190 |
QStringList getRepresentativeCacheString(); |
| 191 |
QStringList getRepresentativeCacheString(CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 192 |
|
| 193 |
QString getIndividualAssociationDebugString(cint64 indiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData, cint64 prevTab); |
| 194 |
|
| 195 |
|
| 196 |
QString getRepresentativeCacheLabelItemString(cint64 labelType); |
| 197 |
|
| 198 |
|
| 199 |
bool requiresIndividualAssociations(cint64 labelType); |
| 200 |
CBackendRepresentativeMemoryLabelCacheItemIndividualAssociationMapExtensionData* getIndividualAssociationsExtensionData(CBackendRepresentativeMemoryLabelCacheItem* labelItem, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 201 |
CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData* getIndividualNeighbourArrayIndexExtensionData(CBackendRepresentativeMemoryLabelCacheItem* labelItem, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 202 |
CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData* getNeighbourArrayRoleTagResolvingLabelExtensionData(CBackendRepresentativeMemoryLabelCacheItem* labelItem, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
CBackendRepresentativeMemoryCacheOntologyData* prepareOntologyDataUpdate(cint64 ontologyIdentifier, cint64 minIndiCount = 0); |
| 207 |
|
| 208 |
|
| 209 |
void indexIndividualLabelAssociations(CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 210 |
|
| 211 |
bool updateInvolvedIndividuals(CBackendRepresentativeMemoryCacheTemporaryInvolvedIndividualDataLinker* tmpInvolvedIndiDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 212 |
bool integratePropagationCut(CBackendRepresentativeMemoryCacheTemporaryPropagationCutDataLinker* tmpPropCutDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 213 |
|
| 214 |
bool updatePropagationCutIndividualIncompletelyHandled(cint64 neighbourId, const CCacheValue& propConValue, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 215 |
bool updatePropagationCutIndividualIncompletelyHandled(cint64 neighbourId, const QList<cint64>& propCutIndiIdList, CBackendRepresentativeMemoryLabelCacheItem* propMarkLabelItem, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 216 |
bool storeIndividualIncompletelyMarked(CBackendRepresentativeMemoryCacheIndividualAssociationData* locAssociationData, bool markIncompletelyHandled, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 217 |
|
| 218 |
bool debugCheckPropagationCutRemainingNeighbours(CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 219 |
bool debugCheckSingleNeighbourInvolvedOccurrences(CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 220 |
bool debugCheckCorrectNeighbourOccurrence(CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 221 |
bool debugCheckNeighoursCorrectlyCounted(CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 222 |
void debugCheckWriteMaxSameMergedIndividualsToFile(CBackendRepresentativeMemoryCacheOntologyData* ontData); |
| 223 |
|
| 224 |
|
| 225 |
bool checkUpdateRejection(CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tempAssWriteDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 226 |
bool handleUpdateRejection(CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tempAssWriteDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 227 |
|
| 228 |
bool analyseDeterministicSameAsAssociationInstallation(CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tempAssWriteDataLinker, CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
bool activateBasicPrecompuationMode(CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 233 |
bool checkBasicPrecompuationModeActivation(CBackendRepresentativeMemoryCacheOntologyData* ontologyData); |
| 234 |
|
| 235 |
|
| 236 |
bool isRoleNeighbourLinkLabelItemCompatibility(CBackendRepresentativeMemoryLabelCacheItem* item1, CBackendRepresentativeMemoryLabelCacheItem* item2); |
| 237 |
bool isCacheValueRoleInverse(const CCacheValue& cacheValue); |
| 238 |
bool isCacheValueRoleNondeterministic(const CCacheValue& cacheValue); |
| 239 |
|
| 240 |
// protected variables |
| 241 |
protected: |
| 242 |
CConfiguration* mConfig; |
| 243 |
|
| 244 |
QHash<cint64, cint64> mIndiContextCountHash; |
| 245 |
cint64 mIndiContextDebuggingCount = 50; |
| 246 |
|
| 247 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryCacheOntologyData*>* mOntologyIdentifierDataHash; |
| 248 |
QHash<cint64, CBackendRepresentativeMemoryCacheOntologyData*> mFixedOntologyIdentifierDataHash; |
| 249 |
QReadWriteLock mFixedOntologyIdentifierDataHashLock; |
| 250 |
|
| 251 |
|
| 252 |
//CCACHINGHASH<cint64,CBackendRepresentativeMemoryLabelSignatureResolveCacheItem>* mSigLabelItemHash[CBackendRepresentativeMemoryLabelCacheItem::LABEL_CACHE_ITEM_TYPE_COUNT]; |
| 253 |
//cint64 mNextEntryID; |
| 254 |
|
| 255 |
////CCACHINGHASH<cint64, CBackendRepresentativeMemoryCacheIndividualAssociationData*>* mIndiIdAssoDataHash; |
| 256 |
//CCACHINGHASH<cint64, CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData* >* mNominalIndiIdIndirectConnectionDataHash; |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
CCACHINGHASH<cint64, CBackendRepresentativeMemoryLabelCacheItem*> mTmpIndiIndirectlyConnNomLabelItemHash; |
| 261 |
cint64 mTmpIndiAssocPrevUpdateId; |
| 262 |
CCACHINGSET<cint64> mPropagationCutIndiSet; |
| 263 |
|
| 264 |
|
| 265 |
//cint64 mIndiIdAssoDataVectorSize; |
| 266 |
//CBackendRepresentativeMemoryCacheIndividualAssociationData** mIndiIdAssoDataVector; |
| 267 |
|
| 268 |
//cint64 mLastMinIncompletelyHandledIndiId; |
| 269 |
//cint64 mIncompletelyHandledIndiIdCount; |
| 270 |
//bool mZeroIncompletelyHandledIndiIdCountDebugWritten; |
| 271 |
|
| 272 |
//cint64 mMaxIndiAssocDataUpdateCount = 0; |
| 273 |
|
| 274 |
//bool mSameMergedIndisInCache; |
| 275 |
|
| 276 |
cint64 mCheckingRemainingIncompletelyHandledCount; |
| 277 |
cint64 mEmptyWriteDataCount; |
| 278 |
cint64 mWriteDataCount; |
| 279 |
cint64 mStartWriteCollectCount; |
| 280 |
cint64 mNextWriteCollectCount; |
| 281 |
cint64 mCollectCount; |
| 282 |
CMemoryPool* mCollectMemoryPools; |
| 283 |
CBackendRepresentativeMemoryCacheWriteData* mCollectWriteData; |
| 284 |
|
| 285 |
cint64 mNextIndiUpdateId; |
| 286 |
cint64 mNextNomConnUpdateId; |
| 287 |
cint64 mUpdatedIndiCount = 0; |
| 288 |
cint64 mAssociationUpdatedIndiCount = 0; |
| 289 |
cint64 mUpdateIncompatibleIndiCount = 0; |
| 290 |
cint64 mCheckedIndiCount = 0; |
| 291 |
cint64 mCheckIncompatibleIndiCount = 0; |
| 292 |
cint64 mReducedNeighbourArrayCount = 0; |
| 293 |
|
| 294 |
cint64 mCurrentUpdateHandlingRecomputationId = -1; |
| 295 |
|
| 296 |
cint64 mReaderSlotUpdateCount; |
| 297 |
cint64 mOntologyDataUpdateCount; |
| 298 |
cint64 mOntologyDataReleasedCount; |
| 299 |
cint64 mOntologyDataReleasedWhileNewCreationCount; |
| 300 |
cint64 mOntologyDataReleasedWhileSlotUpdateCount; |
| 301 |
cint64 mReaderSlotReleasedCount; |
| 302 |
|
| 303 |
QSet<CIndividualReference> mIncompletelyAssociatedIndividualSet; |
| 304 |
CCacheStatistics mCacheStat; |
| 305 |
|
| 306 |
class CPropagationCutNeighbourArrayHandlingData { |
| 307 |
public: |
| 308 |
QSet<cint64> mReaddingArrayPosSet; |
| 309 |
QSet<cint64> mReductionArrayPosSet; |
| 310 |
QSet<cint64> mRemovalArrayPosSet; |
| 311 |
}; |
| 312 |
QHash<cint64, CPropagationCutNeighbourArrayHandlingData*>* mTmpPropCutIndiArrayNeighboursHandlingDataHash; |
| 313 |
QSet<cint64> mTmpCompleteNeighbourSameIndiMergingSet; |
| 314 |
QHash<cint64,cint64> mTmpDetSameMergingCompletionReferenceHash; |
| 315 |
|
| 316 |
CBackendRepresentativeMemoryCacheSlotItem* mSlotLinker; |
| 317 |
CBackendRepresentativeMemoryCacheSlotItem* mLastUpdatedSlotLinker; |
| 318 |
CBackendRepresentativeMemoryCacheReader* mReaderLinker; |
| 319 |
|
| 320 |
QMutex mReaderSyncMutex; |
| 321 |
bool mLimitRemainingWritePending; |
| 322 |
QSemaphore mRemainingWritePendingSemaphore; |
| 323 |
|
| 324 |
CBackendRepresentativeMemoryCacheBaseContext mContext; |
| 325 |
|
| 326 |
bool mConfLateIndividualLabelAssociationIndexing; |
| 327 |
bool mConfWaitIndividualLabelAssociationIndexed; |
| 328 |
bool mConfDebugWriteRepresentativeCache; |
| 329 |
|
| 330 |
bool mConfIncrementUpdateIdForDeterministicSameAsCompletion = true; |
| 331 |
cint64 mConfMinRequiredDeterministicSameMergedHandledInstallationPossiblitiesForNeighbourCompletion = 1; |
| 332 |
cint64 mConfUnchangedDeterministicSameMergeUpdatesForDeterministicSameNeighbourCompletion = 1; |
| 333 |
|
| 334 |
bool mConfInstallingDeterministicSameHandlingLargeDifferenceReached; |
| 335 |
cint64 mConfInstallingDeterministicSameHandlingLargeDifference; |
| 336 |
|
| 337 |
|
| 338 |
double mConfBasicPrecomputationModeActivationUpdateMergesRatio = 0.05; |
| 339 |
|
| 340 |
|
| 341 |
QAtomicInt mPendingUpdateCount; |
| 342 |
|
| 343 |
cint64 mSlotUpdateWaitingIncreaseCount; |
| 344 |
cint64 mSlotUpdateWaitingMaxCount; |
| 345 |
|
| 346 |
|
| 347 |
bool mConfDirectUpdateSynchronization; |
| 348 |
QMutex mDirectUpdateSyncMutex; |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
class CDeterministicSameHandlingInstallationData { |
| 353 |
public: |
| 354 |
QSet<cint64> mIdPossibleInstallationSet; |
| 355 |
QSet<cint64> mIdFirstPossibleInstallationSet; |
| 356 |
}; |
| 357 |
QHash<cint64, CDeterministicSameHandlingInstallationData> mDeterministicSameHandlingInstallationDataHash; |
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
bool mConfPropagationCutPropagatedConceptDirectInstallation = true; |
| 362 |
|
| 363 |
|
| 364 |
cint64 mConfMaxIncompletelyHandledIndividualsRetrievalCount = -1; |
| 365 |
cint64 mConfMaxCacheDataUpdateWritingCount = -1; |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
double mConfUpdateRejectingIncompatibleIndividualAssociationsRatio = 1.; |
| 370 |
double mConfUpdateRejectingIncompatiblePropagationCuttedIndividualLinkedNeighbourRatio = 1; |
| 371 |
cint64 mConfUpdateRejectingIncompatiblePropagationCuttedIndividualLinkedNeighbourCount = -1; |
| 372 |
|
| 373 |
bool mConfInterpretUnchangedLabelsAsCompatible = false; |
| 374 |
|
| 375 |
|
| 376 |
bool mStatCollectStatistics; |
| 377 |
|
| 378 |
cint64 mStatAddingNeighbourLinksAssociationUpdateCount; |
| 379 |
cint64 mStatUpdatedOrRemovedNeighbourLinksAssociationUpdateCount; |
| 380 |
cint64 mStatMaxSameAsMergedCount; |
| 381 |
cint64 mStatMaxLabelValueCount; |
| 382 |
cint64 mStatMaxAssociationUpdateCount; |
| 383 |
cint64 mStatMaxNeighbourLinksCount; |
| 384 |
cint64 mStatLabelCount; |
| 385 |
|
| 386 |
cint64 mStatLabelTypeCount[CBackendRepresentativeMemoryLabelCacheItem::LABEL_CACHE_ITEM_TYPE_COUNT]; |
| 387 |
cint64 mStatLabelTypeMaxValueCount[CBackendRepresentativeMemoryLabelCacheItem::LABEL_CACHE_ITEM_TYPE_COUNT]; |
| 388 |
cint64 mStatLabelTypeAllValueCount[CBackendRepresentativeMemoryLabelCacheItem::LABEL_CACHE_ITEM_TYPE_COUNT]; |
| 389 |
|
| 390 |
cint64 mStatDetSameRepresentativeMergingCount; |
| 391 |
cint64 mStatDetSameAssociationInstallCount; |
| 392 |
cint64 mStatDetSameAssociationFailedCount; |
| 393 |
cint64 mStatDetSameAssociationDifferentUpdateIdFailedCount; |
| 394 |
cint64 mStatDetSameAssociationDifferentDestIdFailedCount; |
| 395 |
cint64 mStatDetSameAssociationIncompleteHandledDestFailedCount; |
| 396 |
cint64 mStatDetSameAssociationRepMergedDestFailedCount; |
| 397 |
|
| 398 |
cint64 mStatCreatedNeighbourLinks; |
| 399 |
|
| 400 |
cint64 mStatIncompatibleLabelNeighbourCompletionCount; |
| 401 |
cint64 mStatChangedLabelNeighbourCompletionCount; |
| 402 |
cint64 mStatNeighbourCompletionDetSameSuccededCount; |
| 403 |
cint64 mStatNeighbourCompletionDetSameUnchangedCount; |
| 404 |
cint64 mStatNeighbourCompletionDetSameChangedCount; |
| 405 |
cint64 mStatNeighbourCompletionDetSameIncompatibleCount; |
| 406 |
|
| 407 |
|
| 408 |
cint64 mStatIndividualAssociationSeparateMemoryManagmentContextCreationCount = 0; |
| 409 |
cint64 mStatIndividualAssociationSeparateMemoryManagmentContextReuseCount = 0; |
| 410 |
|
| 411 |
cint64 mStatIndividualAssociationSeparateMemoryManagmentSlotReferredCheckingCount = 0; |
| 412 |
cint64 mStatIndividualAssociationSeparateMemoryManagmentUnreferredSlotCount = 0; |
| 413 |
cint64 mStatIndividualAssociationSeparateMemoryManagmentDeletionCount = 0; |
| 414 |
cint64 mStatIndividualAssociationSeparateMemoryManagmentSlotReferredCheckingQueuingCount = 0; |
| 415 |
|
| 416 |
cint64 mStatIndividualAssociationWithoutSeparateMemoryManagmentCount = 0; |
| 417 |
|
| 418 |
cint64 mStatIndividualAssociationSeparateMemoryManagmentNeighbourLinkCopyingCount = 0; |
| 419 |
cint64 mStatReportedMaximumHandledRecomputationIdCount = 0; |
| 420 |
|
| 421 |
cint64 mStatMemoryManagmentQueuedCheckingCount = 0; |
| 422 |
cint64 mStatMemoryManagmentScheduledReleasingCount = 0; |
| 423 |
|
| 424 |
|
| 425 |
CBackendRepresentativeMemoryCacheOntologyData* mLastHandledOntologyContext = nullptr; |
| 426 |
cint64 mLastMemoryContextDeletionMinValidRecompId = 0; |
| 427 |
CBackendRepresentativeMemoryCacheTemporaryPropagationCutDataLinker* mLastHandledPropCutDataLinker = nullptr; |
| 428 |
|
| 429 |
bool s1 = false; |
| 430 |
bool s2 = false; |
| 431 |
bool s3 = false; |
| 432 |
cint64 mDebugIndiId = -1; |
| 433 |
|
| 434 |
#ifdef KONCLUDE_CACHE_DEBUGGING_DATA_GENERATION |
| 435 |
QStringList mDebugHandlingStrings; |
| 436 |
#endif |
| 437 |
|
| 438 |
#ifdef KONCLUDE_CACHE_DEBUGGING_DATA_GENERATION |
| 439 |
//#define DEBUG_HANDLING_STRING(a) |
| 440 |
#define DEBUG_HANDLING_STRING(a) mDebugHandlingStrings += QString("%1 at %2 with recomputation id %3").arg(a).arg(mNextIndiUpdateId).arg(mCurrentUpdateHandlingRecomputationId); |
| 441 |
#else |
| 442 |
#define DEBUG_HANDLING_STRING(a) |
| 443 |
#endif |
| 444 |
|
| 445 |
// private methods |
| 446 |
private: |
| 447 |
|
| 448 |
// private variables |
| 449 |
private: |
| 450 |
|
| 451 |
}; |
| 452 |
|
| 453 |
}; // end namespace Cache |
| 454 |
|
| 455 |
}; // end namespace Kernel |
| 456 |
|
| 457 |
}; // end namespace Reasoner |
| 458 |
|
| 459 |
}; // end namespace Konclude |
| 460 |
|
| 461 |
#endif // KONCLUDE_REASONER_KERNEL_CACHE_CBACKENDREPRESENTATIVEMEMORYCACHE_H |