diff OrthancServer/DatabaseWrapperBase.cpp @ 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 878b59270859
children
line wrap: on
line diff
--- a/OrthancServer/DatabaseWrapperBase.cpp	Tue Jul 03 15:07:41 2018 +0200
+++ b/OrthancServer/DatabaseWrapperBase.cpp	Tue Jul 03 15:59:17 2018 +0200
@@ -728,4 +728,30 @@
       target.push_back(s->ColumnInt64(0));
     }    
   }
+
+
+  void DatabaseWrapperBase::LookupIdentifierRange(std::list<int64_t>& target,
+                                                  ResourceType level,
+                                                  const DicomTag& tag,
+                                                  const std::string& start,
+                                                  const std::string& end)
+  {
+    SQLite::Statement statement(db_, SQLITE_FROM_HERE,
+                                "SELECT d.id FROM DicomIdentifiers AS d, Resources AS r WHERE "
+                                "d.id = r.internalId AND r.resourceType=? AND "
+                                "d.tagGroup=? AND d.tagElement=? AND d.value>=? AND d.value<=?");
+
+    statement.BindInt(0, level);
+    statement.BindInt(1, tag.GetGroup());
+    statement.BindInt(2, tag.GetElement());
+    statement.BindString(3, start);
+    statement.BindString(4, end);
+
+    target.clear();
+
+    while (statement.Step())
+    {
+      target.push_back(statement.ColumnInt64(0));
+    }    
+  }
 }