diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-25 16:29:00 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-06 08:38:08 +0100 |
commit | 9b84aff4b68c3cef3328c85ac12418048b169cee (patch) | |
tree | 7014f685e6a8c850f0be7965e1e656d3de72a15d /examples/maildirresource/facade.cpp | |
parent | 0a0c197ed487c343675b62dff8456932c8d5ff7f (diff) | |
download | sink-9b84aff4b68c3cef3328c85ac12418048b169cee.tar.gz sink-9b84aff4b68c3cef3328c85ac12418048b169cee.zip |
Store all BLOB properties inline.
BLOB properties had a couple of intended purposes:
* Allow large payloads to be streamed directly to disk, and then be
handled by reference.
* Allow zero-copy handling.
* Keep the database values compact so we can avoid traversing large
BLOBS.
However, they came at the cost of code-complexity, and we lost all the
benefits of our storage layer, such as transactions.
Measurements showed, that for email (the intended primary usecase),
the overhead is hardly measurable, with most parts performing
better, or at least not worse. We additionally also gain file-system
independence, which may help on other platforms.
The biggest drawback is probably that large payloads need to be written
to disk twice, because of the synchronizer queue (once for the queue,
once for the actual data).
Diffstat (limited to 'examples/maildirresource/facade.cpp')
-rw-r--r-- | examples/maildirresource/facade.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/maildirresource/facade.cpp b/examples/maildirresource/facade.cpp index 5ea3d98..ea02968 100644 --- a/examples/maildirresource/facade.cpp +++ b/examples/maildirresource/facade.cpp | |||
@@ -31,7 +31,7 @@ MaildirResourceMailFacade::MaildirResourceMailFacade(const Sink::ResourceContext | |||
31 | Sink::Log::Context ctx{"maildirfacade"}; | 31 | Sink::Log::Context ctx{"maildirfacade"}; |
32 | if (value.hasProperty(Sink::ApplicationDomain::Mail::MimeMessage::name)) { | 32 | if (value.hasProperty(Sink::ApplicationDomain::Mail::MimeMessage::name)) { |
33 | auto mail = Sink::ApplicationDomain::Mail{value}; | 33 | auto mail = Sink::ApplicationDomain::Mail{value}; |
34 | const auto mimeMessage = mail.getMimeMessagePath(); | 34 | const auto mimeMessage = mail.getMimeMessage(); |
35 | //Transform the mime message property into the actual path on disk. | 35 | //Transform the mime message property into the actual path on disk. |
36 | auto parts = mimeMessage.split('/'); | 36 | auto parts = mimeMessage.split('/'); |
37 | auto key = parts.takeLast(); | 37 | auto key = parts.takeLast(); |
@@ -45,7 +45,10 @@ MaildirResourceMailFacade::MaildirResourceMailFacade(const Sink::ResourceContext | |||
45 | SinkErrorCtx(ctx) << "Failed to find message. Directory: " << path << "Key: " << key << "Number of matching files: " << list.size(); | 45 | SinkErrorCtx(ctx) << "Failed to find message. Directory: " << path << "Key: " << key << "Number of matching files: " << list.size(); |
46 | mail.setProperty(Sink::ApplicationDomain::Mail::MimeMessage::name, QVariant()); | 46 | mail.setProperty(Sink::ApplicationDomain::Mail::MimeMessage::name, QVariant()); |
47 | } else { | 47 | } else { |
48 | mail.setMimeMessagePath(list.at(0).filePath()); | 48 | QFile file{list.at(0).filePath()}; |
49 | if (file.open(QIODevice::ReadOnly)) { | ||
50 | mail.setMimeMessage(file.readAll()); | ||
51 | } | ||
49 | } | 52 | } |
50 | } | 53 | } |
51 | value.setChangedProperties(QSet<QByteArray>()); | 54 | value.setChangedProperties(QSet<QByteArray>()); |