Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
409deaa6
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
409deaa6
编写于
7月 05, 2019
作者:
Z
zhiru
提交者:
jinhai
7月 09, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
Former-commit-id: 215895408d02929ee280bc73f9e6222008866751
上级
be324243
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
10 deletion
+29
-10
cpp/src/db/MemTableFile.cpp
cpp/src/db/MemTableFile.cpp
+8
-2
cpp/src/db/MemTableFile.h
cpp/src/db/MemTableFile.h
+3
-0
cpp/src/db/VectorSource.cpp
cpp/src/db/VectorSource.cpp
+5
-5
cpp/src/db/VectorSource.h
cpp/src/db/VectorSource.h
+7
-1
cpp/unittest/db/mem_test.cpp
cpp/unittest/db/mem_test.cpp
+6
-2
未找到文件。
cpp/src/db/MemTableFile.cpp
浏览文件 @
409deaa6
#include "MemTableFile.h"
#include "Constants.h"
#include "Log.h"
#include "EngineFactory.h"
#include <cmath>
...
...
@@ -14,7 +15,12 @@ MemTableFile::MemTableFile(const std::string& table_id,
meta_
(
meta
)
{
current_mem_
=
0
;
CreateTableFile
();
auto
status
=
CreateTableFile
();
if
(
status
.
ok
())
{
execution_engine_
=
EngineFactory
::
Build
(
table_file_schema_
.
dimension_
,
table_file_schema_
.
location_
,
(
EngineType
)
table_file_schema_
.
engine_type_
);
}
}
Status
MemTableFile
::
CreateTableFile
()
{
...
...
@@ -39,7 +45,7 @@ Status MemTableFile::Add(const VectorSource::Ptr& source) {
if
(
memLeft
>=
singleVectorMemSize
)
{
size_t
numVectorsToAdd
=
std
::
ceil
(
memLeft
/
singleVectorMemSize
);
size_t
numVectorsAdded
;
auto
status
=
source
->
Add
(
table_file_schema_
,
numVectorsToAdd
,
numVectorsAdded
);
auto
status
=
source
->
Add
(
execution_engine_
,
table_file_schema_
,
numVectorsToAdd
,
numVectorsAdded
);
if
(
status
.
ok
())
{
current_mem_
+=
(
numVectorsAdded
*
singleVectorMemSize
);
}
...
...
cpp/src/db/MemTableFile.h
浏览文件 @
409deaa6
...
...
@@ -3,6 +3,7 @@
#include "Status.h"
#include "Meta.h"
#include "VectorSource.h"
#include "ExecutionEngine.h"
namespace
zilliz
{
namespace
milvus
{
...
...
@@ -37,6 +38,8 @@ private:
size_t
current_mem_
;
ExecutionEnginePtr
execution_engine_
;
};
//MemTableFile
}
// namespace engine
...
...
cpp/src/db/VectorSource.cpp
浏览文件 @
409deaa6
...
...
@@ -16,7 +16,10 @@ VectorSource::VectorSource(const size_t &n,
current_num_vectors_added
=
0
;
}
Status
VectorSource
::
Add
(
const
meta
::
TableFileSchema
&
table_file_schema
,
const
size_t
&
num_vectors_to_add
,
size_t
&
num_vectors_added
)
{
Status
VectorSource
::
Add
(
const
ExecutionEnginePtr
&
execution_engine
,
const
meta
::
TableFileSchema
&
table_file_schema
,
const
size_t
&
num_vectors_to_add
,
size_t
&
num_vectors_added
)
{
if
(
table_file_schema
.
dimension_
<=
0
)
{
std
::
string
errMsg
=
"VectorSource::Add: table_file_schema dimension = "
+
...
...
@@ -24,14 +27,11 @@ Status VectorSource::Add(const meta::TableFileSchema& table_file_schema, const s
ENGINE_LOG_ERROR
<<
errMsg
;
return
Status
::
Error
(
errMsg
);
}
ExecutionEnginePtr
engine
=
EngineFactory
::
Build
(
table_file_schema
.
dimension_
,
table_file_schema
.
location_
,
(
EngineType
)
table_file_schema
.
engine_type_
);
num_vectors_added
=
current_num_vectors_added
+
num_vectors_to_add
<=
n_
?
num_vectors_to_add
:
n_
-
current_num_vectors_added
;
IDNumbers
vector_ids_to_add
;
id_generator_
->
GetNextIDNumbers
(
num_vectors_added
,
vector_ids_to_add
);
Status
status
=
engine
->
AddWithIds
(
num_vectors_added
,
vectors_
+
current_num_vectors_added
,
vector_ids_to_add
.
data
());
Status
status
=
e
xecution_e
ngine
->
AddWithIds
(
num_vectors_added
,
vectors_
+
current_num_vectors_added
,
vector_ids_to_add
.
data
());
if
(
status
.
ok
())
{
current_num_vectors_added
+=
num_vectors_added
;
vector_ids_
.
insert
(
vector_ids_
.
end
(),
vector_ids_to_add
.
begin
(),
vector_ids_to_add
.
end
());
...
...
cpp/src/db/VectorSource.h
浏览文件 @
409deaa6
...
...
@@ -3,6 +3,7 @@
#include "Status.h"
#include "Meta.h"
#include "IDGenerator.h"
#include "ExecutionEngine.h"
namespace
zilliz
{
namespace
milvus
{
...
...
@@ -16,7 +17,10 @@ public:
VectorSource
(
const
size_t
&
n
,
const
float
*
vectors
);
Status
Add
(
const
meta
::
TableFileSchema
&
table_file_schema
,
const
size_t
&
num_vectors_to_add
,
size_t
&
num_vectors_added
);
Status
Add
(
const
ExecutionEnginePtr
&
execution_engine
,
const
meta
::
TableFileSchema
&
table_file_schema
,
const
size_t
&
num_vectors_to_add
,
size_t
&
num_vectors_added
);
size_t
GetNumVectorsAdded
();
...
...
@@ -24,6 +28,8 @@ public:
IDNumbers
GetVectorIds
();
// Status Serialize();
private:
const
size_t
n_
;
...
...
cpp/unittest/db/mem_test.cpp
浏览文件 @
409deaa6
...
...
@@ -6,6 +6,7 @@
#include "utils.h"
#include "db/Factories.h"
#include "db/Constants.h"
#include "db/EngineFactory.h"
using
namespace
zilliz
::
milvus
;
...
...
@@ -55,7 +56,10 @@ TEST(MEM_TEST, VECTOR_SOURCE_TEST) {
engine
::
VectorSource
source
(
n
,
vectors
.
data
());
size_t
num_vectors_added
;
status
=
source
.
Add
(
table_file_schema
,
50
,
num_vectors_added
);
engine
::
ExecutionEnginePtr
execution_engine_
=
engine
::
EngineFactory
::
Build
(
table_file_schema
.
dimension_
,
table_file_schema
.
location_
,
(
engine
::
EngineType
)
table_file_schema
.
engine_type_
);
status
=
source
.
Add
(
execution_engine_
,
table_file_schema
,
50
,
num_vectors_added
);
ASSERT_TRUE
(
status
.
ok
());
ASSERT_EQ
(
num_vectors_added
,
50
);
...
...
@@ -63,7 +67,7 @@ TEST(MEM_TEST, VECTOR_SOURCE_TEST) {
engine
::
IDNumbers
vector_ids
=
source
.
GetVectorIds
();
ASSERT_EQ
(
vector_ids
.
size
(),
50
);
status
=
source
.
Add
(
table_file_schema
,
60
,
num_vectors_added
);
status
=
source
.
Add
(
execution_engine_
,
table_file_schema
,
60
,
num_vectors_added
);
ASSERT_TRUE
(
status
.
ok
());
ASSERT_EQ
(
num_vectors_added
,
50
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录