提交 1d18c0a9 编写于 作者: Y yudong.cai

#1547 rename storage/file to storage/disk

Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>
上级 aaf7f487
......@@ -106,11 +106,11 @@ set(web_server_files
)
aux_source_directory(${MILVUS_ENGINE_SRC}/storage storage_main_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/storage/file storage_file_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/storage/disk storage_disk_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/storage/s3 storage_s3_files)
set(storage_files
${storage_main_files}
${storage_file_files}
${storage_disk_files}
${storage_s3_files}
)
......
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#pragma once
#include <string>
#include <vector>
#include "utils/Status.h"
namespace milvus {
namespace storage {
class IStorage {
public:
virtual Status
CreateBucket() = 0;
virtual Status
DeleteBucket() = 0;
virtual Status
PutObjectFile(const std::string& object_name, const std::string& file_path) = 0;
virtual Status
PutObjectStr(const std::string& object_name, const std::string& content) = 0;
virtual Status
GetObjectFile(const std::string& object_name, const std::string& file_path) = 0;
virtual Status
GetObjectStr(const std::string& object_name, std::string& content) = 0;
virtual Status
ListObjects(std::vector<std::string>& object_list, const std::string& marker = "") = 0;
virtual Status
DeleteObject(const std::string& object_name) = 0;
virtual Status
DeleteObjects(const std::string& marker) = 0;
};
} // namespace storage
} // namespace milvus
......@@ -9,31 +9,31 @@
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#include "storage/file/FileIOReader.h"
#include "storage/disk/DiskIOReader.h"
namespace milvus {
namespace storage {
FileIOReader::FileIOReader(const std::string& name) : IOReader(name) {
DiskIOReader::DiskIOReader(const std::string& name) : IOReader(name) {
fs_ = std::fstream(name_, std::ios::in | std::ios::binary);
}
FileIOReader::~FileIOReader() {
DiskIOReader::~DiskIOReader() {
fs_.close();
}
void
FileIOReader::read(void* ptr, size_t size) {
DiskIOReader::read(void* ptr, size_t size) {
fs_.read(reinterpret_cast<char*>(ptr), size);
}
void
FileIOReader::seekg(size_t pos) {
DiskIOReader::seekg(size_t pos) {
fs_.seekg(pos);
}
size_t
FileIOReader::length() {
DiskIOReader::length() {
fs_.seekg(0, fs_.end);
return fs_.tellg();
}
......
......@@ -18,10 +18,10 @@
namespace milvus {
namespace storage {
class FileIOReader : public IOReader {
class DiskIOReader : public IOReader {
public:
explicit FileIOReader(const std::string& name);
~FileIOReader();
explicit DiskIOReader(const std::string& name);
~DiskIOReader();
void
read(void* ptr, size_t size) override;
......
......@@ -9,27 +9,27 @@
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#include "storage/file/FileIOWriter.h"
#include "storage/disk/DiskIOWriter.h"
namespace milvus {
namespace storage {
FileIOWriter::FileIOWriter(const std::string& name) : IOWriter(name) {
DiskIOWriter::DiskIOWriter(const std::string& name) : IOWriter(name) {
fs_ = std::fstream(name_, std::ios::out | std::ios::binary);
}
FileIOWriter::~FileIOWriter() {
DiskIOWriter::~DiskIOWriter() {
fs_.close();
}
void
FileIOWriter::write(void* ptr, size_t size) {
DiskIOWriter::write(void* ptr, size_t size) {
fs_.write(reinterpret_cast<char*>(ptr), size);
len_ += size;
}
size_t
FileIOWriter::length() {
DiskIOWriter::length() {
return len_;
}
......
......@@ -18,10 +18,10 @@
namespace milvus {
namespace storage {
class FileIOWriter : public IOWriter {
class DiskIOWriter : public IOWriter {
public:
explicit FileIOWriter(const std::string& name);
~FileIOWriter();
explicit DiskIOWriter(const std::string& name);
~DiskIOWriter();
void
write(void* ptr, size_t size) override;
......
......@@ -16,12 +16,13 @@
#include <memory>
#include <string>
#include <vector>
#include "storage/IStorage.h"
#include "utils/Status.h"
namespace milvus {
namespace storage {
class S3ClientWrapper : public IStorage {
class S3ClientWrapper {
public:
static S3ClientWrapper&
GetInstance() {
......@@ -35,23 +36,23 @@ class S3ClientWrapper : public IStorage {
StopService();
Status
CreateBucket() override;
CreateBucket();
Status
DeleteBucket() override;
DeleteBucket();
Status
PutObjectFile(const std::string& object_key, const std::string& file_path) override;
PutObjectFile(const std::string& object_key, const std::string& file_path);
Status
PutObjectStr(const std::string& object_key, const std::string& content) override;
PutObjectStr(const std::string& object_key, const std::string& content);
Status
GetObjectFile(const std::string& object_key, const std::string& file_path) override;
GetObjectFile(const std::string& object_key, const std::string& file_path);
Status
GetObjectStr(const std::string& object_key, std::string& content) override;
GetObjectStr(const std::string& object_key, std::string& content);
Status
ListObjects(std::vector<std::string>& object_list, const std::string& marker = "") override;
ListObjects(std::vector<std::string>& object_list, const std::string& marker = "");
Status
DeleteObject(const std::string& object_key) override;
DeleteObject(const std::string& object_key);
Status
DeleteObjects(const std::string& marker) override;
DeleteObjects(const std::string& marker);
private:
std::shared_ptr<Aws::S3::S3Client> client_ptr_;
......
......@@ -23,8 +23,8 @@
#include "knowhere/index/vector_index/IndexNSG.h"
#include "knowhere/index/vector_index/IndexSPTAG.h"
#include "server/Config.h"
#include "storage/file/FileIOReader.h"
#include "storage/file/FileIOWriter.h"
#include "storage/disk/DiskIOReader.h"
#include "storage/disk/DiskIOWriter.h"
#include "storage/s3/S3IOReader.h"
#include "storage/s3/S3IOWriter.h"
#include "utils/Exception.h"
......@@ -181,7 +181,7 @@ read_index(const std::string& location) {
if (s3_enable) {
reader_ptr = std::make_shared<storage::S3IOReader>(location);
} else {
reader_ptr = std::make_shared<storage::FileIOReader>(location);
reader_ptr = std::make_shared<storage::DiskIOReader>(location);
}
recorder.RecordSection("Start");
......@@ -254,7 +254,7 @@ write_index(VecIndexPtr index, const std::string& location) {
if (s3_enable) {
writer_ptr = std::make_shared<storage::S3IOWriter>(location);
} else {
writer_ptr = std::make_shared<storage::FileIOWriter>(location);
writer_ptr = std::make_shared<storage::DiskIOWriter>(location);
}
recorder.RecordSection("Start");
......
......@@ -98,11 +98,11 @@ aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper wrapper_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/tracing tracing_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/storage storage_main_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/storage/file storage_file_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/storage/disk storage_disk_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/storage/s3 storage_s3_files)
set(storage_files
${storage_main_files}
${storage_file_files}
${storage_disk_files}
${storage_s3_files}
)
......
......@@ -21,7 +21,6 @@
#include "storage/s3/S3ClientWrapper.h"
#include "storage/s3/S3IOReader.h"
#include "storage/s3/S3IOWriter.h"
#include "storage/IStorage.h"
#include "storage/utils.h"
INITIALIZE_EASYLOGGINGPP
......
......@@ -27,8 +27,8 @@ set(wrapper_files
)
set(storage_files
${MILVUS_ENGINE_SRC}/storage/file/FileIOReader.cpp
${MILVUS_ENGINE_SRC}/storage/file/FileIOWriter.cpp
${MILVUS_ENGINE_SRC}/storage/disk/DiskIOReader.cpp
${MILVUS_ENGINE_SRC}/storage/disk/DiskIOWriter.cpp
)
set(util_files
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册