From 36458f35bf1d9bdf24be9fcdf6bbf859fdd7b0f9 Mon Sep 17 00:00:00 2001 From: liuqi Date: Sun, 8 Apr 2018 09:54:58 +0800 Subject: [PATCH] KVStorage Find api return const vector pointer. --- mace/core/file_storage.cc | 3 +-- mace/core/file_storage.h | 2 +- mace/public/mace_runtime.h | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mace/core/file_storage.cc b/mace/core/file_storage.cc index eb48cfed..d0030d2b 100644 --- a/mace/core/file_storage.cc +++ b/mace/core/file_storage.cc @@ -104,7 +104,6 @@ void FileStorage::Load() { if (res != 0) { LOG(WARNING) << "munmap file " << file_path_ << " failed, error code: " << errno; - return; } res = close(fd); if (res != 0) { @@ -119,7 +118,7 @@ bool FileStorage::Insert(const std::string &key, return true; } -std::vector *FileStorage::Find(const std::string &key) { +const std::vector *FileStorage::Find(const std::string &key) { auto iter = data_.find(key); if (iter == data_.end()) return nullptr; diff --git a/mace/core/file_storage.h b/mace/core/file_storage.h index b1c90b50..7c777e7e 100644 --- a/mace/core/file_storage.h +++ b/mace/core/file_storage.h @@ -21,7 +21,7 @@ class FileStorage : public KVStorage { void Load() override; bool Insert(const std::string &key, const std::vector &value) override; - std::vector *Find(const std::string &key) override; + const std::vector *Find(const std::string &key) override; void Flush() override; private: diff --git a/mace/public/mace_runtime.h b/mace/public/mace_runtime.h index 55397701..46500994 100644 --- a/mace/public/mace_runtime.h +++ b/mace/public/mace_runtime.h @@ -36,7 +36,7 @@ class KVStorage { virtual void Load() = 0; virtual bool Insert(const std::string &key, const std::vector &value) = 0; - virtual std::vector *Find(const std::string &key) = 0; + virtual const std::vector *Find(const std::string &key) = 0; virtual void Flush() = 0; }; -- GitLab