# HG changeset patch # User Sebastien Jodogne # Date 1539108575 -7200 # Node ID ae8e72009e64b2e25436e9778bf532e1c19a67b4 # Parent edfd98a2b6c4a15837b5b00f33d74869931d5626 notes diff -r edfd98a2b6c4 -r ae8e72009e64 OrthancServer/OrthancFindRequestHandler.cpp --- a/OrthancServer/OrthancFindRequestHandler.cpp Tue Oct 09 16:44:28 2018 +0200 +++ b/OrthancServer/OrthancFindRequestHandler.cpp Tue Oct 09 20:09:35 2018 +0200 @@ -588,7 +588,7 @@ * Build up the query object. **/ - LookupResource finder(level); + LookupResource lookup(level); const bool caseSensitivePN = Configuration::GetGlobalBoolParameter("CaseSensitivePN", false); @@ -623,7 +623,7 @@ sensitive = caseSensitivePN; } - finder.AddDicomConstraint(tag, value, sensitive); + lookup.AddDicomConstraint(tag, value, sensitive); } else { @@ -637,10 +637,12 @@ * Run the query. **/ - size_t maxResults = (level == ResourceType_Instance) ? maxInstances_ : maxResults_; + size_t limit = (level == ResourceType_Instance) ? maxInstances_ : maxResults_; + // TODO - Use ServerContext::Apply() at this point, in order to + // share the code with the "/tools/find" REST URI std::vector resources, instances; - context_.GetIndex().FindCandidates(resources, instances, finder); + context_.GetIndex().FindCandidates(resources, instances, lookup); LOG(INFO) << "Number of candidate resources after fast DB filtering: " << resources.size(); @@ -654,10 +656,10 @@ Json::Value dicom; context_.ReadDicomAsJson(dicom, instances[i]); - if (finder.IsMatch(dicom)) + if (lookup.IsMatch(dicom)) { - if (maxResults != 0 && - answers.GetSize() >= maxResults) + if (limit != 0 && + answers.GetSize() >= limit) { complete = false; break; diff -r edfd98a2b6c4 -r ae8e72009e64 OrthancServer/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Tue Oct 09 16:44:28 2018 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Tue Oct 09 20:09:35 2018 +0200 @@ -1334,9 +1334,10 @@ request["Query"][members[i]].asString(), caseSensitive); } - + + bool isComplete; std::list resources; - context.Apply(resources, query, since, limit); + context.Apply(isComplete, resources, query, since, limit); AnswerListOfResources(call.GetOutput(), context.GetIndex(), resources, query.GetLevel(), expand); } diff -r edfd98a2b6c4 -r ae8e72009e64 OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Tue Oct 09 16:44:28 2018 +0200 +++ b/OrthancServer/ServerContext.cpp Tue Oct 09 20:09:35 2018 +0200 @@ -766,12 +766,14 @@ } - void ServerContext::Apply(std::list& result, + void ServerContext::Apply(bool& isComplete, + std::list& result, const ::Orthanc::LookupResource& lookup, size_t since, size_t limit) { result.clear(); + isComplete = true; std::vector resources, instances; GetIndex().FindCandidates(resources, instances, lookup); @@ -781,6 +783,8 @@ size_t skipped = 0; for (size_t i = 0; i < instances.size(); i++) { + // TODO - Don't read the full JSON from the disk if only "main + // DICOM tags" are to be returned Json::Value dicom; ReadDicomAsJson(dicom, instances[i]); @@ -793,6 +797,7 @@ else if (limit != 0 && result.size() >= limit) { + isComplete = false; return; // too many results } else diff -r edfd98a2b6c4 -r ae8e72009e64 OrthancServer/ServerContext.h --- a/OrthancServer/ServerContext.h Tue Oct 09 16:44:28 2018 +0200 +++ b/OrthancServer/ServerContext.h Tue Oct 09 20:09:35 2018 +0200 @@ -321,7 +321,8 @@ void Stop(); - void Apply(std::list& result, + void Apply(bool& isComplete, + std::list& result, const ::Orthanc::LookupResource& lookup, size_t since, size_t limit);