changeset 5692:7c11a71927a9 find-refactoring

improved handling of limits
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 11 Jul 2024 20:20:50 +0200
parents c352d762177c
children 023787ecaff2
files OrthancServer/Sources/Database/FindRequest.h OrthancServer/Sources/ResourceFinder.cpp
diffstat 2 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/FindRequest.h	Tue Jul 09 18:06:21 2024 +0200
+++ b/OrthancServer/Sources/Database/FindRequest.h	Thu Jul 11 20:20:50 2024 +0200
@@ -314,6 +314,11 @@
       return metadataConstraints_.size();
     }
 
+    void ClearLimits()
+    {
+      hasLimits_ = false;
+    }
+
     void SetLimits(uint64_t since,
                    uint64_t count);
 
--- a/OrthancServer/Sources/ResourceFinder.cpp	Tue Jul 09 18:06:21 2024 +0200
+++ b/OrthancServer/Sources/ResourceFinder.cpp	Thu Jul 11 20:20:50 2024 +0200
@@ -431,18 +431,20 @@
     {
       request_.SetLimits(0, databaseLimits_ + 1);
     }
-
-    if (lookup_.get() == NULL ||
-        lookup_->HasOnlyMainDicomTags())
+    else
     {
-      // TODO-FIND: Understand why this doesn't work:
-      // $ ./Start.sh --force Orthanc.test_rest_find_limit Orthanc.test_resources_since_limit Orthanc.test_rest_find_limit
+      request_.ClearLimits();
+    }
 
-      /*if (hasLimits_)
+    if (hasLimits_)
+    {
+      if (lookup_.get() == NULL)
       {
         isDatabasePaging_ = true;
         request_.SetLimits(limitsSince_, limitsCount_);
-        }*/
+      }
+
+      // TODO-FIND: enable database paging on "simple" lookups that involve no normalization
     }
 
     // TODO-FIND: More cases could be added, depending on "GetDatabaseCapabilities()"
@@ -527,7 +529,6 @@
   void ResourceFinder::SetDatabaseLookup(const DatabaseLookup& lookup)
   {
     lookup_.reset(lookup.Clone());
-    UpdateRequestLimits();
 
     for (size_t i = 0; i < lookup.GetConstraintsCount(); i++)
     {
@@ -567,6 +568,8 @@
         throw OrthancException(ErrorCode_InternalError);
       }
     }
+
+    UpdateRequestLimits();
   }