Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
a602302a
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,发现更多精彩内容 >>
提交
a602302a
编写于
10月 18, 2019
作者:
J
JinHai-CN
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/0.5.0' into 0.5.0
Former-commit-id: f90856809e386ecdce5bb88210d895e141e53d82
上级
7e4badb8
8eaed609
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
237 addition
and
159 deletion
+237
-159
CHANGELOG.md
CHANGELOG.md
+4
-0
core/conf/server_config.template
core/conf/server_config.template
+2
-3
core/src/db/engine/ExecutionEngineImpl.cpp
core/src/db/engine/ExecutionEngineImpl.cpp
+4
-4
core/src/scheduler/SchedInst.cpp
core/src/scheduler/SchedInst.cpp
+18
-9
core/src/scheduler/Utils.cpp
core/src/scheduler/Utils.cpp
+1
-1
core/src/scheduler/action/PushTaskToNeighbour.cpp
core/src/scheduler/action/PushTaskToNeighbour.cpp
+3
-3
core/src/scheduler/optimizer/Pass.h
core/src/scheduler/optimizer/Pass.h
+3
-3
core/src/scheduler/task/BuildIndexTask.cpp
core/src/scheduler/task/BuildIndexTask.cpp
+6
-0
core/src/server/Config.cpp
core/src/server/Config.cpp
+73
-55
core/src/server/Config.h
core/src/server/Config.h
+11
-11
core/src/server/grpc_impl/GrpcRequestTask.cpp
core/src/server/grpc_impl/GrpcRequestTask.cpp
+31
-19
core/src/utils/ValidationUtil.cpp
core/src/utils/ValidationUtil.cpp
+30
-17
core/src/wrapper/KnowhereResource.cpp
core/src/wrapper/KnowhereResource.cpp
+2
-2
core/unittest/server/appendix/server_config.yaml
core/unittest/server/appendix/server_config.yaml
+16
-10
core/unittest/wrapper/test_wrapper.cpp
core/unittest/wrapper/test_wrapper.cpp
+11
-0
core/unittest/wrapper/utils.h
core/unittest/wrapper/utils.h
+22
-22
未找到文件。
CHANGELOG.md
浏览文件 @
a602302a
...
@@ -27,9 +27,12 @@ Please mark all change in change log and use the ticket from JIRA.
...
@@ -27,9 +27,12 @@ Please mark all change in change log and use the ticket from JIRA.
-
MS-654 - Describe index timeout when building index
-
MS-654 - Describe index timeout when building index
-
MS-658 - Fix SQ8 Hybrid can't search
-
MS-658 - Fix SQ8 Hybrid can't search
-
\#
9 Change default gpu_cache_capacity to 4
-
\#
9 Change default gpu_cache_capacity to 4
-
MS-665 - IVF_SQ8H search crash when no GPU resource in search_resources
-
\#
20 - C++ sdk example get grpc error
-
\#
20 - C++ sdk example get grpc error
-
\#
23 - Add unittest to improve code coverage
-
\#
23 - Add unittest to improve code coverage
-
\#
31 - make clang-format failed after run build.sh -l
-
\#
31 - make clang-format failed after run build.sh -l
-
\#
39 - Create SQ8H index hang if using github server version
-
\#
30 - Some troubleshoot messages in Milvus do not provide enough information
## Improvement
## Improvement
-
MS-552 - Add and change the easylogging library
-
MS-552 - Add and change the easylogging library
...
@@ -51,6 +54,7 @@ Please mark all change in change log and use the ticket from JIRA.
...
@@ -51,6 +54,7 @@ Please mark all change in change log and use the ticket from JIRA.
-
MS-626 - Refactor DataObj to support cache any type data
-
MS-626 - Refactor DataObj to support cache any type data
-
MS-648 - Improve unittest
-
MS-648 - Improve unittest
-
MS-655 - Upgrade SPTAG
-
MS-655 - Upgrade SPTAG
-
\#
42 - Put union of index_build_device and search resources to gpu_pool
## New Feature
## New Feature
-
MS-614 - Preload table at startup
-
MS-614 - Preload table at startup
...
...
core/conf/server_config.template
浏览文件 @
a602302a
...
@@ -16,7 +16,6 @@ db_config:
...
@@ -16,7 +16,6 @@ db_config:
insert_buffer_size: 4 # GB, maximum insert buffer size allowed
insert_buffer_size: 4 # GB, maximum insert buffer size allowed
# sum of insert_buffer_size and cpu_cache_capacity cannot exceed total memory
# sum of insert_buffer_size and cpu_cache_capacity cannot exceed total memory
build_index_gpu: 0 # gpu id used for building index
preload_table: # preload data at startup, '*' means load all tables, empty value means no preload
preload_table: # preload data at startup, '*' means load all tables, empty value means no preload
# you can specify preload tables like this: table1,table2,table3
# you can specify preload tables like this: table1,table2,table3
...
@@ -39,6 +38,6 @@ engine_config:
...
@@ -39,6 +38,6 @@ engine_config:
# if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
# if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
resource_config:
resource_config:
resource_pool:
search_resources: # define the GPUs used for search computation, valid value: gpux
- cpu
- gpu0
- gpu0
index_build_device: gpu0 # GPU used for building index
\ No newline at end of file
core/src/db/engine/ExecutionEngineImpl.cpp
浏览文件 @
a602302a
...
@@ -65,7 +65,7 @@ ExecutionEngineImpl::ExecutionEngineImpl(uint16_t dimension, const std::string&
...
@@ -65,7 +65,7 @@ ExecutionEngineImpl::ExecutionEngineImpl(uint16_t dimension, const std::string&
:
location_
(
location
),
dim_
(
dimension
),
index_type_
(
index_type
),
metric_type_
(
metric_type
),
nlist_
(
nlist
)
{
:
location_
(
location
),
dim_
(
dimension
),
index_type_
(
index_type
),
metric_type_
(
metric_type
),
nlist_
(
nlist
)
{
index_
=
CreatetVecIndex
(
EngineType
::
FAISS_IDMAP
);
index_
=
CreatetVecIndex
(
EngineType
::
FAISS_IDMAP
);
if
(
!
index_
)
{
if
(
!
index_
)
{
throw
Exception
(
DB_ERROR
,
"
Could not create VecIndex
"
);
throw
Exception
(
DB_ERROR
,
"
Unsupported index type
"
);
}
}
TempMetaConf
temp_conf
;
TempMetaConf
temp_conf
;
...
@@ -111,7 +111,7 @@ ExecutionEngineImpl::CreatetVecIndex(EngineType type) {
...
@@ -111,7 +111,7 @@ ExecutionEngineImpl::CreatetVecIndex(EngineType type) {
break
;
break
;
}
}
default:
{
default:
{
ENGINE_LOG_ERROR
<<
"
Invalid engine
type"
;
ENGINE_LOG_ERROR
<<
"
Unsupported index
type"
;
return
nullptr
;
return
nullptr
;
}
}
}
}
...
@@ -373,7 +373,7 @@ ExecutionEngineImpl::BuildIndex(const std::string& location, EngineType engine_t
...
@@ -373,7 +373,7 @@ ExecutionEngineImpl::BuildIndex(const std::string& location, EngineType engine_t
auto
to_index
=
CreatetVecIndex
(
engine_type
);
auto
to_index
=
CreatetVecIndex
(
engine_type
);
if
(
!
to_index
)
{
if
(
!
to_index
)
{
throw
Exception
(
DB_ERROR
,
"
Could not create VecIndex
"
);
throw
Exception
(
DB_ERROR
,
"
Unsupported index type
"
);
}
}
TempMetaConf
temp_conf
;
TempMetaConf
temp_conf
;
...
@@ -503,7 +503,7 @@ ExecutionEngineImpl::GpuCache(uint64_t gpu_id) {
...
@@ -503,7 +503,7 @@ ExecutionEngineImpl::GpuCache(uint64_t gpu_id) {
Status
Status
ExecutionEngineImpl
::
Init
()
{
ExecutionEngineImpl
::
Init
()
{
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
Status
s
=
config
.
Get
DBConfigBuildIndexGPU
(
gpu_num_
);
Status
s
=
config
.
Get
ResourceConfigIndexBuildDevice
(
gpu_num_
);
if
(
!
s
.
ok
())
{
if
(
!
s
.
ok
())
{
return
s
;
return
s
;
}
}
...
...
core/src/scheduler/SchedInst.cpp
浏览文件 @
a602302a
...
@@ -50,29 +50,38 @@ load_simple_config() {
...
@@ -50,29 +50,38 @@ load_simple_config() {
std
::
string
mode
;
std
::
string
mode
;
config
.
GetResourceConfigMode
(
mode
);
config
.
GetResourceConfigMode
(
mode
);
std
::
vector
<
std
::
string
>
pool
;
std
::
vector
<
std
::
string
>
pool
;
config
.
GetResourceConfig
Pool
(
pool
);
config
.
GetResourceConfig
SearchResources
(
pool
);
// get resources
// get resources
bool
use_cpu_to_compute
=
false
;
for
(
auto
&
resource
:
pool
)
{
if
(
resource
==
"cpu"
)
{
use_cpu_to_compute
=
true
;
break
;
}
}
auto
gpu_ids
=
get_gpu_pool
();
auto
gpu_ids
=
get_gpu_pool
();
int32_t
build_gpu_id
;
config
.
GetResourceConfigIndexBuildDevice
(
build_gpu_id
);
// create and connect
// create and connect
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
"disk"
,
"DISK"
,
0
,
true
,
false
));
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
"disk"
,
"DISK"
,
0
,
true
,
false
));
auto
io
=
Connection
(
"io"
,
500
);
auto
io
=
Connection
(
"io"
,
500
);
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
"cpu"
,
"CPU"
,
0
,
true
,
use_cpu_to_comput
e
));
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
"cpu"
,
"CPU"
,
0
,
true
,
tru
e
));
ResMgrInst
::
GetInstance
()
->
Connect
(
"disk"
,
"cpu"
,
io
);
ResMgrInst
::
GetInstance
()
->
Connect
(
"disk"
,
"cpu"
,
io
);
auto
pcie
=
Connection
(
"pcie"
,
12000
);
auto
pcie
=
Connection
(
"pcie"
,
12000
);
bool
find_build_gpu_id
=
false
;
for
(
auto
&
gpu_id
:
gpu_ids
)
{
for
(
auto
&
gpu_id
:
gpu_ids
)
{
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
std
::
to_string
(
gpu_id
),
"GPU"
,
gpu_id
,
true
,
true
));
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
std
::
to_string
(
gpu_id
),
"GPU"
,
gpu_id
,
true
,
true
));
ResMgrInst
::
GetInstance
()
->
Connect
(
"cpu"
,
std
::
to_string
(
gpu_id
),
pcie
);
ResMgrInst
::
GetInstance
()
->
Connect
(
"cpu"
,
std
::
to_string
(
gpu_id
),
pcie
);
if
(
build_gpu_id
==
gpu_id
)
{
find_build_gpu_id
=
true
;
}
}
if
(
not
find_build_gpu_id
)
{
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
std
::
to_string
(
build_gpu_id
),
"GPU"
,
build_gpu_id
,
true
,
true
));
ResMgrInst
::
GetInstance
()
->
Connect
(
"cpu"
,
std
::
to_string
(
build_gpu_id
),
pcie
);
}
}
}
}
...
...
core/src/scheduler/Utils.cpp
浏览文件 @
a602302a
...
@@ -48,7 +48,7 @@ get_gpu_pool() {
...
@@ -48,7 +48,7 @@ get_gpu_pool() {
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
std
::
vector
<
std
::
string
>
pool
;
std
::
vector
<
std
::
string
>
pool
;
Status
s
=
config
.
GetResourceConfig
Pool
(
pool
);
Status
s
=
config
.
GetResourceConfig
SearchResources
(
pool
);
if
(
!
s
.
ok
())
{
if
(
!
s
.
ok
())
{
SERVER_LOG_ERROR
<<
s
.
message
();
SERVER_LOG_ERROR
<<
s
.
message
();
}
}
...
...
core/src/scheduler/action/PushTaskToNeighbour.cpp
浏览文件 @
a602302a
...
@@ -184,11 +184,11 @@ Action::SpecifiedResourceLabelTaskScheduler(ResourceMgrWPtr res_mgr, ResourcePtr
...
@@ -184,11 +184,11 @@ Action::SpecifiedResourceLabelTaskScheduler(ResourceMgrWPtr res_mgr, ResourcePtr
// get build index gpu resource
// get build index gpu resource
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
int32_t
build_index_gpu
;
int32_t
build_index_gpu
;
Status
stat
=
config
.
Get
DBConfigBuildIndexGPU
(
build_index_gpu
);
Status
stat
=
config
.
Get
ResourceConfigIndexBuildDevice
(
build_index_gpu
);
bool
find_gpu_res
=
false
;
bool
find_gpu_res
=
false
;
for
(
uint64_t
i
=
0
;
i
<
compute_resources
.
size
();
++
i
)
{
if
(
res_mgr
.
lock
()
->
GetResource
(
ResourceType
::
GPU
,
build_index_gpu
)
!=
nullptr
)
{
if
(
res_mgr
.
lock
()
->
GetResource
(
ResourceType
::
GPU
,
build_index_gpu
)
!=
nullptr
)
{
for
(
uint64_t
i
=
0
;
i
<
compute_resources
.
size
();
++
i
)
{
if
(
compute_resources
[
i
]
->
name
()
==
if
(
compute_resources
[
i
]
->
name
()
==
res_mgr
.
lock
()
->
GetResource
(
ResourceType
::
GPU
,
build_index_gpu
)
->
name
())
{
res_mgr
.
lock
()
->
GetResource
(
ResourceType
::
GPU
,
build_index_gpu
)
->
name
())
{
find_gpu_res
=
true
;
find_gpu_res
=
true
;
...
...
core/src/scheduler/optimizer/Pass.h
浏览文件 @
a602302a
...
@@ -34,9 +34,9 @@ namespace scheduler {
...
@@ -34,9 +34,9 @@ namespace scheduler {
class
Pass
{
class
Pass
{
public:
public:
virtual
void
//
virtual void
Init
()
{
//
Init() {
}
//
}
virtual
bool
virtual
bool
Run
(
const
TaskPtr
&
task
)
=
0
;
Run
(
const
TaskPtr
&
task
)
=
0
;
...
...
core/src/scheduler/task/BuildIndexTask.cpp
浏览文件 @
a602302a
...
@@ -134,6 +134,7 @@ XBuildIndexTask::Execute() {
...
@@ -134,6 +134,7 @@ XBuildIndexTask::Execute() {
ENGINE_LOG_DEBUG
<<
"Failed to update file to index, mark file: "
<<
table_file
.
file_id_
ENGINE_LOG_DEBUG
<<
"Failed to update file to index, mark file: "
<<
table_file
.
file_id_
<<
" to to_delete"
;
<<
" to to_delete"
;
build_index_job
->
BuildIndexDone
(
to_index_id_
);
to_index_engine_
=
nullptr
;
to_index_engine_
=
nullptr
;
return
;
return
;
}
}
...
@@ -148,6 +149,7 @@ XBuildIndexTask::Execute() {
...
@@ -148,6 +149,7 @@ XBuildIndexTask::Execute() {
std
::
cout
<<
"ERROR: failed to build index, index file is too large or gpu memory is not enough"
std
::
cout
<<
"ERROR: failed to build index, index file is too large or gpu memory is not enough"
<<
std
::
endl
;
<<
std
::
endl
;
build_index_job
->
BuildIndexDone
(
to_index_id_
);
build_index_job
->
GetStatus
()
=
Status
(
DB_ERROR
,
msg
);
build_index_job
->
GetStatus
()
=
Status
(
DB_ERROR
,
msg
);
to_index_engine_
=
nullptr
;
to_index_engine_
=
nullptr
;
return
;
return
;
...
@@ -158,6 +160,9 @@ XBuildIndexTask::Execute() {
...
@@ -158,6 +160,9 @@ XBuildIndexTask::Execute() {
meta_ptr
->
HasTable
(
file_
->
table_id_
,
has_table
);
meta_ptr
->
HasTable
(
file_
->
table_id_
,
has_table
);
if
(
!
has_table
)
{
if
(
!
has_table
)
{
meta_ptr
->
DeleteTableFiles
(
file_
->
table_id_
);
meta_ptr
->
DeleteTableFiles
(
file_
->
table_id_
);
build_index_job
->
BuildIndexDone
(
to_index_id_
);
build_index_job
->
GetStatus
()
=
Status
(
DB_ERROR
,
"Table has been deleted, discard index file."
);
to_index_engine_
=
nullptr
;
to_index_engine_
=
nullptr
;
return
;
return
;
}
}
...
@@ -177,6 +182,7 @@ XBuildIndexTask::Execute() {
...
@@ -177,6 +182,7 @@ XBuildIndexTask::Execute() {
std
::
cout
<<
"ERROR: failed to persist index file: "
<<
table_file
.
location_
std
::
cout
<<
"ERROR: failed to persist index file: "
<<
table_file
.
location_
<<
", possible out of disk space"
<<
std
::
endl
;
<<
", possible out of disk space"
<<
std
::
endl
;
build_index_job
->
BuildIndexDone
(
to_index_id_
);
build_index_job
->
GetStatus
()
=
Status
(
DB_ERROR
,
msg
);
build_index_job
->
GetStatus
()
=
Status
(
DB_ERROR
,
msg
);
to_index_engine_
=
nullptr
;
to_index_engine_
=
nullptr
;
return
;
return
;
...
...
core/src/server/Config.cpp
浏览文件 @
a602302a
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include <sys/stat.h>
#include <sys/stat.h>
#include <algorithm>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <regex>
#include <string>
#include <string>
#include <vector>
#include <vector>
...
@@ -129,12 +130,6 @@ Config::ValidateConfig() {
...
@@ -129,12 +130,6 @@ Config::ValidateConfig() {
return
s
;
return
s
;
}
}
int32_t
db_build_index_gpu
;
s
=
GetDBConfigBuildIndexGPU
(
db_build_index_gpu
);
if
(
!
s
.
ok
())
{
return
s
;
}
/* metric config */
/* metric config */
bool
metric_enable_monitor
;
bool
metric_enable_monitor
;
s
=
GetMetricConfigEnableMonitor
(
metric_enable_monitor
);
s
=
GetMetricConfigEnableMonitor
(
metric_enable_monitor
);
...
@@ -205,8 +200,14 @@ Config::ValidateConfig() {
...
@@ -205,8 +200,14 @@ Config::ValidateConfig() {
return
s
;
return
s
;
}
}
std
::
vector
<
std
::
string
>
resource_pool
;
std
::
vector
<
std
::
string
>
search_resources
;
s
=
GetResourceConfigPool
(
resource_pool
);
s
=
GetResourceConfigSearchResources
(
search_resources
);
if
(
!
s
.
ok
())
{
return
s
;
}
int32_t
resource_index_build_device
;
s
=
GetResourceConfigIndexBuildDevice
(
resource_index_build_device
);
if
(
!
s
.
ok
())
{
if
(
!
s
.
ok
())
{
return
s
;
return
s
;
}
}
...
@@ -270,11 +271,6 @@ Config::ResetDefaultConfig() {
...
@@ -270,11 +271,6 @@ Config::ResetDefaultConfig() {
return
s
;
return
s
;
}
}
s
=
SetDBConfigBuildIndexGPU
(
CONFIG_DB_BUILD_INDEX_GPU_DEFAULT
);
if
(
!
s
.
ok
())
{
return
s
;
}
/* metric config */
/* metric config */
s
=
SetMetricConfigEnableMonitor
(
CONFIG_METRIC_ENABLE_MONITOR_DEFAULT
);
s
=
SetMetricConfigEnableMonitor
(
CONFIG_METRIC_ENABLE_MONITOR_DEFAULT
);
if
(
!
s
.
ok
())
{
if
(
!
s
.
ok
())
{
...
@@ -334,6 +330,11 @@ Config::ResetDefaultConfig() {
...
@@ -334,6 +330,11 @@ Config::ResetDefaultConfig() {
return
s
;
return
s
;
}
}
s
=
SetResourceConfigIndexBuildDevice
(
CONFIG_RESOURCE_INDEX_BUILD_DEVICE_DEFAULT
);
if
(
!
s
.
ok
())
{
return
s
;
}
return
Status
::
OK
();
return
Status
::
OK
();
}
}
...
@@ -459,19 +460,6 @@ Config::CheckDBConfigInsertBufferSize(const std::string& value) {
...
@@ -459,19 +460,6 @@ Config::CheckDBConfigInsertBufferSize(const std::string& value) {
return
Status
::
OK
();
return
Status
::
OK
();
}
}
Status
Config
::
CheckDBConfigBuildIndexGPU
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateStringIsNumber
(
value
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid DB config build_index_gpu: "
+
value
);
}
else
{
int32_t
gpu_index
=
std
::
stoi
(
value
);
if
(
!
ValidationUtil
::
ValidateGpuIndex
(
gpu_index
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid DB config build_index_gpu: "
+
value
);
}
}
return
Status
::
OK
();
}
Status
Status
Config
::
CheckMetricConfigEnableMonitor
(
const
std
::
string
&
value
)
{
Config
::
CheckMetricConfigEnableMonitor
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateStringIsBool
(
value
).
ok
())
{
if
(
!
ValidationUtil
::
ValidateStringIsBool
(
value
).
ok
())
{
...
@@ -544,7 +532,7 @@ Config::CheckCacheConfigGpuCacheCapacity(const std::string& value) {
...
@@ -544,7 +532,7 @@ Config::CheckCacheConfigGpuCacheCapacity(const std::string& value) {
}
else
{
}
else
{
uint64_t
gpu_cache_capacity
=
std
::
stoi
(
value
)
*
GB
;
uint64_t
gpu_cache_capacity
=
std
::
stoi
(
value
)
*
GB
;
int
gpu_index
;
int
gpu_index
;
Status
s
=
Get
DBConfigBuildIndexGPU
(
gpu_index
);
Status
s
=
Get
ResourceConfigIndexBuildDevice
(
gpu_index
);
if
(
!
s
.
ok
())
{
if
(
!
s
.
ok
())
{
return
s
;
return
s
;
}
}
...
@@ -616,9 +604,38 @@ Config::CheckResourceConfigMode(const std::string& value) {
...
@@ -616,9 +604,38 @@ Config::CheckResourceConfigMode(const std::string& value) {
}
}
Status
Status
Config
::
CheckResourceConfigPool
(
const
std
::
vector
<
std
::
string
>&
value
)
{
CheckGpuDevice
(
const
std
::
string
&
value
)
{
const
std
::
regex
pat
(
"gpu(
\\
d+)"
);
std
::
cmatch
m
;
if
(
!
std
::
regex_match
(
value
.
c_str
(),
m
,
pat
))
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid gpu device: "
+
value
);
}
int32_t
gpu_index
=
std
::
stoi
(
value
.
substr
(
3
));
if
(
!
ValidationUtil
::
ValidateGpuIndex
(
gpu_index
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid gpu device: "
+
value
);
}
return
Status
::
OK
();
}
Status
Config
::
CheckResourceConfigSearchResources
(
const
std
::
vector
<
std
::
string
>&
value
)
{
if
(
value
.
empty
())
{
if
(
value
.
empty
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid resource config pool"
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Empty resource config search_resources"
);
}
for
(
auto
&
gpu_device
:
value
)
{
if
(
!
CheckGpuDevice
(
gpu_device
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid resource config search_resources: "
+
gpu_device
);
}
}
return
Status
::
OK
();
}
Status
Config
::
CheckResourceConfigIndexBuildDevice
(
const
std
::
string
&
value
)
{
if
(
!
CheckGpuDevice
(
value
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid resource config index_build_device: "
+
value
);
}
}
return
Status
::
OK
();
return
Status
::
OK
();
}
}
...
@@ -739,18 +756,6 @@ Config::GetDBConfigInsertBufferSize(int32_t& value) {
...
@@ -739,18 +756,6 @@ Config::GetDBConfigInsertBufferSize(int32_t& value) {
return
Status
::
OK
();
return
Status
::
OK
();
}
}
Status
Config
::
GetDBConfigBuildIndexGPU
(
int32_t
&
value
)
{
std
::
string
str
=
GetConfigStr
(
CONFIG_DB
,
CONFIG_DB_BUILD_INDEX_GPU
,
CONFIG_DB_BUILD_INDEX_GPU_DEFAULT
);
Status
s
=
CheckDBConfigBuildIndexGPU
(
str
);
if
(
!
s
.
ok
())
{
return
s
;
}
value
=
std
::
stoi
(
str
);
return
Status
::
OK
();
}
Status
Status
Config
::
GetDBConfigPreloadTable
(
std
::
string
&
value
)
{
Config
::
GetDBConfigPreloadTable
(
std
::
string
&
value
)
{
value
=
GetConfigStr
(
CONFIG_DB
,
CONFIG_DB_PRELOAD_TABLE
);
value
=
GetConfigStr
(
CONFIG_DB
,
CONFIG_DB_PRELOAD_TABLE
);
...
@@ -880,10 +885,23 @@ Config::GetResourceConfigMode(std::string& value) {
...
@@ -880,10 +885,23 @@ Config::GetResourceConfigMode(std::string& value) {
}
}
Status
Status
Config
::
GetResourceConfig
Pool
(
std
::
vector
<
std
::
string
>&
value
)
{
Config
::
GetResourceConfig
SearchResources
(
std
::
vector
<
std
::
string
>&
value
)
{
ConfigNode
resource_config
=
GetConfigNode
(
CONFIG_RESOURCE
);
ConfigNode
resource_config
=
GetConfigNode
(
CONFIG_RESOURCE
);
value
=
resource_config
.
GetSequence
(
CONFIG_RESOURCE_POOL
);
value
=
resource_config
.
GetSequence
(
CONFIG_RESOURCE_SEARCH_RESOURCES
);
return
CheckResourceConfigPool
(
value
);
return
CheckResourceConfigSearchResources
(
value
);
}
Status
Config
::
GetResourceConfigIndexBuildDevice
(
int32_t
&
value
)
{
std
::
string
str
=
GetConfigStr
(
CONFIG_RESOURCE
,
CONFIG_RESOURCE_INDEX_BUILD_DEVICE
,
CONFIG_RESOURCE_INDEX_BUILD_DEVICE_DEFAULT
);
Status
s
=
CheckResourceConfigIndexBuildDevice
(
str
);
if
(
!
s
.
ok
())
{
return
s
;
}
value
=
std
::
stoi
(
str
.
substr
(
3
));
return
Status
::
OK
();
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
...
@@ -999,17 +1017,6 @@ Config::SetDBConfigInsertBufferSize(const std::string& value) {
...
@@ -999,17 +1017,6 @@ Config::SetDBConfigInsertBufferSize(const std::string& value) {
return
Status
::
OK
();
return
Status
::
OK
();
}
}
Status
Config
::
SetDBConfigBuildIndexGPU
(
const
std
::
string
&
value
)
{
Status
s
=
CheckDBConfigBuildIndexGPU
(
value
);
if
(
!
s
.
ok
())
{
return
s
;
}
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_DB_BUILD_INDEX_GPU
,
value
);
return
Status
::
OK
();
}
/* metric config */
/* metric config */
Status
Status
Config
::
SetMetricConfigEnableMonitor
(
const
std
::
string
&
value
)
{
Config
::
SetMetricConfigEnableMonitor
(
const
std
::
string
&
value
)
{
...
@@ -1135,5 +1142,16 @@ Config::SetResourceConfigMode(const std::string& value) {
...
@@ -1135,5 +1142,16 @@ Config::SetResourceConfigMode(const std::string& value) {
return
Status
::
OK
();
return
Status
::
OK
();
}
}
Status
Config
::
SetResourceConfigIndexBuildDevice
(
const
std
::
string
&
value
)
{
Status
s
=
CheckResourceConfigIndexBuildDevice
(
value
);
if
(
!
s
.
ok
())
{
return
s
;
}
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_RESOURCE_INDEX_BUILD_DEVICE
,
value
);
return
Status
::
OK
();
}
}
// namespace server
}
// namespace server
}
// namespace milvus
}
// namespace milvus
core/src/server/Config.h
浏览文件 @
a602302a
...
@@ -53,8 +53,6 @@ static const char* CONFIG_DB_ARCHIVE_DAYS_THRESHOLD = "archive_days_threshold";
...
@@ -53,8 +53,6 @@ static const char* CONFIG_DB_ARCHIVE_DAYS_THRESHOLD = "archive_days_threshold";
static
const
char
*
CONFIG_DB_ARCHIVE_DAYS_THRESHOLD_DEFAULT
=
"0"
;
static
const
char
*
CONFIG_DB_ARCHIVE_DAYS_THRESHOLD_DEFAULT
=
"0"
;
static
const
char
*
CONFIG_DB_INSERT_BUFFER_SIZE
=
"insert_buffer_size"
;
static
const
char
*
CONFIG_DB_INSERT_BUFFER_SIZE
=
"insert_buffer_size"
;
static
const
char
*
CONFIG_DB_INSERT_BUFFER_SIZE_DEFAULT
=
"4"
;
static
const
char
*
CONFIG_DB_INSERT_BUFFER_SIZE_DEFAULT
=
"4"
;
static
const
char
*
CONFIG_DB_BUILD_INDEX_GPU
=
"build_index_gpu"
;
static
const
char
*
CONFIG_DB_BUILD_INDEX_GPU_DEFAULT
=
"0"
;
static
const
char
*
CONFIG_DB_PRELOAD_TABLE
=
"preload_table"
;
static
const
char
*
CONFIG_DB_PRELOAD_TABLE
=
"preload_table"
;
/* cache config */
/* cache config */
...
@@ -91,7 +89,9 @@ static const char* CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT = "0";
...
@@ -91,7 +89,9 @@ static const char* CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT = "0";
static
const
char
*
CONFIG_RESOURCE
=
"resource_config"
;
static
const
char
*
CONFIG_RESOURCE
=
"resource_config"
;
static
const
char
*
CONFIG_RESOURCE_MODE
=
"mode"
;
static
const
char
*
CONFIG_RESOURCE_MODE
=
"mode"
;
static
const
char
*
CONFIG_RESOURCE_MODE_DEFAULT
=
"simple"
;
static
const
char
*
CONFIG_RESOURCE_MODE_DEFAULT
=
"simple"
;
static
const
char
*
CONFIG_RESOURCE_POOL
=
"resource_pool"
;
static
const
char
*
CONFIG_RESOURCE_SEARCH_RESOURCES
=
"search_resources"
;
static
const
char
*
CONFIG_RESOURCE_INDEX_BUILD_DEVICE
=
"index_build_device"
;
static
const
char
*
CONFIG_RESOURCE_INDEX_BUILD_DEVICE_DEFAULT
=
"gpu0"
;
class
Config
{
class
Config
{
public:
public:
...
@@ -140,8 +140,6 @@ class Config {
...
@@ -140,8 +140,6 @@ class Config {
CheckDBConfigArchiveDaysThreshold
(
const
std
::
string
&
value
);
CheckDBConfigArchiveDaysThreshold
(
const
std
::
string
&
value
);
Status
Status
CheckDBConfigInsertBufferSize
(
const
std
::
string
&
value
);
CheckDBConfigInsertBufferSize
(
const
std
::
string
&
value
);
Status
CheckDBConfigBuildIndexGPU
(
const
std
::
string
&
value
);
/* metric config */
/* metric config */
Status
Status
...
@@ -173,7 +171,9 @@ class Config {
...
@@ -173,7 +171,9 @@ class Config {
Status
Status
CheckResourceConfigMode
(
const
std
::
string
&
value
);
CheckResourceConfigMode
(
const
std
::
string
&
value
);
Status
Status
CheckResourceConfigPool
(
const
std
::
vector
<
std
::
string
>&
value
);
CheckResourceConfigSearchResources
(
const
std
::
vector
<
std
::
string
>&
value
);
Status
CheckResourceConfigIndexBuildDevice
(
const
std
::
string
&
value
);
std
::
string
std
::
string
GetConfigStr
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
const
std
::
string
&
default_value
=
""
);
GetConfigStr
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
const
std
::
string
&
default_value
=
""
);
...
@@ -203,8 +203,6 @@ class Config {
...
@@ -203,8 +203,6 @@ class Config {
Status
Status
GetDBConfigInsertBufferSize
(
int32_t
&
value
);
GetDBConfigInsertBufferSize
(
int32_t
&
value
);
Status
Status
GetDBConfigBuildIndexGPU
(
int32_t
&
value
);
Status
GetDBConfigPreloadTable
(
std
::
string
&
value
);
GetDBConfigPreloadTable
(
std
::
string
&
value
);
/* metric config */
/* metric config */
...
@@ -237,7 +235,9 @@ class Config {
...
@@ -237,7 +235,9 @@ class Config {
Status
Status
GetResourceConfigMode
(
std
::
string
&
value
);
GetResourceConfigMode
(
std
::
string
&
value
);
Status
Status
GetResourceConfigPool
(
std
::
vector
<
std
::
string
>&
value
);
GetResourceConfigSearchResources
(
std
::
vector
<
std
::
string
>&
value
);
Status
GetResourceConfigIndexBuildDevice
(
int32_t
&
value
);
public:
public:
/* server config */
/* server config */
...
@@ -263,8 +263,6 @@ class Config {
...
@@ -263,8 +263,6 @@ class Config {
SetDBConfigArchiveDaysThreshold
(
const
std
::
string
&
value
);
SetDBConfigArchiveDaysThreshold
(
const
std
::
string
&
value
);
Status
Status
SetDBConfigInsertBufferSize
(
const
std
::
string
&
value
);
SetDBConfigInsertBufferSize
(
const
std
::
string
&
value
);
Status
SetDBConfigBuildIndexGPU
(
const
std
::
string
&
value
);
/* metric config */
/* metric config */
Status
Status
...
@@ -295,6 +293,8 @@ class Config {
...
@@ -295,6 +293,8 @@ class Config {
/* resource config */
/* resource config */
Status
Status
SetResourceConfigMode
(
const
std
::
string
&
value
);
SetResourceConfigMode
(
const
std
::
string
&
value
);
Status
SetResourceConfigIndexBuildDevice
(
const
std
::
string
&
value
);
private:
private:
std
::
unordered_map
<
std
::
string
,
std
::
unordered_map
<
std
::
string
,
std
::
string
>>
config_map_
;
std
::
unordered_map
<
std
::
string
,
std
::
unordered_map
<
std
::
string
,
std
::
string
>>
config_map_
;
...
...
core/src/server/grpc_impl/GrpcRequestTask.cpp
浏览文件 @
a602302a
...
@@ -113,6 +113,14 @@ ConvertTimeRangeToDBDates(const std::vector<::milvus::grpc::Range>& range_array,
...
@@ -113,6 +113,14 @@ ConvertTimeRangeToDBDates(const std::vector<::milvus::grpc::Range>& range_array,
return
Status
::
OK
();
return
Status
::
OK
();
}
}
std
::
string
TableNotExistMsg
(
const
std
::
string
&
table_name
)
{
return
"Table "
+
table_name
+
" not exist. Use milvus.has_table to verify whether the table exists. You also can check if the table name "
"exists."
;
}
}
// namespace
}
// namespace
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...
@@ -255,7 +263,7 @@ CreateIndexTask::OnExecute() {
...
@@ -255,7 +263,7 @@ CreateIndexTask::OnExecute() {
}
}
if
(
!
has_table
)
{
if
(
!
has_table
)
{
return
Status
(
SERVER_TABLE_NOT_EXIST
,
"Table "
+
table_name_
+
" not exists"
);
return
Status
(
SERVER_TABLE_NOT_EXIST
,
TableNotExistMsg
(
table_name_
)
);
}
}
auto
&
grpc_index
=
index_param_
->
index
();
auto
&
grpc_index
=
index_param_
->
index
();
...
@@ -348,7 +356,7 @@ DropTableTask::OnExecute() {
...
@@ -348,7 +356,7 @@ DropTableTask::OnExecute() {
status
=
DBWrapper
::
DB
()
->
DescribeTable
(
table_info
);
status
=
DBWrapper
::
DB
()
->
DescribeTable
(
table_info
);
if
(
!
status
.
ok
())
{
if
(
!
status
.
ok
())
{
if
(
status
.
code
()
==
DB_NOT_FOUND
)
{
if
(
status
.
code
()
==
DB_NOT_FOUND
)
{
return
Status
(
SERVER_TABLE_NOT_EXIST
,
"Table "
+
table_name_
+
" not exists"
);
return
Status
(
SERVER_TABLE_NOT_EXIST
,
TableNotExistMsg
(
table_name_
)
);
}
else
{
}
else
{
return
status
;
return
status
;
}
}
...
@@ -420,12 +428,14 @@ InsertTask::OnExecute() {
...
@@ -420,12 +428,14 @@ InsertTask::OnExecute() {
return
status
;
return
status
;
}
}
if
(
insert_param_
->
row_record_array
().
empty
())
{
if
(
insert_param_
->
row_record_array
().
empty
())
{
return
Status
(
SERVER_INVALID_ROWRECORD_ARRAY
,
"Row record array is empty"
);
return
Status
(
SERVER_INVALID_ROWRECORD_ARRAY
,
"The vector array is empty. Make sure you have entered vector records."
);
}
}
if
(
!
insert_param_
->
row_id_array
().
empty
())
{
if
(
!
insert_param_
->
row_id_array
().
empty
())
{
if
(
insert_param_
->
row_id_array
().
size
()
!=
insert_param_
->
row_record_array_size
())
{
if
(
insert_param_
->
row_id_array
().
size
()
!=
insert_param_
->
row_record_array_size
())
{
return
Status
(
SERVER_ILLEGAL_VECTOR_ID
,
"Size of vector ids is not equal to row record array size"
);
return
Status
(
SERVER_ILLEGAL_VECTOR_ID
,
"The size of vector ID array must be equal to the size of the vector."
);
}
}
}
}
...
@@ -435,7 +445,7 @@ InsertTask::OnExecute() {
...
@@ -435,7 +445,7 @@ InsertTask::OnExecute() {
status
=
DBWrapper
::
DB
()
->
DescribeTable
(
table_info
);
status
=
DBWrapper
::
DB
()
->
DescribeTable
(
table_info
);
if
(
!
status
.
ok
())
{
if
(
!
status
.
ok
())
{
if
(
status
.
code
()
==
DB_NOT_FOUND
)
{
if
(
status
.
code
()
==
DB_NOT_FOUND
)
{
return
Status
(
SERVER_TABLE_NOT_EXIST
,
"Table "
+
insert_param_
->
table_name
()
+
" not exists"
);
return
Status
(
SERVER_TABLE_NOT_EXIST
,
TableNotExistMsg
(
insert_param_
->
table_name
())
);
}
else
{
}
else
{
return
status
;
return
status
;
}
}
...
@@ -447,13 +457,14 @@ InsertTask::OnExecute() {
...
@@ -447,13 +457,14 @@ InsertTask::OnExecute() {
// user already provided id before, all insert action require user id
// user already provided id before, all insert action require user id
if
((
table_info
.
flag_
&
engine
::
meta
::
FLAG_MASK_HAS_USERID
)
!=
0
&&
!
user_provide_ids
)
{
if
((
table_info
.
flag_
&
engine
::
meta
::
FLAG_MASK_HAS_USERID
)
!=
0
&&
!
user_provide_ids
)
{
return
Status
(
SERVER_ILLEGAL_VECTOR_ID
,
return
Status
(
SERVER_ILLEGAL_VECTOR_ID
,
"Table vector
ids are user defined, please provide id for this batch
"
);
"Table vector
IDs are user-defined. Please provide IDs for all vectors of this table.
"
);
}
}
// user didn't provided id before, no need to provide user id
// user didn't provided id before, no need to provide user id
if
((
table_info
.
flag_
&
engine
::
meta
::
FLAG_MASK_NO_USERID
)
!=
0
&&
user_provide_ids
)
{
if
((
table_info
.
flag_
&
engine
::
meta
::
FLAG_MASK_NO_USERID
)
!=
0
&&
user_provide_ids
)
{
return
Status
(
SERVER_ILLEGAL_VECTOR_ID
,
return
Status
(
"Table vector ids are auto generated, no need to provide id for this batch"
);
SERVER_ILLEGAL_VECTOR_ID
,
"Table vector IDs are auto-generated. All vectors of this table must use auto-generated IDs."
);
}
}
rc
.
RecordSection
(
"check validation"
);
rc
.
RecordSection
(
"check validation"
);
...
@@ -470,13 +481,13 @@ InsertTask::OnExecute() {
...
@@ -470,13 +481,13 @@ InsertTask::OnExecute() {
// TODO(yk): change to one dimension array or use multiple-thread to copy the data
// TODO(yk): change to one dimension array or use multiple-thread to copy the data
for
(
size_t
i
=
0
;
i
<
insert_param_
->
row_record_array_size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
insert_param_
->
row_record_array_size
();
i
++
)
{
if
(
insert_param_
->
row_record_array
(
i
).
vector_data
().
empty
())
{
if
(
insert_param_
->
row_record_array
(
i
).
vector_data
().
empty
())
{
return
Status
(
SERVER_INVALID_ROWRECORD_ARRAY
,
"Row record array data is empty"
);
return
Status
(
SERVER_INVALID_ROWRECORD_ARRAY
,
"The vector dimension must be equal to the table dimension."
);
}
}
uint64_t
vec_dim
=
insert_param_
->
row_record_array
(
i
).
vector_data
().
size
();
uint64_t
vec_dim
=
insert_param_
->
row_record_array
(
i
).
vector_data
().
size
();
if
(
vec_dim
!=
table_info
.
dimension_
)
{
if
(
vec_dim
!=
table_info
.
dimension_
)
{
ErrorCode
error_code
=
SERVER_INVALID_VECTOR_DIMENSION
;
ErrorCode
error_code
=
SERVER_INVALID_VECTOR_DIMENSION
;
std
::
string
error_msg
=
"Invalid row record dimension: "
+
std
::
to_string
(
vec_dim
)
+
std
::
string
error_msg
=
"The vector dimension must be equal to the table dimension."
;
" vs. table dimension:"
+
std
::
to_string
(
table_info
.
dimension_
);
return
Status
(
error_code
,
error_msg
);
return
Status
(
error_code
,
error_msg
);
}
}
memcpy
(
&
vec_f
[
i
*
table_info
.
dimension_
],
insert_param_
->
row_record_array
(
i
).
vector_data
().
data
(),
memcpy
(
&
vec_f
[
i
*
table_info
.
dimension_
],
insert_param_
->
row_record_array
(
i
).
vector_data
().
data
(),
...
@@ -569,7 +580,7 @@ SearchTask::OnExecute() {
...
@@ -569,7 +580,7 @@ SearchTask::OnExecute() {
status
=
DBWrapper
::
DB
()
->
DescribeTable
(
table_info
);
status
=
DBWrapper
::
DB
()
->
DescribeTable
(
table_info
);
if
(
!
status
.
ok
())
{
if
(
!
status
.
ok
())
{
if
(
status
.
code
()
==
DB_NOT_FOUND
)
{
if
(
status
.
code
()
==
DB_NOT_FOUND
)
{
return
Status
(
SERVER_TABLE_NOT_EXIST
,
"Table "
+
table_name_
+
" not exists"
);
return
Status
(
SERVER_TABLE_NOT_EXIST
,
TableNotExistMsg
(
table_name_
)
);
}
else
{
}
else
{
return
status
;
return
status
;
}
}
...
@@ -587,7 +598,8 @@ SearchTask::OnExecute() {
...
@@ -587,7 +598,8 @@ SearchTask::OnExecute() {
}
}
if
(
search_param_
->
query_record_array
().
empty
())
{
if
(
search_param_
->
query_record_array
().
empty
())
{
return
Status
(
SERVER_INVALID_ROWRECORD_ARRAY
,
"Row record array is empty"
);
return
Status
(
SERVER_INVALID_ROWRECORD_ARRAY
,
"The vector array is empty. Make sure you have entered vector records."
);
}
}
// step 4: check date range, and convert to db dates
// step 4: check date range, and convert to db dates
...
@@ -609,13 +621,13 @@ SearchTask::OnExecute() {
...
@@ -609,13 +621,13 @@ SearchTask::OnExecute() {
std
::
vector
<
float
>
vec_f
(
record_array_size
*
table_info
.
dimension_
,
0
);
std
::
vector
<
float
>
vec_f
(
record_array_size
*
table_info
.
dimension_
,
0
);
for
(
size_t
i
=
0
;
i
<
record_array_size
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
record_array_size
;
i
++
)
{
if
(
search_param_
->
query_record_array
(
i
).
vector_data
().
empty
())
{
if
(
search_param_
->
query_record_array
(
i
).
vector_data
().
empty
())
{
return
Status
(
SERVER_INVALID_ROWRECORD_ARRAY
,
"Row record array data is empty"
);
return
Status
(
SERVER_INVALID_ROWRECORD_ARRAY
,
"The vector dimension must be equal to the table dimension."
);
}
}
uint64_t
query_vec_dim
=
search_param_
->
query_record_array
(
i
).
vector_data
().
size
();
uint64_t
query_vec_dim
=
search_param_
->
query_record_array
(
i
).
vector_data
().
size
();
if
(
query_vec_dim
!=
table_info
.
dimension_
)
{
if
(
query_vec_dim
!=
table_info
.
dimension_
)
{
ErrorCode
error_code
=
SERVER_INVALID_VECTOR_DIMENSION
;
ErrorCode
error_code
=
SERVER_INVALID_VECTOR_DIMENSION
;
std
::
string
error_msg
=
"Invalid row record dimension: "
+
std
::
to_string
(
query_vec_dim
)
+
std
::
string
error_msg
=
"The vector dimension must be equal to the table dimension."
;
" vs. table dimension:"
+
std
::
to_string
(
table_info
.
dimension_
);
return
Status
(
error_code
,
error_msg
);
return
Status
(
error_code
,
error_msg
);
}
}
...
@@ -707,7 +719,7 @@ CountTableTask::OnExecute() {
...
@@ -707,7 +719,7 @@ CountTableTask::OnExecute() {
status
=
DBWrapper
::
DB
()
->
GetTableRowCount
(
table_name_
,
row_count
);
status
=
DBWrapper
::
DB
()
->
GetTableRowCount
(
table_name_
,
row_count
);
if
(
!
status
.
ok
())
{
if
(
!
status
.
ok
())
{
if
(
status
.
code
(),
DB_NOT_FOUND
)
{
if
(
status
.
code
(),
DB_NOT_FOUND
)
{
return
Status
(
SERVER_TABLE_NOT_EXIST
,
"Table "
+
table_name_
+
" not exists"
);
return
Status
(
SERVER_TABLE_NOT_EXIST
,
TableNotExistMsg
(
table_name_
)
);
}
else
{
}
else
{
return
status
;
return
status
;
}
}
...
@@ -779,7 +791,7 @@ DeleteByRangeTask::OnExecute() {
...
@@ -779,7 +791,7 @@ DeleteByRangeTask::OnExecute() {
status
=
DBWrapper
::
DB
()
->
DescribeTable
(
table_info
);
status
=
DBWrapper
::
DB
()
->
DescribeTable
(
table_info
);
if
(
!
status
.
ok
())
{
if
(
!
status
.
ok
())
{
if
(
status
.
code
(),
DB_NOT_FOUND
)
{
if
(
status
.
code
(),
DB_NOT_FOUND
)
{
return
Status
(
SERVER_TABLE_NOT_EXIST
,
"Table "
+
table_name
+
" not exists"
);
return
Status
(
SERVER_TABLE_NOT_EXIST
,
TableNotExistMsg
(
table_name
)
);
}
else
{
}
else
{
return
status
;
return
status
;
}
}
...
@@ -917,7 +929,7 @@ DropIndexTask::OnExecute() {
...
@@ -917,7 +929,7 @@ DropIndexTask::OnExecute() {
}
}
if
(
!
has_table
)
{
if
(
!
has_table
)
{
return
Status
(
SERVER_TABLE_NOT_EXIST
,
"Table "
+
table_name_
+
" not exists"
);
return
Status
(
SERVER_TABLE_NOT_EXIST
,
TableNotExistMsg
(
table_name_
)
);
}
}
// step 2: check table existence
// step 2: check table existence
...
...
core/src/utils/ValidationUtil.cpp
浏览文件 @
a602302a
...
@@ -37,14 +37,15 @@ Status
...
@@ -37,14 +37,15 @@ Status
ValidationUtil
::
ValidateTableName
(
const
std
::
string
&
table_name
)
{
ValidationUtil
::
ValidateTableName
(
const
std
::
string
&
table_name
)
{
// Table name shouldn't be empty.
// Table name shouldn't be empty.
if
(
table_name
.
empty
())
{
if
(
table_name
.
empty
())
{
std
::
string
msg
=
"
Empty table name
"
;
std
::
string
msg
=
"
Table name should not be empty.
"
;
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_TABLE_NAME
,
msg
);
return
Status
(
SERVER_INVALID_TABLE_NAME
,
msg
);
}
}
std
::
string
invalid_msg
=
"Invalid table name: "
+
table_name
+
". "
;
// Table name size shouldn't exceed 16384.
// Table name size shouldn't exceed 16384.
if
(
table_name
.
size
()
>
TABLE_NAME_SIZE_LIMIT
)
{
if
(
table_name
.
size
()
>
TABLE_NAME_SIZE_LIMIT
)
{
std
::
string
msg
=
"Table name size exceed the limitation
"
;
std
::
string
msg
=
invalid_msg
+
"The length of a table name must be less than 255 characters.
"
;
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_TABLE_NAME
,
msg
);
return
Status
(
SERVER_INVALID_TABLE_NAME
,
msg
);
}
}
...
@@ -52,7 +53,7 @@ ValidationUtil::ValidateTableName(const std::string& table_name) {
...
@@ -52,7 +53,7 @@ ValidationUtil::ValidateTableName(const std::string& table_name) {
// Table name first character should be underscore or character.
// Table name first character should be underscore or character.
char
first_char
=
table_name
[
0
];
char
first_char
=
table_name
[
0
];
if
(
first_char
!=
'_'
&&
std
::
isalpha
(
first_char
)
==
0
)
{
if
(
first_char
!=
'_'
&&
std
::
isalpha
(
first_char
)
==
0
)
{
std
::
string
msg
=
"Table name first character isn't underscore or character
"
;
std
::
string
msg
=
invalid_msg
+
"The first character of a table name must be an underscore or letter.
"
;
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_TABLE_NAME
,
msg
);
return
Status
(
SERVER_INVALID_TABLE_NAME
,
msg
);
}
}
...
@@ -61,7 +62,7 @@ ValidationUtil::ValidateTableName(const std::string& table_name) {
...
@@ -61,7 +62,7 @@ ValidationUtil::ValidateTableName(const std::string& table_name) {
for
(
int64_t
i
=
1
;
i
<
table_name_size
;
++
i
)
{
for
(
int64_t
i
=
1
;
i
<
table_name_size
;
++
i
)
{
char
name_char
=
table_name
[
i
];
char
name_char
=
table_name
[
i
];
if
(
name_char
!=
'_'
&&
std
::
isalnum
(
name_char
)
==
0
)
{
if
(
name_char
!=
'_'
&&
std
::
isalnum
(
name_char
)
==
0
)
{
std
::
string
msg
=
"Table name character isn't underscore or alphanumber
"
;
std
::
string
msg
=
invalid_msg
+
"Table name can only contain numbers, letters, and underscores.
"
;
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_TABLE_NAME
,
msg
);
return
Status
(
SERVER_INVALID_TABLE_NAME
,
msg
);
}
}
...
@@ -72,12 +73,9 @@ ValidationUtil::ValidateTableName(const std::string& table_name) {
...
@@ -72,12 +73,9 @@ ValidationUtil::ValidateTableName(const std::string& table_name) {
Status
Status
ValidationUtil
::
ValidateTableDimension
(
int64_t
dimension
)
{
ValidationUtil
::
ValidateTableDimension
(
int64_t
dimension
)
{
if
(
dimension
<=
0
)
{
if
(
dimension
<=
0
||
dimension
>
TABLE_DIMENSION_LIMIT
)
{
std
::
string
msg
=
"Dimension value should be greater than 0"
;
std
::
string
msg
=
"Invalid table dimension: "
+
std
::
to_string
(
dimension
)
+
". "
+
SERVER_LOG_ERROR
<<
msg
;
"The table dimension must be within the range of 1 ~ 16384."
;
return
Status
(
SERVER_INVALID_VECTOR_DIMENSION
,
msg
);
}
else
if
(
dimension
>
TABLE_DIMENSION_LIMIT
)
{
std
::
string
msg
=
"Table dimension excceed the limitation: "
+
std
::
to_string
(
TABLE_DIMENSION_LIMIT
);
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_VECTOR_DIMENSION
,
msg
);
return
Status
(
SERVER_INVALID_VECTOR_DIMENSION
,
msg
);
}
else
{
}
else
{
...
@@ -89,10 +87,20 @@ Status
...
@@ -89,10 +87,20 @@ Status
ValidationUtil
::
ValidateTableIndexType
(
int32_t
index_type
)
{
ValidationUtil
::
ValidateTableIndexType
(
int32_t
index_type
)
{
int
engine_type
=
static_cast
<
int
>
(
engine
::
EngineType
(
index_type
));
int
engine_type
=
static_cast
<
int
>
(
engine
::
EngineType
(
index_type
));
if
(
engine_type
<=
0
||
engine_type
>
static_cast
<
int
>
(
engine
::
EngineType
::
MAX_VALUE
))
{
if
(
engine_type
<=
0
||
engine_type
>
static_cast
<
int
>
(
engine
::
EngineType
::
MAX_VALUE
))
{
std
::
string
msg
=
"Invalid index type: "
+
std
::
to_string
(
index_type
);
std
::
string
msg
=
"Invalid index type: "
+
std
::
to_string
(
index_type
)
+
". "
+
"Make sure the index type is in IndexType list."
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_INDEX_TYPE
,
msg
);
}
#ifndef CUSTOMIZATION
// special case, hybird index only available in customize faiss library
if
(
engine_type
==
static_cast
<
int
>
(
engine
::
EngineType
::
FAISS_IVFSQ8H
))
{
std
::
string
msg
=
"Unsupported index type: "
+
std
::
to_string
(
index_type
);
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_INDEX_TYPE
,
msg
);
return
Status
(
SERVER_INVALID_INDEX_TYPE
,
msg
);
}
}
#endif
return
Status
::
OK
();
return
Status
::
OK
();
}
}
...
@@ -100,7 +108,8 @@ ValidationUtil::ValidateTableIndexType(int32_t index_type) {
...
@@ -100,7 +108,8 @@ ValidationUtil::ValidateTableIndexType(int32_t index_type) {
Status
Status
ValidationUtil
::
ValidateTableIndexNlist
(
int32_t
nlist
)
{
ValidationUtil
::
ValidateTableIndexNlist
(
int32_t
nlist
)
{
if
(
nlist
<=
0
)
{
if
(
nlist
<=
0
)
{
std
::
string
msg
=
"nlist value should be greater than 0"
;
std
::
string
msg
=
"Invalid index nlist: "
+
std
::
to_string
(
nlist
)
+
". "
+
"The index nlist must be greater than 0."
;
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_INDEX_NLIST
,
msg
);
return
Status
(
SERVER_INVALID_INDEX_NLIST
,
msg
);
}
}
...
@@ -111,7 +120,9 @@ ValidationUtil::ValidateTableIndexNlist(int32_t nlist) {
...
@@ -111,7 +120,9 @@ ValidationUtil::ValidateTableIndexNlist(int32_t nlist) {
Status
Status
ValidationUtil
::
ValidateTableIndexFileSize
(
int64_t
index_file_size
)
{
ValidationUtil
::
ValidateTableIndexFileSize
(
int64_t
index_file_size
)
{
if
(
index_file_size
<=
0
||
index_file_size
>
INDEX_FILE_SIZE_LIMIT
)
{
if
(
index_file_size
<=
0
||
index_file_size
>
INDEX_FILE_SIZE_LIMIT
)
{
std
::
string
msg
=
"Invalid index file size: "
+
std
::
to_string
(
index_file_size
);
std
::
string
msg
=
"Invalid index file size: "
+
std
::
to_string
(
index_file_size
)
+
". "
+
"The index file size must be within the range of 1 ~ "
+
std
::
to_string
(
INDEX_FILE_SIZE_LIMIT
)
+
"."
;
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_INDEX_FILE_SIZE
,
msg
);
return
Status
(
SERVER_INVALID_INDEX_FILE_SIZE
,
msg
);
}
}
...
@@ -123,7 +134,8 @@ Status
...
@@ -123,7 +134,8 @@ Status
ValidationUtil
::
ValidateTableIndexMetricType
(
int32_t
metric_type
)
{
ValidationUtil
::
ValidateTableIndexMetricType
(
int32_t
metric_type
)
{
if
(
metric_type
!=
static_cast
<
int32_t
>
(
engine
::
MetricType
::
L2
)
&&
if
(
metric_type
!=
static_cast
<
int32_t
>
(
engine
::
MetricType
::
L2
)
&&
metric_type
!=
static_cast
<
int32_t
>
(
engine
::
MetricType
::
IP
))
{
metric_type
!=
static_cast
<
int32_t
>
(
engine
::
MetricType
::
IP
))
{
std
::
string
msg
=
"Invalid metric type: "
+
std
::
to_string
(
metric_type
);
std
::
string
msg
=
"Invalid index metric type: "
+
std
::
to_string
(
metric_type
)
+
". "
+
"Make sure the metric type is either MetricType.L2 or MetricType.IP."
;
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_INDEX_METRIC_TYPE
,
msg
);
return
Status
(
SERVER_INVALID_INDEX_METRIC_TYPE
,
msg
);
}
}
...
@@ -133,7 +145,8 @@ ValidationUtil::ValidateTableIndexMetricType(int32_t metric_type) {
...
@@ -133,7 +145,8 @@ ValidationUtil::ValidateTableIndexMetricType(int32_t metric_type) {
Status
Status
ValidationUtil
::
ValidateSearchTopk
(
int64_t
top_k
,
const
engine
::
meta
::
TableSchema
&
table_schema
)
{
ValidationUtil
::
ValidateSearchTopk
(
int64_t
top_k
,
const
engine
::
meta
::
TableSchema
&
table_schema
)
{
if
(
top_k
<=
0
||
top_k
>
2048
)
{
if
(
top_k
<=
0
||
top_k
>
2048
)
{
std
::
string
msg
=
"Invalid top k value: "
+
std
::
to_string
(
top_k
)
+
", rational range [1, 2048]"
;
std
::
string
msg
=
"Invalid topk: "
+
std
::
to_string
(
top_k
)
+
". "
+
"The topk must be within the range of 1 ~ 2048."
;
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_TOPK
,
msg
);
return
Status
(
SERVER_INVALID_TOPK
,
msg
);
}
}
...
@@ -144,8 +157,8 @@ ValidationUtil::ValidateSearchTopk(int64_t top_k, const engine::meta::TableSchem
...
@@ -144,8 +157,8 @@ ValidationUtil::ValidateSearchTopk(int64_t top_k, const engine::meta::TableSchem
Status
Status
ValidationUtil
::
ValidateSearchNprobe
(
int64_t
nprobe
,
const
engine
::
meta
::
TableSchema
&
table_schema
)
{
ValidationUtil
::
ValidateSearchNprobe
(
int64_t
nprobe
,
const
engine
::
meta
::
TableSchema
&
table_schema
)
{
if
(
nprobe
<=
0
||
nprobe
>
table_schema
.
nlist_
)
{
if
(
nprobe
<=
0
||
nprobe
>
table_schema
.
nlist_
)
{
std
::
string
msg
=
"Invalid nprobe
value: "
+
std
::
to_string
(
nprobe
)
+
", rational range [1,
"
+
std
::
string
msg
=
"Invalid nprobe
: "
+
std
::
to_string
(
nprobe
)
+
".
"
+
std
::
to_string
(
table_schema
.
nlist_
)
+
"]
"
;
"The nprobe must be within the range of 1 ~ index nlist.
"
;
SERVER_LOG_ERROR
<<
msg
;
SERVER_LOG_ERROR
<<
msg
;
return
Status
(
SERVER_INVALID_NPROBE
,
msg
);
return
Status
(
SERVER_INVALID_NPROBE
,
msg
);
}
}
...
...
core/src/wrapper/KnowhereResource.cpp
浏览文件 @
a602302a
...
@@ -45,7 +45,7 @@ KnowhereResource::Initialize() {
...
@@ -45,7 +45,7 @@ KnowhereResource::Initialize() {
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
int32_t
build_index_gpu
;
int32_t
build_index_gpu
;
s
=
config
.
Get
DBConfigBuildIndexGPU
(
build_index_gpu
);
s
=
config
.
Get
ResourceConfigIndexBuildDevice
(
build_index_gpu
);
if
(
!
s
.
ok
())
if
(
!
s
.
ok
())
return
s
;
return
s
;
...
@@ -53,7 +53,7 @@ KnowhereResource::Initialize() {
...
@@ -53,7 +53,7 @@ KnowhereResource::Initialize() {
// get search gpu resource
// get search gpu resource
std
::
vector
<
std
::
string
>
pool
;
std
::
vector
<
std
::
string
>
pool
;
s
=
config
.
GetResourceConfig
Pool
(
pool
);
s
=
config
.
GetResourceConfig
SearchResources
(
pool
);
if
(
!
s
.
ok
())
if
(
!
s
.
ok
())
return
s
;
return
s
;
...
...
core/unittest/server/appendix/server_config.yaml
浏览文件 @
a602302a
#
All the following configurations are default value
s.
#
Default values are used when you make no changes to the following parameter
s.
server_config
:
server_config
:
address
:
0.0.0.0
# milvus server ip address (IPv4)
address
:
0.0.0.0
# milvus server ip address (IPv4)
...
@@ -11,27 +11,33 @@ db_config:
...
@@ -11,27 +11,33 @@ db_config:
secondary_path
:
# path used to store data only, split by semicolon
secondary_path
:
# path used to store data only, split by semicolon
backend_url
:
sqlite://:@:/
# URI format: dialect://username:password@host:port/database
backend_url
:
sqlite://:@:/
# URI format: dialect://username:password@host:port/database
# Keep 'dialect://:@:/', and replace other texts with real values
.
# Keep 'dialect://:@:/', and replace other texts with real values
# Replace 'dialect' with 'mysql' or 'sqlite'
# Replace 'dialect' with 'mysql' or 'sqlite'
insert_buffer_size
:
4
# GB, maximum insert buffer size allowed
insert_buffer_size
:
4
# GB, maximum insert buffer size allowed
build_index_gpu
:
0
# gpu id used for building index
# sum of insert_buffer_size and cpu_cache_capacity cannot exceed total memory
preload_table
:
# preload data at startup, '*' means load all tables, empty value means no preload
# you can specify preload tables like this: table1,table2,table3
metric_config
:
metric_config
:
enable_monitor
:
false
# enable monitoring or not
enable_monitor
:
false
# enable monitoring or not
collector
:
prometheus
# prometheus
collector
:
prometheus
# prometheus
prometheus_config
:
prometheus_config
:
port
:
8080
# port prometheus use
d
to fetch metrics
port
:
8080
# port prometheus use
s
to fetch metrics
cache_config
:
cache_config
:
cpu_mem_capacity
:
16
# GB, CPU memory used for cache
cpu_cache_capacity
:
16
# GB, CPU memory used for cache
cpu_mem_threshold
:
0.85
# percentage of data kept when cache cleanup triggered
cpu_cache_threshold
:
0.85
# percentage of data that will be kept when cache cleanup is triggered
cache_insert_data
:
false
# whether load inserted data into cache
gpu_cache_capacity
:
4
# GB, GPU memory used for cache
gpu_cache_threshold
:
0.85
# percentage of data that will be kept when cache cleanup is triggered
cache_insert_data
:
false
# whether to load inserted data into cache
engine_config
:
engine_config
:
blas_threshold
:
20
use_blas_threshold
:
20
# if nq < use_blas_threshold, use SSE, faster with fluctuated response times
# if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
resource_config
:
resource_config
:
resource_pool
:
search_resources
:
# define the GPUs used for search computation, valid value: gpux
-
cpu
-
gpu0
-
gpu0
index_build_device
:
gpu0
# GPU used for building index
core/unittest/wrapper/test_wrapper.cpp
浏览文件 @
a602302a
...
@@ -164,3 +164,14 @@ TEST_P(KnowhereWrapperTest, SERIALIZE_TEST) {
...
@@ -164,3 +164,14 @@ TEST_P(KnowhereWrapperTest, SERIALIZE_TEST) {
AssertResult
(
res_ids
,
res_dis
);
AssertResult
(
res_ids
,
res_dis
);
}
}
}
}
#include "wrapper/ConfAdapter.h"
TEST
(
whatever
,
test_config
)
{
milvus
::
engine
::
TempMetaConf
conf
;
auto
nsg_conf
=
std
::
make_shared
<
milvus
::
engine
::
NSGConfAdapter
>
();
nsg_conf
->
Match
(
conf
);
nsg_conf
->
MatchSearch
(
conf
,
milvus
::
engine
::
IndexType
::
FAISS_IVFPQ_GPU
);
auto
pq_conf
=
std
::
make_shared
<
milvus
::
engine
::
IVFPQConfAdapter
>
();
pq_conf
->
Match
(
conf
);
}
core/unittest/wrapper/utils.h
浏览文件 @
a602302a
...
@@ -104,28 +104,28 @@ class ParamGenerator {
...
@@ -104,28 +104,28 @@ class ParamGenerator {
tempconf
->
metric_type
=
knowhere
::
METRICTYPE
::
L2
;
tempconf
->
metric_type
=
knowhere
::
METRICTYPE
::
L2
;
return
tempconf
;
return
tempconf
;
}
}
case
milvus
::
engine
::
IndexType
::
FAISS_IVFPQ_CPU
:
//
case milvus::engine::IndexType::FAISS_IVFPQ_CPU:
case
milvus
::
engine
::
IndexType
::
FAISS_IVFPQ_GPU
:
{
//
case milvus::engine::IndexType::FAISS_IVFPQ_GPU: {
auto
tempconf
=
std
::
make_shared
<
knowhere
::
IVFPQCfg
>
();
//
auto tempconf = std::make_shared<knowhere::IVFPQCfg>();
tempconf
->
nlist
=
100
;
//
tempconf->nlist = 100;
tempconf
->
nprobe
=
16
;
//
tempconf->nprobe = 16;
tempconf
->
nbits
=
8
;
//
tempconf->nbits = 8;
tempconf
->
m
=
8
;
//
tempconf->m = 8;
tempconf
->
metric_type
=
knowhere
::
METRICTYPE
::
L2
;
//
tempconf->metric_type = knowhere::METRICTYPE::L2;
return
tempconf
;
//
return tempconf;
}
//
}
case
milvus
::
engine
::
IndexType
::
NSG_MIX
:
{
//
case milvus::engine::IndexType::NSG_MIX: {
auto
tempconf
=
std
::
make_shared
<
knowhere
::
NSGCfg
>
();
//
auto tempconf = std::make_shared<knowhere::NSGCfg>();
tempconf
->
nlist
=
100
;
//
tempconf->nlist = 100;
tempconf
->
nprobe
=
16
;
//
tempconf->nprobe = 16;
tempconf
->
search_length
=
8
;
//
tempconf->search_length = 8;
tempconf
->
knng
=
200
;
//
tempconf->knng = 200;
tempconf
->
search_length
=
40
;
// TODO(linxj): be 20 when search
//
tempconf->search_length = 40; // TODO(linxj): be 20 when search
tempconf
->
out_degree
=
60
;
//
tempconf->out_degree = 60;
tempconf
->
candidate_pool_size
=
200
;
//
tempconf->candidate_pool_size = 200;
tempconf
->
metric_type
=
knowhere
::
METRICTYPE
::
L2
;
//
tempconf->metric_type = knowhere::METRICTYPE::L2;
return
tempconf
;
//
return tempconf;
}
//
}
}
}
}
}
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录