Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp @ 5213:055428d92772 db-protobuf
clarifying types of since/limit in IDatabaseWrapper
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 03 Apr 2023 11:18:55 +0200 |
parents | 1a878922404b |
children | 450ac804d3af |
comparison
equal
deleted
inserted
replaced
5212:19e916dfc767 | 5213:055428d92772 |
---|---|
231 | 231 |
232 | 232 |
233 void GetChangesInternal(std::list<ServerIndexChange>& target, | 233 void GetChangesInternal(std::list<ServerIndexChange>& target, |
234 bool& done, | 234 bool& done, |
235 SQLite::Statement& s, | 235 SQLite::Statement& s, |
236 uint32_t maxResults) | 236 uint32_t limit) |
237 { | 237 { |
238 target.clear(); | 238 target.clear(); |
239 | 239 |
240 while (target.size() < maxResults && s.Step()) | 240 while (target.size() < limit && s.Step()) |
241 { | 241 { |
242 int64_t seq = s.ColumnInt64(0); | 242 int64_t seq = s.ColumnInt64(0); |
243 ChangeType changeType = static_cast<ChangeType>(s.ColumnInt(1)); | 243 ChangeType changeType = static_cast<ChangeType>(s.ColumnInt(1)); |
244 ResourceType resourceType = static_cast<ResourceType>(s.ColumnInt(3)); | 244 ResourceType resourceType = static_cast<ResourceType>(s.ColumnInt(3)); |
245 const std::string& date = s.ColumnString(4); | 245 const std::string& date = s.ColumnString(4); |
248 std::string publicId = GetPublicId(internalId); | 248 std::string publicId = GetPublicId(internalId); |
249 | 249 |
250 target.push_back(ServerIndexChange(seq, changeType, resourceType, publicId, date)); | 250 target.push_back(ServerIndexChange(seq, changeType, resourceType, publicId, date)); |
251 } | 251 } |
252 | 252 |
253 done = !(target.size() == maxResults && s.Step()); | 253 done = !(target.size() == limit && s.Step()); |
254 } | 254 } |
255 | 255 |
256 | 256 |
257 void GetExportedResourcesInternal(std::list<ExportedResource>& target, | 257 void GetExportedResourcesInternal(std::list<ExportedResource>& target, |
258 bool& done, | 258 bool& done, |
259 SQLite::Statement& s, | 259 SQLite::Statement& s, |
260 uint32_t maxResults) | 260 uint32_t limit) |
261 { | 261 { |
262 target.clear(); | 262 target.clear(); |
263 | 263 |
264 while (target.size() < maxResults && s.Step()) | 264 while (target.size() < limit && s.Step()) |
265 { | 265 { |
266 int64_t seq = s.ColumnInt64(0); | 266 int64_t seq = s.ColumnInt64(0); |
267 ResourceType resourceType = static_cast<ResourceType>(s.ColumnInt(1)); | 267 ResourceType resourceType = static_cast<ResourceType>(s.ColumnInt(1)); |
268 std::string publicId = s.ColumnString(2); | 268 std::string publicId = s.ColumnString(2); |
269 | 269 |
278 s.ColumnString(7)); // sop instance UID | 278 s.ColumnString(7)); // sop instance UID |
279 | 279 |
280 target.push_back(resource); | 280 target.push_back(resource); |
281 } | 281 } |
282 | 282 |
283 done = !(target.size() == maxResults && s.Step()); | 283 done = !(target.size() == limit && s.Step()); |
284 } | 284 } |
285 | 285 |
286 | 286 |
287 void GetChildren(std::list<std::string>& childrenPublicIds, | 287 void GetChildren(std::list<std::string>& childrenPublicIds, |
288 int64_t id) | 288 int64_t id) |
339 | 339 |
340 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, | 340 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, |
341 std::list<std::string>* instancesId, | 341 std::list<std::string>* instancesId, |
342 const std::vector<DatabaseConstraint>& lookup, | 342 const std::vector<DatabaseConstraint>& lookup, |
343 ResourceType queryLevel, | 343 ResourceType queryLevel, |
344 size_t limit) ORTHANC_OVERRIDE | 344 uint32_t limit) ORTHANC_OVERRIDE |
345 { | 345 { |
346 LookupFormatter formatter; | 346 LookupFormatter formatter; |
347 | 347 |
348 std::string sql; | 348 std::string sql; |
349 LookupFormatter::Apply(sql, formatter, lookup, queryLevel, limit); | 349 LookupFormatter::Apply(sql, formatter, lookup, queryLevel, limit); |
507 } | 507 } |
508 | 508 |
509 | 509 |
510 virtual void GetAllPublicIds(std::list<std::string>& target, | 510 virtual void GetAllPublicIds(std::list<std::string>& target, |
511 ResourceType resourceType, | 511 ResourceType resourceType, |
512 size_t since, | 512 int64_t since, |
513 size_t limit) ORTHANC_OVERRIDE | 513 uint32_t limit) ORTHANC_OVERRIDE |
514 { | 514 { |
515 if (limit == 0) | 515 if (limit == 0) |
516 { | 516 { |
517 target.clear(); | 517 target.clear(); |
518 return; | 518 return; |
534 | 534 |
535 | 535 |
536 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/, | 536 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/, |
537 bool& done /*out*/, | 537 bool& done /*out*/, |
538 int64_t since, | 538 int64_t since, |
539 uint32_t maxResults) ORTHANC_OVERRIDE | 539 uint32_t limit) ORTHANC_OVERRIDE |
540 { | 540 { |
541 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM Changes WHERE seq>? ORDER BY seq LIMIT ?"); | 541 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM Changes WHERE seq>? ORDER BY seq LIMIT ?"); |
542 s.BindInt64(0, since); | 542 s.BindInt64(0, since); |
543 s.BindInt(1, maxResults + 1); | 543 s.BindInt(1, limit + 1); |
544 GetChangesInternal(target, done, s, maxResults); | 544 GetChangesInternal(target, done, s, limit); |
545 } | 545 } |
546 | 546 |
547 | 547 |
548 virtual void GetChildrenMetadata(std::list<std::string>& target, | 548 virtual void GetChildrenMetadata(std::list<std::string>& target, |
549 int64_t resourceId, | 549 int64_t resourceId, |
586 | 586 |
587 | 587 |
588 virtual void GetExportedResources(std::list<ExportedResource>& target, | 588 virtual void GetExportedResources(std::list<ExportedResource>& target, |
589 bool& done, | 589 bool& done, |
590 int64_t since, | 590 int64_t since, |
591 uint32_t maxResults) ORTHANC_OVERRIDE | 591 uint32_t limit) ORTHANC_OVERRIDE |
592 { | 592 { |
593 SQLite::Statement s(db_, SQLITE_FROM_HERE, | 593 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
594 "SELECT * FROM ExportedResources WHERE seq>? ORDER BY seq LIMIT ?"); | 594 "SELECT * FROM ExportedResources WHERE seq>? ORDER BY seq LIMIT ?"); |
595 s.BindInt64(0, since); | 595 s.BindInt64(0, since); |
596 s.BindInt(1, maxResults + 1); | 596 s.BindInt(1, limit + 1); |
597 GetExportedResourcesInternal(target, done, s, maxResults); | 597 GetExportedResourcesInternal(target, done, s, limit); |
598 } | 598 } |
599 | 599 |
600 | 600 |
601 virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/) ORTHANC_OVERRIDE | 601 virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/) ORTHANC_OVERRIDE |
602 { | 602 { |