comparison OrthancServer/ServerContext.cpp @ 3003:5ae3ff2398e9

refactoring OrthancFindRequestHandler using LookupResource::IVisitor
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Dec 2018 19:02:51 +0100
parents 7695a9c81099
children 8265a6b56100
comparison
equal deleted inserted replaced
3002:9ceb7dafae2e 3003:5ae3ff2398e9
779 size_t limit) 779 size_t limit)
780 { 780 {
781 std::vector<std::string> resources, instances; 781 std::vector<std::string> resources, instances;
782 GetIndex().FindCandidates(resources, instances, lookup); 782 GetIndex().FindCandidates(resources, instances, lookup);
783 783
784 LOG(INFO) << "Number of candidate resources after fast DB filtering: " << resources.size();
785
784 assert(resources.size() == instances.size()); 786 assert(resources.size() == instances.size());
785 787
786 size_t countResults = 0; 788 size_t countResults = 0;
787 size_t skipped = 0; 789 size_t skipped = 0;
790 bool complete = true;
788 791
789 for (size_t i = 0; i < instances.size(); i++) 792 for (size_t i = 0; i < instances.size(); i++)
790 { 793 {
791 // TODO - Don't read the full JSON from the disk if only "main 794 // TODO - Don't read the full JSON from the disk if only "main
792 // DICOM tags" are to be returned 795 // DICOM tags" are to be returned
800 skipped++; 803 skipped++;
801 } 804 }
802 else if (limit != 0 && 805 else if (limit != 0 &&
803 countResults >= limit) 806 countResults >= limit)
804 { 807 {
805 return; // too many results, don't mark as complete 808 // Too many results, don't mark as complete
809 complete = false;
810 break;
806 } 811 }
807 else 812 else
808 { 813 {
809 visitor.Visit(resources[i], dicom); 814 visitor.Visit(resources[i], instances[i], dicom);
810 countResults ++; 815 countResults ++;
811 } 816 }
812 } 817 }
813 } 818 }
814 819
815 visitor.MarkAsComplete(); 820 if (complete)
821 {
822 visitor.MarkAsComplete();
823 }
824
825 LOG(INFO) << "Number of matching resources: " << countResults;
816 } 826 }
817 827
818 828
819 void ServerContext::AddChildInstances(SetOfInstancesJob& job, 829 void ServerContext::AddChildInstances(SetOfInstancesJob& job,
820 const std::string& publicId) 830 const std::string& publicId)