Debian Codegraph @

Source/Reasoner/Triples/CRedlandStoredTriplesIndividualAssertionIndexCache.h

raw ◀ ▶
1 Debian patch touch this file
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 #ifdef KONCLUDE_REDLAND_INTEGRATION
21
22 #ifndef KONCLUDE_REASONER_TRIPLES_CREDLANDSTOREDTRIPLESINDIVIDUALASSERTIONINDEXCACHE_H
23 #define KONCLUDE_REASONER_TRIPLES_CREDLANDSTOREDTRIPLESINDIVIDUALASSERTIONINDEXCACHE_H
24
25 // Libraries includes
26 #include <QCache>
27 #include <QHash>
28 #include <QUrl>
29
•30 #include <librdf.h>
31
32 // Namespace includes
33 #include "TriplesSettings.h"
34 #include "CRedlandStoredTriplesData.h"
35 #include "CRedlandStoredTriplesIndividualAssertionIndexCacheDataUpdateHandler.h"
36 #include "CRedlandStoredTriplesRepresentativeIndividualAssertionsIndexData.h"
37 #include "CRedlandStoredTriplesIndividualAssertionIndexCacheData.h"
38 #include "CRedlandNodeHasher.h"
39 #include "CRedlandStoredTriplesRepresentativeTagSetHash.h"
40 #include "CRedlandStoredTriplesRepresentativeTagRolesSet.h"
41 #include "CRedlandStoredTriplesRepresentativeTagTypeConceptsSet.h"
42
43
44 // Other includes
45 #include "Utilities/Container/CLinker.h"
46
47 #include "Config/CConfigurationBase.h"
48 #include "Config/CConfigDataReader.h"
49
50 // Logger includes
51 #include "Logger/CLogger.h"
52
53
54 namespace Konclude {
55
56 using namespace Utilities::Container;
57 using namespace Config;
58
59 namespace Reasoner {
60
61 namespace Triples {
62
63
64 /*!
65 *
66 * \class CRedlandStoredTriplesIndividualAssertionIndexCache
67 * \author Andreas Steigmiller
68 * \version 0.1
69 * \brief TODO
70 *
71 */
72 class CRedlandStoredTriplesIndividualAssertionIndexCache : public CRedlandStoredTriplesIndividualAssertionIndexCacheDataUpdateHandler {
73 // public methods
74 public:
75 //! Constructor
76 CRedlandStoredTriplesIndividualAssertionIndexCache(const QString& kbName, CRedlandStoredTriplesData* tripleData, CConfigurationBase* config);
77
78 ~CRedlandStoredTriplesIndividualAssertionIndexCache();
79
80
81 CRedlandStoredTriplesIndividualAssertionIndexCache* beginIndexing();
82 CRedlandStoredTriplesIndividualAssertionIndexCache* completeIndexing();
83
84
85 CRedlandStoredTriplesIndividualAssertionIndexCacheData* getIndividualAssertionIndexCacheData(cint64 individualId);
86 CRedlandStoredTriplesRepresentativeIndividualAssertionsIndexData* getRepresentativeIndividualAssertionsIndexData(CRedlandStoredTriplesIndividualAssertionIndexCacheData* indiData);
87
88
89 CRedlandStoredTriplesIndividualAssertionIndexCacheData* extendIndividualAssertionIndexCacheDataByTypeConcept(CRedlandStoredTriplesIndividualAssertionIndexCacheData* indiData, CConcept* concept);
90 CRedlandStoredTriplesIndividualAssertionIndexCacheData* extendIndividualAssertionIndexCacheDataByOutgoingObjectRole(CRedlandStoredTriplesIndividualAssertionIndexCacheData* indiData, CRole* role);
91 CRedlandStoredTriplesIndividualAssertionIndexCacheData* extendIndividualAssertionIndexCacheDataByIncomingObjectRole(CRedlandStoredTriplesIndividualAssertionIndexCacheData* indiData, CRole* role);
92 CRedlandStoredTriplesIndividualAssertionIndexCacheData* extendIndividualAssertionIndexCacheDataByOutgoingDataRole(CRedlandStoredTriplesIndividualAssertionIndexCacheData* indiData, CRole* role);
93
94
95 cint64 getIndividualIdFromIndividualNode(librdf_node* node);
96 cint64 getIndividualIdFromIndividualName(const QString& indiName);
97 CRedlandStoredTriplesIndividualAssertionIndexCacheData* getIndividualAssertionIndexCacheData(librdf_node* node, bool createIfNotExists = true);
98
99 CRedlandStoredTriplesIndividualAssertionIndexCacheData* associateIndividualWithId(librdf_node* indiNode, cint64 indiId);
100 CRedlandStoredTriplesIndividualAssertionIndexCache* setNextIndividualId(cint64 indiId);
101
102 QSet<CConcept*>* getAssertedConceptSet();
103 QSet<CRole*>* getAssertedObjectRoleSet();
104 QSet<CRole*>* getAssertedDataRoleSet();
105
106 cint64 getNextIndividualId();
107
108 QString getRepresentativeCacheModelString();
109
110 // protected methods
111 protected:
112 CRedlandStoredTriplesIndividualAssertionIndexCache* initRepresentativeStore();
113 librdf_statement* initPartialFilteringStatement(const char* subjectFilterUri, const char* predicateFilterUri, const char* objectFilterUri);
114
115
116 CRedlandStoredTriplesIndividualAssertionIndexCacheData* createWithRetrievalIndividualAssertionIndexCacheData(librdf_node* node, cint64* individualId, bool idStored);
117
118
119 CRedlandStoredTriplesIndividualAssertionIndexCacheDataUpdateHandler* releaseCacheData(CRedlandStoredTriplesIndividualAssertionIndexCacheData* cacheData);
120 CRedlandStoredTriplesIndividualAssertionIndexCacheDataUpdateHandler* updateCacheData(CRedlandStoredTriplesIndividualAssertionIndexCacheData* cacheData);
121
122
123 CRedlandStoredTriplesIndividualAssertionIndexCache* writeRepresentativeTagRoleSetToStore(char encodingChar, CRedlandStoredTriplesIndividualAssertionIndexCacheData* cacheData, CRedlandStoredTriplesRepresentativeTagRolesSet* newTagRoleSet, CRedlandStoredTriplesRepresentativeTagRolesSet* prevTagRoleSet, CRedlandStoredTriplesRepresentativeTagRolesSet* baseTagRoleSet);
124
125
126
127 // protected variables
128 protected:
129 CRedlandStoredTriplesData* mTripleData;
130 librdf_storage* mRepresentativeStorage = nullptr;
131 librdf_model* mRepresentativeModel = nullptr;
132
133 const char* mIndividualIdPredicateUri = "i:id";
134 const char* mRepresentativeIdObjectPredicateUri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
135 const char* mRepresentativeNonAnonymousPredicateUri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
136 const char* mRepresentativeNonAnonymousObjectUri = "n";
137 librdf_node* mRepresentativeNonAnonymousObjectNode = nullptr;
138
139 librdf_statement* mIndividualNodeRetrievalByIdStatement;
140 librdf_statement* mIndividualIdRetrievalByNodeStatement;
141 librdf_statement* mRepresentativeTypeFilteringStatement;
142 librdf_statement* mIndividualIdInsertionStatement;
143 librdf_statement* mIndividualNonAnonymityInsertionStatement;
144
145
146 QCache<CRedlandNodeHasher, CRedlandStoredTriplesIndividualAssertionIndexCacheData>* mIndividualAssertionsIndexCache;
147 QHash<cint64, CRedlandStoredTriplesIndividualAssertionIndexCacheData*>* mIndividualIdAssertionsIndexDataHash;
148
149
150 CRedlandStoredTriplesRepresentativeTagSetHash<CConcept*, CRedlandStoredTriplesRepresentativeTagTypeConceptsSet> mTagTypeConceptsSetHash;
151 CRedlandStoredTriplesRepresentativeTagSetHash<CRole*, CRedlandStoredTriplesRepresentativeTagRolesSet> mTagOutgoingObjectRolesSetHash;
152 CRedlandStoredTriplesRepresentativeTagSetHash<CRole*, CRedlandStoredTriplesRepresentativeTagRolesSet> mTagIncomingObjectRolesSetHash;
153 CRedlandStoredTriplesRepresentativeTagSetHash<CRole*, CRedlandStoredTriplesRepresentativeTagRolesSet> mTagOutgoingDataRolesSetHash;
154
155
156 cint64 mNextIndividualId = 0;
157
158 bool mIndividualDataWritenToStore = false;
159
160 bool mExternalTripleDataStroing = false;
161
162 QString mKBName;
163 CConfigurationBase* mConfig;
164
165 // private methods
166 private:
167
168 // private variables
169 private:
170
171 };
172
173
174 }; // end namespace Triples
175
176 }; // end namespace Reasoner
177
178 }; // end namespace Konclude
179
180 #endif // KONCLUDE_REASONER_TRIPLES_CREDLANDSTOREDTRIPLESINDIVIDUALASSERTIONINDEXCACHE_H
181
182 #endif // !KONCLUDE_REDLAND_INTEGRATION