diff --git a/src/blobstore/implementations/ondisk/OnDiskBlobStore.cpp b/src/blobstore/implementations/ondisk/OnDiskBlobStore.cpp index c05ca0af..ee306cda 100644 --- a/src/blobstore/implementations/ondisk/OnDiskBlobStore.cpp +++ b/src/blobstore/implementations/ondisk/OnDiskBlobStore.cpp @@ -10,9 +10,11 @@ namespace ondisk { OnDiskBlobStore::OnDiskBlobStore(const boost::filesystem::path &rootdir) : _rootdir(rootdir) {} -unique_ptr OnDiskBlobStore::create(const std::string &key, size_t size) { +BlobStore::BlobWithKey OnDiskBlobStore::create(const std::string &key, size_t size) { auto file_path = _rootdir / key; - return OnDiskBlob::CreateOnDisk(file_path, size); + auto blob = OnDiskBlob::CreateOnDisk(file_path, size); + + return BlobStore::BlobWithKey(key, std::move(blob)); } unique_ptr OnDiskBlobStore::load(const std::string &key) { diff --git a/src/blobstore/implementations/ondisk/OnDiskBlobStore.h b/src/blobstore/implementations/ondisk/OnDiskBlobStore.h index d636713a..0764bdd2 100644 --- a/src/blobstore/implementations/ondisk/OnDiskBlobStore.h +++ b/src/blobstore/implementations/ondisk/OnDiskBlobStore.h @@ -16,7 +16,7 @@ class OnDiskBlobStore: public BlobStore { public: OnDiskBlobStore(const boost::filesystem::path &rootdir); - std::unique_ptr create(const std::string &key, size_t size) override; + BlobWithKey create(const std::string &key, size_t size) override; std::unique_ptr load(const std::string &key) override; private: diff --git a/src/blobstore/interface/BlobStore.h b/src/blobstore/interface/BlobStore.h index 213a413f..16d4f9dc 100644 --- a/src/blobstore/interface/BlobStore.h +++ b/src/blobstore/interface/BlobStore.h @@ -5,8 +5,9 @@ #include #include +#include "Blob.h" + namespace blobstore { -class Blob; //TODO Don't use string, but own class for keys? (better performance for all keys have same length) @@ -14,7 +15,14 @@ class BlobStore { public: virtual ~BlobStore() {} - virtual std::unique_ptr create(const std::string &key, size_t size) = 0; + struct BlobWithKey { + BlobWithKey(const std::string &key_, std::unique_ptr &&blob_): key(key_), blob(std::move(blob_)) {} + + std::string key; + std::unique_ptr blob; + }; + + virtual BlobWithKey create(const std::string &key, size_t size) = 0; virtual std::unique_ptr load(const std::string &key) = 0; //TODO Needed for performance? Or is deleting loaded blobs enough? //virtual void remove(const std::string &key) = 0;