Mercurial > hg > orthanc
diff OrthancServer/Sources/ServerContext.cpp @ 4810:7afbb54bd028
merge storage-cache
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 23 Nov 2021 09:22:11 +0100 |
parents | 0bd98c52474b 434843934307 |
children | 70d2a97ca8cb 7053502fbf97 |
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerContext.cpp Tue Nov 23 09:20:59 2021 +0100 +++ b/OrthancServer/Sources/ServerContext.cpp Tue Nov 23 09:22:11 2021 +0100 @@ -492,7 +492,7 @@ void ServerContext::RemoveFile(const std::string& fileUuid, FileContentType type) { - StorageAccessor accessor(area_, GetMetricsRegistry()); + StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); accessor.Remove(fileUuid, type); } @@ -534,7 +534,7 @@ try { MetricsRegistry::Timer timer(GetMetricsRegistry(), "orthanc_store_dicom_duration_ms"); - StorageAccessor accessor(area_, GetMetricsRegistry()); + StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); DicomInstanceHasher hasher(summary); resultPublicId = hasher.HashInstance(); @@ -781,7 +781,7 @@ } else { - StorageAccessor accessor(area_, GetMetricsRegistry()); + StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); accessor.AnswerFile(output, attachment, GetFileContentMime(content)); } } @@ -811,7 +811,7 @@ std::string content; - StorageAccessor accessor(area_, GetMetricsRegistry()); + StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); accessor.Read(content, attachment); FileInfo modified = accessor.Write(content.empty() ? NULL : content.c_str(), @@ -867,7 +867,7 @@ std::string dicom; { - StorageAccessor accessor(area_, GetMetricsRegistry()); + StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); accessor.Read(dicom, attachment); } @@ -932,8 +932,8 @@ std::unique_ptr<IMemoryBuffer> dicom; { - MetricsRegistry::Timer timer(GetMetricsRegistry(), "orthanc_storage_read_range_duration_ms"); - dicom.reset(area_.ReadRange(attachment.GetUuid(), FileContentType_Dicom, 0, pixelDataOffset)); + StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); + dicom.reset(accessor.ReadStartRange(attachment.GetUuid(), FileContentType_Dicom, pixelDataOffset, FileContentType_DicomUntilPixelData)); } if (dicom.get() == NULL) @@ -962,7 +962,7 @@ std::string dicomAsJson; { - StorageAccessor accessor(area_, GetMetricsRegistry()); + StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); accessor.Read(dicomAsJson, attachment); } @@ -1031,7 +1031,15 @@ int64_t revision; ReadAttachment(dicom, revision, instancePublicId, FileContentType_Dicom, true /* uncompress */); } - + + void ServerContext::ReadDicomForHeader(std::string& dicom, + const std::string& instancePublicId) + { + if (!ReadDicomUntilPixelData(dicom, instancePublicId)) + { + ReadDicom(dicom, instancePublicId); + } + } bool ServerContext::ReadDicomUntilPixelData(std::string& dicom, const std::string& instancePublicId) @@ -1060,8 +1068,10 @@ { uint64_t pixelDataOffset = boost::lexical_cast<uint64_t>(s); + StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); + std::unique_ptr<IMemoryBuffer> buffer( - area_.ReadRange(attachment.GetUuid(), attachment.GetContentType(), 0, pixelDataOffset)); + accessor.ReadStartRange(attachment.GetUuid(), attachment.GetContentType(), pixelDataOffset, FileContentType_DicomUntilPixelData)); buffer->MoveToString(dicom); return true; // Success } @@ -1092,7 +1102,7 @@ assert(attachment.GetContentType() == content); { - StorageAccessor accessor(area_, GetMetricsRegistry()); + StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); if (uncompressIfNeeded) { @@ -1192,7 +1202,7 @@ // TODO Should we use "gzip" instead? CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None); - StorageAccessor accessor(area_, GetMetricsRegistry()); + StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); FileInfo attachment = accessor.Write(data, size, attachmentType, compression, storeMD5_); try