Mercurial > hg > orthanc
diff OrthancServer/Search/LookupIdentifierQuery.h @ 2697:e583478e0c6c jobs
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 03 Jul 2018 15:59:17 +0200 |
parents | 1b736d151ea1 |
children | 7695a9c81099 |
line wrap: on
line diff
--- a/OrthancServer/Search/LookupIdentifierQuery.h Tue Jul 03 15:07:41 2018 +0200 +++ b/OrthancServer/Search/LookupIdentifierQuery.h Tue Jul 03 15:59:17 2018 +0200 @@ -65,8 +65,11 @@ class LookupIdentifierQuery : public boost::noncopyable { + // This class encodes a conjunction ("AND") of disjunctions. Each + // disjunction represents an "OR" of several constraints. + public: - class Constraint + class SingleConstraint { private: DicomTag tag_; @@ -74,9 +77,9 @@ std::string value_; public: - Constraint(const DicomTag& tag, - IdentifierConstraintType type, - const std::string& value) : + SingleConstraint(const DicomTag& tag, + IdentifierConstraintType type, + const std::string& value) : tag_(tag), type_(type), value_(ServerToolbox::NormalizeIdentifier(value)) @@ -100,10 +103,45 @@ }; + class RangeConstraint + { + private: + DicomTag tag_; + std::string start_; + std::string end_; + + public: + RangeConstraint(const DicomTag& tag, + const std::string& start, + const std::string& end) : + tag_(tag), + start_(ServerToolbox::NormalizeIdentifier(start)), + end_(ServerToolbox::NormalizeIdentifier(end)) + { + } + + const DicomTag& GetTag() const + { + return tag_; + } + + const std::string& GetStart() const + { + return start_; + } + + const std::string& GetEnd() const + { + return end_; + } + }; + + class Disjunction : public boost::noncopyable { private: - std::vector<Constraint*> constraints_; + std::vector<SingleConstraint*> singleConstraints_; + std::vector<RangeConstraint*> rangeConstraints_; public: ~Disjunction(); @@ -112,23 +150,37 @@ IdentifierConstraintType type, const std::string& value); - size_t GetSize() const + void AddRange(const DicomTag& tag, + const std::string& start, + const std::string& end); + + size_t GetSingleConstraintsCount() const { - return constraints_.size(); + return singleConstraints_.size(); } - const Constraint& GetConstraint(size_t i) const + const SingleConstraint& GetSingleConstraint(size_t i) const + { + return *singleConstraints_[i]; + } + + size_t GetRangeConstraintsCount() const { - return *constraints_[i]; + return rangeConstraints_.size(); + } + + const RangeConstraint& GetRangeConstraint(size_t i) const + { + return *rangeConstraints_[i]; } }; private: - typedef std::vector<Disjunction*> Disjuntions; + typedef std::vector<Disjunction*> Disjunctions; ResourceType level_; - Disjuntions disjuntions_; + Disjunctions disjunctions_; public: LookupIdentifierQuery(ResourceType level) : level_(level) @@ -146,6 +198,10 @@ IdentifierConstraintType type, const std::string& value); + void AddRange(DicomTag tag, + const std::string& start, + const std::string& end); + Disjunction& AddDisjunction(); ResourceType GetLevel() const @@ -153,11 +209,6 @@ return level_; } - size_t GetSize() const - { - return disjuntions_.size(); - } - // The database must be locked void Apply(std::list<std::string>& result, IDatabaseWrapper& database);