annotate Framework/Plugins/StorageBackend.h @ 522:c49136b34891 large-queries tip

use a prepared statement for InsertOrUpdateMetadata
author Alain Mazy <am@orthanc.team>
date Fri, 05 Jul 2024 09:15:54 +0200
parents 54d518dcd74a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
507
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
459
ecd0b719cff5 update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 389
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU Affero General Public License
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * as published by the Free Software Foundation, either version 3 of
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * the License, or (at your option) any later version.
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * Affero General Public License for more details.
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU Affero General Public License
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../Common/DatabaseManager.h"
194
a51ce147dbe0 refactoring using new class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
27
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <orthanc/OrthancCDatabasePlugin.h>
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
231
0a9b48d19643 removed mutex out of DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
30 #include <boost/thread/mutex.hpp>
0a9b48d19643 removed mutex out of DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
31
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 namespace OrthancDatabases
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 class StorageBackend : public boost::noncopyable
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 public:
219
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
38 class IFileContentVisitor : public boost::noncopyable
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
39 {
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
40 public:
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
41 virtual ~IFileContentVisitor()
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
42 {
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
43 }
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
44
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
45 virtual void Assign(const std::string& content) = 0;
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
46
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
47 virtual bool IsSuccess() const = 0;
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
48 };
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
49
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
50 class IAccessor : public boost::noncopyable
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
51 {
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
52 public:
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
53 virtual ~IAccessor()
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
54 {
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
55 }
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
56
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
57 virtual void Create(const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
58 const void* content,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
59 size_t size,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
60 OrthancPluginContentType type) = 0;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
61
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
62 virtual void ReadWhole(IFileContentVisitor& visitor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
63 const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
64 OrthancPluginContentType type) = 0;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
65
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
66 virtual void ReadRange(IFileContentVisitor& visitor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
67 const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
68 OrthancPluginContentType type,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
69 uint64_t start,
246
483af3f35a4b turning ResultFileValue into a base class, and implement its primitives for PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
70 size_t length) = 0;
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
71
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
72 virtual void Remove(const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
73 OrthancPluginContentType type) = 0;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
74 };
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
75
269
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
76 /**
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
77 * This class is similar to
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
78 * "Orthanc::StatelessDatabaseOperations": It handles retries of
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
79 * transactions in the case of collision between multiple
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
80 * readers/writers.
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
81 **/
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
82 class IDatabaseOperation : public boost::noncopyable
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
83 {
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
84 public:
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
85 virtual ~IDatabaseOperation()
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
86 {
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
87 }
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
88
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
89 virtual void Execute(IAccessor& accessor) = 0;
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
90 };
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
91
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
92 class ReadWholeOperation;
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
93
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
94 private:
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
95 class StringVisitor;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
96
255
d663d9e44f8d reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 252
diff changeset
97 boost::mutex mutex_;
d663d9e44f8d reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 252
diff changeset
98 DatabaseManager manager_;
269
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
99 unsigned int maxRetries_;
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
100
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
101 protected:
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
102 class AccessorBase : public IAccessor
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
103 {
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
104 private:
231
0a9b48d19643 removed mutex out of DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
105 boost::mutex::scoped_lock lock_;
0a9b48d19643 removed mutex out of DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
106 DatabaseManager& manager_;
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
107
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
108 public:
252
33fa478c119a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
109 explicit AccessorBase(StorageBackend& backend) :
231
0a9b48d19643 removed mutex out of DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
110 lock_(backend.mutex_),
255
d663d9e44f8d reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 252
diff changeset
111 manager_(backend.manager_)
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
112 {
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
113 }
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
114
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
115 DatabaseManager& GetManager() const
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
116 {
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
117 return manager_;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
118 }
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
119
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
120 virtual void Create(const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
121 const void* content,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
122 size_t size,
252
33fa478c119a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
123 OrthancPluginContentType type) ORTHANC_OVERRIDE;
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
124
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
125 virtual void ReadWhole(IFileContentVisitor& visitor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
126 const std::string& uuid,
252
33fa478c119a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
127 OrthancPluginContentType type) ORTHANC_OVERRIDE;
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
128
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
129 virtual void ReadRange(IFileContentVisitor& visitor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
130 const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
131 OrthancPluginContentType type,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
132 uint64_t start,
252
33fa478c119a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
133 size_t length) ORTHANC_OVERRIDE;
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
134
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
135 virtual void Remove(const std::string& uuid,
252
33fa478c119a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
136 OrthancPluginContentType type) ORTHANC_OVERRIDE;
219
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
137 };
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
138
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
139 virtual bool HasReadRange() const = 0;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
140
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
141 public:
269
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
142 StorageBackend(IDatabaseFactory* factory /* takes ownership */,
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
143 unsigned int maxRetries);
255
d663d9e44f8d reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 252
diff changeset
144
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 virtual ~StorageBackend()
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 {
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 }
12
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
148
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
149 virtual IAccessor* CreateAccessor()
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
150 {
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
151 return new AccessorBase(*this);
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
152 }
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
153
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 static void Register(OrthancPluginContext* context,
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 StorageBackend* backend); // Takes ownership
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 static void Finalize();
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
158
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
159 // For unit tests
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
160 static void ReadWholeToString(std::string& target,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
161 IAccessor& accessor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
162 const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
163 OrthancPluginContentType type);
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
164
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
165 // For unit tests
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
166 static void ReadRangeToString(std::string& target,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
167 IAccessor& accessor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
168 const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
169 OrthancPluginContentType type,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
170 uint64_t start,
246
483af3f35a4b turning ResultFileValue into a base class, and implement its primitives for PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
171 size_t length);
269
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
172
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
173 unsigned int GetMaxRetries() const
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
174 {
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
175 return maxRetries_;
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
176 }
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
177
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
178 void Execute(IDatabaseOperation& operation);
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 };
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 }