Mercurial > hg > orthanc
annotate OrthancServer/IDatabaseWrapper.h @ 3025:039a9d262d64 db-changes
preparing to speed up find in databases
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 17 Dec 2018 17:05:28 +0100 |
parents | d207f6ac1f86 |
children | fd587cf51a89 |
rev | line source |
---|---|
1247 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1286
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
1247 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #pragma once | |
35 | |
36 #include "../Core/DicomFormat/DicomMap.h" | |
3025
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
37 #include "../Core/FileStorage/FileInfo.h" |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
38 #include "../Core/FileStorage/IStorageArea.h" |
3025
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
39 #include "../Core/SQLite/ITransaction.h" |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
40 |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
41 #include "ExportedResource.h" |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1306
diff
changeset
|
42 #include "IDatabaseListener.h" |
3025
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
43 #include "Search/DatabaseLookup.h" |
1247 | 44 |
45 #include <list> | |
46 #include <boost/noncopyable.hpp> | |
47 | |
48 namespace Orthanc | |
49 { | |
50 class IDatabaseWrapper : public boost::noncopyable | |
51 { | |
52 public: | |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
53 class ITransaction : public boost::noncopyable |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
54 { |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
55 public: |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
56 virtual ~ITransaction() |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
57 { |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
58 } |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
59 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
60 virtual void Begin() = 0; |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
61 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
62 virtual void Rollback() = 0; |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
63 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
64 virtual void Commit(int64_t fileSizeDelta) = 0; |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
65 }; |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
66 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
67 |
1247 | 68 virtual ~IDatabaseWrapper() |
69 { | |
70 } | |
71 | |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
72 virtual void Open() = 0; |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
73 |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
74 virtual void Close() = 0; |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
75 |
1247 | 76 virtual void AddAttachment(int64_t id, |
77 const FileInfo& attachment) = 0; | |
78 | |
79 virtual void AttachChild(int64_t parent, | |
80 int64_t child) = 0; | |
81 | |
1286 | 82 virtual void ClearChanges() = 0; |
83 | |
84 virtual void ClearExportedResources() = 0; | |
1247 | 85 |
86 virtual int64_t CreateResource(const std::string& publicId, | |
87 ResourceType type) = 0; | |
88 | |
89 virtual void DeleteAttachment(int64_t id, | |
90 FileContentType attachment) = 0; | |
91 | |
92 virtual void DeleteMetadata(int64_t id, | |
93 MetadataType type) = 0; | |
94 | |
95 virtual void DeleteResource(int64_t id) = 0; | |
96 | |
97 virtual void FlushToDisk() = 0; | |
98 | |
1306
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1302
diff
changeset
|
99 virtual bool HasFlushToDisk() const = 0; |
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1302
diff
changeset
|
100 |
1301 | 101 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target, |
1247 | 102 int64_t id) = 0; |
103 | |
1750
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
104 virtual void GetAllInternalIds(std::list<int64_t>& target, |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
105 ResourceType resourceType) = 0; |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
106 |
1247 | 107 virtual void GetAllPublicIds(std::list<std::string>& target, |
108 ResourceType resourceType) = 0; | |
109 | |
1509
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
110 virtual void GetAllPublicIds(std::list<std::string>& target, |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
111 ResourceType resourceType, |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
112 size_t since, |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
113 size_t limit) = 0; |
1247 | 114 |
115 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/, | |
116 bool& done /*out*/, | |
117 int64_t since, | |
1302 | 118 uint32_t maxResults) = 0; |
1247 | 119 |
1301 | 120 virtual void GetChildrenInternalId(std::list<int64_t>& target, |
1247 | 121 int64_t id) = 0; |
122 | |
1301 | 123 virtual void GetChildrenPublicId(std::list<std::string>& target, |
1247 | 124 int64_t id) = 0; |
125 | |
126 virtual void GetExportedResources(std::list<ExportedResource>& target /*out*/, | |
127 bool& done /*out*/, | |
128 int64_t since, | |
1302 | 129 uint32_t maxResults) = 0; |
1247 | 130 |
131 virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/) = 0; | |
132 | |
133 virtual void GetLastExportedResource(std::list<ExportedResource>& target /*out*/) = 0; | |
134 | |
135 virtual void GetMainDicomTags(DicomMap& map, | |
136 int64_t id) = 0; | |
137 | |
138 virtual std::string GetPublicId(int64_t resourceId) = 0; | |
139 | |
140 virtual uint64_t GetResourceCount(ResourceType resourceType) = 0; | |
141 | |
142 virtual ResourceType GetResourceType(int64_t resourceId) = 0; | |
143 | |
144 virtual uint64_t GetTotalCompressedSize() = 0; | |
145 | |
146 virtual uint64_t GetTotalUncompressedSize() = 0; | |
147 | |
148 virtual bool IsExistingResource(int64_t internalId) = 0; | |
149 | |
150 virtual bool IsProtectedPatient(int64_t internalId) = 0; | |
151 | |
152 virtual void ListAvailableMetadata(std::list<MetadataType>& target, | |
153 int64_t id) = 0; | |
154 | |
1301 | 155 virtual void ListAvailableAttachments(std::list<FileContentType>& target, |
1247 | 156 int64_t id) = 0; |
157 | |
158 virtual void LogChange(int64_t internalId, | |
159 const ServerIndexChange& change) = 0; | |
160 | |
161 virtual void LogExportedResource(const ExportedResource& resource) = 0; | |
162 | |
163 virtual bool LookupAttachment(FileInfo& attachment, | |
164 int64_t id, | |
165 FileContentType contentType) = 0; | |
166 | |
167 virtual bool LookupGlobalProperty(std::string& target, | |
168 GlobalProperty property) = 0; | |
169 | |
1746 | 170 virtual void LookupIdentifier(std::list<int64_t>& result, |
171 ResourceType level, | |
172 const DicomTag& tag, | |
173 IdentifierConstraintType type, | |
174 const std::string& value) = 0; | |
1729 | 175 |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
176 virtual void LookupIdentifierRange(std::list<int64_t>& result, |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
177 ResourceType level, |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
178 const DicomTag& tag, |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
179 const std::string& start, |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
180 const std::string& end) = 0; |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
181 |
1247 | 182 virtual bool LookupMetadata(std::string& target, |
183 int64_t id, | |
184 MetadataType type) = 0; | |
185 | |
186 virtual bool LookupParent(int64_t& parentId, | |
187 int64_t resourceId) = 0; | |
188 | |
1294 | 189 virtual bool LookupResource(int64_t& id, |
190 ResourceType& type, | |
191 const std::string& publicId) = 0; | |
1247 | 192 |
193 virtual bool SelectPatientToRecycle(int64_t& internalId) = 0; | |
194 | |
195 virtual bool SelectPatientToRecycle(int64_t& internalId, | |
196 int64_t patientIdToAvoid) = 0; | |
197 | |
198 virtual void SetGlobalProperty(GlobalProperty property, | |
199 const std::string& value) = 0; | |
200 | |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
201 virtual void ClearMainDicomTags(int64_t id) = 0; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
202 |
1286 | 203 virtual void SetMainDicomTag(int64_t id, |
204 const DicomTag& tag, | |
205 const std::string& value) = 0; | |
1247 | 206 |
1713 | 207 virtual void SetIdentifierTag(int64_t id, |
208 const DicomTag& tag, | |
209 const std::string& value) = 0; | |
210 | |
1247 | 211 virtual void SetMetadata(int64_t id, |
212 MetadataType type, | |
213 const std::string& value) = 0; | |
214 | |
215 virtual void SetProtectedPatient(int64_t internalId, | |
216 bool isProtected) = 0; | |
217 | |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
218 virtual ITransaction* StartTransaction() = 0; |
1247 | 219 |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1306
diff
changeset
|
220 virtual void SetListener(IDatabaseListener& listener) = 0; |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
221 |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
222 virtual unsigned int GetDatabaseVersion() = 0; |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
223 |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
224 virtual void Upgrade(unsigned int targetVersion, |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
225 IStorageArea& storageArea) = 0; |
3020
d207f6ac1f86
tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3019
diff
changeset
|
226 |
d207f6ac1f86
tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3019
diff
changeset
|
227 virtual bool IsDiskSizeAbove(uint64_t threshold) = 0; |
3025
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
228 |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
229 virtual void FindOneChildInstance(std::vector<std::string>& instancesId, |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
230 const std::vector<std::string>& resourcesId, |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
231 ResourceType level) = 0; |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
232 |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
233 virtual void ApplyLookupPatients(std::vector<std::string>& patientsId, |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
234 const DatabaseLookup& lookup, |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
235 size_t limit) = 0; |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
236 |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
237 virtual void ApplyLookupResources(std::vector<std::string>& resourcesId, |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
238 const DatabaseLookup& lookup, |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
239 ResourceType queryLevel, |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
240 size_t limit) = 0; |
1247 | 241 }; |
242 } |