mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-02-02 01:06:41 +08:00
Make Memsegment create segment explicitly (#3181)
Signed-off-by: Yhz <yinghao.zou@zilliz.com>
This commit is contained in:
parent
ab5a48cfa6
commit
d37e0a39e5
@ -54,6 +54,7 @@ MemCollection::Add(int64_t partition_id, const milvus::engine::VectorSourcePtr&
|
||||
Status status;
|
||||
if (current_mem_segment == nullptr || current_mem_segment->IsFull()) {
|
||||
MemSegmentPtr new_mem_segment = std::make_shared<MemSegment>(collection_id_, partition_id, options_);
|
||||
STATUS_CHECK(new_mem_segment->CreateSegment());
|
||||
status = new_mem_segment->Add(source);
|
||||
if (status.ok()) {
|
||||
mem_segments_[partition_id].emplace_back(new_mem_segment);
|
||||
|
||||
@ -33,7 +33,7 @@ namespace engine {
|
||||
MemSegment::MemSegment(int64_t collection_id, int64_t partition_id, const DBOptions& options)
|
||||
: collection_id_(collection_id), partition_id_(partition_id), options_(options) {
|
||||
current_mem_ = 0;
|
||||
CreateSegment();
|
||||
// CreateSegment();
|
||||
}
|
||||
|
||||
Status
|
||||
|
||||
@ -32,6 +32,9 @@ class MemSegment {
|
||||
~MemSegment() = default;
|
||||
|
||||
public:
|
||||
Status
|
||||
CreateSegment();
|
||||
|
||||
Status
|
||||
Add(const VectorSourcePtr& source);
|
||||
|
||||
@ -54,9 +57,6 @@ class MemSegment {
|
||||
GetSegmentId() const;
|
||||
|
||||
private:
|
||||
Status
|
||||
CreateSegment();
|
||||
|
||||
Status
|
||||
GetSingleEntitySize(int64_t& single_size);
|
||||
|
||||
|
||||
@ -225,8 +225,12 @@ SqliteEngine::ExecuteTransaction(const std::vector<MetaApplyContext>& sql_contex
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(meta_mutex_);
|
||||
int rc = SQLITE_OK;
|
||||
sqlite3_exec(db_, "BEGIN", NULL, NULL, NULL);
|
||||
int rc = sqlite3_exec(db_, "BEGIN", NULL, NULL, NULL);
|
||||
if (rc != SQLITE_OK) {
|
||||
std::string sql_err =
|
||||
std::string("(code:") + std::to_string(sqlite3_errcode(db_)) + ", msg:" + sqlite3_errmsg(db_) + ")";
|
||||
return Status(DB_ERROR, sql_err);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sql_contexts.size(); i++) {
|
||||
rc = sqlite3_exec(db_, sqls[i].c_str(), NULL, NULL, NULL);
|
||||
@ -252,7 +256,6 @@ SqliteEngine::ExecuteTransaction(const std::vector<MetaApplyContext>& sql_contex
|
||||
if (SQLITE_OK != rc) {
|
||||
std::string err = "Execute Fail:";
|
||||
err += sqlite3_errmsg(db_);
|
||||
std::cerr << err << std::endl;
|
||||
sqlite3_exec(db_, "ROLLBACK", NULL, NULL, NULL);
|
||||
return Status(SERVER_UNEXPECTED_ERROR, err);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user