Mercurial > hg > orthanc
changeset 7172:b7a765bb2812
Reduced the number of SQL queries in ServerContext::ReadDicomUntilPixelData
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Tue, 20 Oct 2026 09:48:12 +0200 |
| parents | 752b2dc9f6b1 |
| children | 745b6573db71 |
| files | NEWS OrthancServer/Sources/ServerContext.cpp |
| diffstat | 2 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Tue Oct 20 09:27:07 2026 +0200 +++ b/NEWS Tue Oct 20 09:48:12 2026 +0200 @@ -39,6 +39,7 @@ could keep the job in a "processing" state forever. * Fixed preview of YBR_FULL images encoded in JPEG-LS (https://discourse.orthanc-server.org/t/orthanc-preview-does-not-show-correctly/6488) +* Reduced the number of SQL queries when accessing /instances/../tags * Fix use of the static runtime under Visual Studio (/MT), which broke in 1.12.10 * New CMake options: - "THIRD_PARTY_DOWNLOADS_ROOT_URL" to specify another webserver to downloads the third-parties from.
--- a/OrthancServer/Sources/ServerContext.cpp Tue Oct 20 09:27:07 2026 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Tue Oct 20 09:48:12 2026 +0200 @@ -1853,22 +1853,28 @@ DicomDataSource::Dicom* ServerContext::ReadDicomUntilPixelData(const std::string& instancePublicId) { + FindRequest findInstanceRequest(ResourceType_Instance); + findInstanceRequest.SetOrthancId(ResourceType_Instance, instancePublicId); + findInstanceRequest.SetRetrieveAttachments(true); + findInstanceRequest.SetRetrieveMetadata(true); + + FindResponse findInstanceResponse; + index_.ExecuteFind(findInstanceResponse, findInstanceRequest); + const FindResponse::Resource& instance = findInstanceResponse.GetResourceByIdentifier(instancePublicId); + FileInfo attachment; int64_t revision; // Ignored - if (index_.LookupAttachment(attachment, revision, ResourceType_Instance, - instancePublicId, FileContentType_DicomUntilPixelData)) + if (instance.LookupAttachment(attachment, revision, FileContentType_DicomUntilPixelData)) { return DicomDataSource::Execute(*dicomReader_, DicomDataSource::CreateWholeRequest(attachment)); } - else + else if (instance.LookupAttachment(attachment, revision, FileContentType_Dicom)) { - attachment = LookupDicomForInstance(instancePublicId); - std::string metadata; if (attachment.GetCompressionType() == CompressionType_None && - index_.LookupMetadata(metadata, instancePublicId, ResourceType_Instance, + instance.LookupMetadata(metadata, ResourceType_Instance, MetadataType_Instance_PixelDataOffset) && !metadata.empty()) { @@ -1887,6 +1893,12 @@ // Fallback: The pixel data offset is not present or cannot be used, the whole DICOM file must be read return DicomDataSource::Execute(*dicomReader_, DicomDataSource::CreateWholeRequest(attachment)); } + else + { + throw OrthancException(ErrorCode_InternalError, + "Unable to read attachment " + EnumerationToString(FileContentType_Dicom) + + " of instance " + instancePublicId); + } }
