Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
9fdfee96
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,发现更多精彩内容 >>
提交
9fdfee96
编写于
8月 14, 2019
作者:
Y
Yu Kun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add preloadtable
Former-commit-id: 61faf0724db583db9e2bea14b3ee6c9ad6e11eb8
上级
80fc6d3b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
81 addition
and
0 deletion
+81
-0
cpp/src/db/DB.h
cpp/src/db/DB.h
+1
-0
cpp/src/db/DBImpl.cpp
cpp/src/db/DBImpl.cpp
+31
-0
cpp/src/db/DBImpl.h
cpp/src/db/DBImpl.h
+3
-0
cpp/src/db/meta/Meta.h
cpp/src/db/meta/Meta.h
+3
-0
cpp/src/db/meta/MySQLMetaImpl.cpp
cpp/src/db/meta/MySQLMetaImpl.cpp
+5
-0
cpp/src/db/meta/MySQLMetaImpl.h
cpp/src/db/meta/MySQLMetaImpl.h
+1
-0
cpp/src/db/meta/SqliteMetaImpl.cpp
cpp/src/db/meta/SqliteMetaImpl.cpp
+34
-0
cpp/src/db/meta/SqliteMetaImpl.h
cpp/src/db/meta/SqliteMetaImpl.h
+3
-0
未找到文件。
cpp/src/db/DB.h
浏览文件 @
9fdfee96
...
@@ -28,6 +28,7 @@ public:
...
@@ -28,6 +28,7 @@ public:
virtual
Status
HasTable
(
const
std
::
string
&
table_id
,
bool
&
has_or_not_
)
=
0
;
virtual
Status
HasTable
(
const
std
::
string
&
table_id
,
bool
&
has_or_not_
)
=
0
;
virtual
Status
AllTables
(
std
::
vector
<
meta
::
TableSchema
>&
table_schema_array
)
=
0
;
virtual
Status
AllTables
(
std
::
vector
<
meta
::
TableSchema
>&
table_schema_array
)
=
0
;
virtual
Status
GetTableRowCount
(
const
std
::
string
&
table_id
,
uint64_t
&
row_count
)
=
0
;
virtual
Status
GetTableRowCount
(
const
std
::
string
&
table_id
,
uint64_t
&
row_count
)
=
0
;
virtual
Status
PreloadTable
(
const
std
::
string
&
table_id
)
=
0
;
virtual
Status
InsertVectors
(
const
std
::
string
&
table_id_
,
virtual
Status
InsertVectors
(
const
std
::
string
&
table_id_
,
uint64_t
n
,
const
float
*
vectors
,
IDNumbers
&
vector_ids_
)
=
0
;
uint64_t
n
,
const
float
*
vectors
,
IDNumbers
&
vector_ids_
)
=
0
;
...
...
cpp/src/db/DBImpl.cpp
浏览文件 @
9fdfee96
...
@@ -32,6 +32,7 @@ namespace {
...
@@ -32,6 +32,7 @@ namespace {
constexpr
uint64_t
METRIC_ACTION_INTERVAL
=
1
;
constexpr
uint64_t
METRIC_ACTION_INTERVAL
=
1
;
constexpr
uint64_t
COMPACT_ACTION_INTERVAL
=
1
;
constexpr
uint64_t
COMPACT_ACTION_INTERVAL
=
1
;
constexpr
uint64_t
INDEX_ACTION_INTERVAL
=
1
;
constexpr
uint64_t
INDEX_ACTION_INTERVAL
=
1
;
constexpr
int64_t
unit
=
1024
*
1024
*
1024
;
void
CollectInsertMetrics
(
double
total_time
,
size_t
n
,
bool
succeed
)
{
void
CollectInsertMetrics
(
double
total_time
,
size_t
n
,
bool
succeed
)
{
double
avg_time
=
total_time
/
n
;
double
avg_time
=
total_time
/
n
;
...
@@ -127,6 +128,36 @@ Status DBImpl::AllTables(std::vector<meta::TableSchema>& table_schema_array) {
...
@@ -127,6 +128,36 @@ Status DBImpl::AllTables(std::vector<meta::TableSchema>& table_schema_array) {
return
meta_ptr_
->
AllTables
(
table_schema_array
);
return
meta_ptr_
->
AllTables
(
table_schema_array
);
}
}
Status
DBImpl
::
PreloadTable
(
const
std
::
string
&
table_id
)
{
meta
::
TableFilesSchema
files
;
auto
status
=
meta_ptr_
->
PreloadTable
(
table_id
,
files
);
int64_t
size
=
0
;
server
::
ConfigNode
&
config
=
server
::
ServerConfig
::
GetInstance
().
GetConfig
(
server
::
CONFIG_CACHE
);
int64_t
cap
=
config
.
GetInt64Value
(
server
::
CONFIG_CPU_CACHE_CAPACITY
,
16
);
cap
*=
unit
;
for
(
auto
&
file
:
files
)
{
ExecutionEnginePtr
engine
=
EngineFactory
::
Build
(
file
.
dimension_
,
file
.
location_
,
(
EngineType
)
file
.
engine_type_
);
if
(
engine
==
nullptr
)
{
ENGINE_LOG_ERROR
<<
"Invalid engine type"
;
return
Status
::
Error
(
"Invalid engine type"
);
}
size
+=
engine
->
PhysicalSize
();
if
(
size
<=
cap
)
{
try
{
//step 1: load index
engine
->
Load
(
options_
.
insert_cache_immediately_
);
}
catch
(
std
::
exception
&
ex
)
{
std
::
string
msg
=
"load to cache exception"
+
std
::
string
(
ex
.
what
());
ENGINE_LOG_ERROR
<<
msg
;
return
Status
::
Error
(
msg
);
}
}
}
}
Status
DBImpl
::
GetTableRowCount
(
const
std
::
string
&
table_id
,
uint64_t
&
row_count
)
{
Status
DBImpl
::
GetTableRowCount
(
const
std
::
string
&
table_id
,
uint64_t
&
row_count
)
{
return
meta_ptr_
->
Count
(
table_id
,
row_count
);
return
meta_ptr_
->
Count
(
table_id
,
row_count
);
}
}
...
...
cpp/src/db/DBImpl.h
浏览文件 @
9fdfee96
...
@@ -51,6 +51,9 @@ class DBImpl : public DB {
...
@@ -51,6 +51,9 @@ class DBImpl : public DB {
Status
Status
AllTables
(
std
::
vector
<
meta
::
TableSchema
>
&
table_schema_array
)
override
;
AllTables
(
std
::
vector
<
meta
::
TableSchema
>
&
table_schema_array
)
override
;
Status
PreloadTable
(
const
std
::
string
&
table_id
)
override
;
Status
Status
GetTableRowCount
(
const
std
::
string
&
table_id
,
uint64_t
&
row_count
)
override
;
GetTableRowCount
(
const
std
::
string
&
table_id
,
uint64_t
&
row_count
)
override
;
...
...
cpp/src/db/meta/Meta.h
浏览文件 @
9fdfee96
...
@@ -38,6 +38,9 @@ class Meta {
...
@@ -38,6 +38,9 @@ class Meta {
virtual
Status
virtual
Status
AllTables
(
std
::
vector
<
TableSchema
>
&
table_schema_array
)
=
0
;
AllTables
(
std
::
vector
<
TableSchema
>
&
table_schema_array
)
=
0
;
virtual
Status
PreloadTable
(
const
std
::
string
&
table_id
,
meta
::
TableFilesSchema
&
files
)
=
0
;
virtual
Status
virtual
Status
DeleteTable
(
const
std
::
string
&
table_id
)
=
0
;
DeleteTable
(
const
std
::
string
&
table_id
)
=
0
;
...
...
cpp/src/db/meta/MySQLMetaImpl.cpp
浏览文件 @
9fdfee96
...
@@ -690,6 +690,11 @@ Status MySQLMetaImpl::AllTables(std::vector<TableSchema> &table_schema_array) {
...
@@ -690,6 +690,11 @@ Status MySQLMetaImpl::AllTables(std::vector<TableSchema> &table_schema_array) {
return
Status
::
OK
();
return
Status
::
OK
();
}
}
Status
MySQLMetaImpl
::
PreloadTable
(
const
std
::
string
&
table_id
,
meta
::
TableFilesSchema
&
files_schema
)
{
}
Status
MySQLMetaImpl
::
CreateTableFile
(
TableFileSchema
&
file_schema
)
{
Status
MySQLMetaImpl
::
CreateTableFile
(
TableFileSchema
&
file_schema
)
{
...
...
cpp/src/db/meta/MySQLMetaImpl.h
浏览文件 @
9fdfee96
...
@@ -29,6 +29,7 @@ class MySQLMetaImpl : public Meta {
...
@@ -29,6 +29,7 @@ class MySQLMetaImpl : public Meta {
Status
DescribeTable
(
TableSchema
&
group_info_
)
override
;
Status
DescribeTable
(
TableSchema
&
group_info_
)
override
;
Status
HasTable
(
const
std
::
string
&
table_id
,
bool
&
has_or_not
)
override
;
Status
HasTable
(
const
std
::
string
&
table_id
,
bool
&
has_or_not
)
override
;
Status
AllTables
(
std
::
vector
<
TableSchema
>
&
table_schema_array
)
override
;
Status
AllTables
(
std
::
vector
<
TableSchema
>
&
table_schema_array
)
override
;
Status
PreloadTable
(
const
std
::
string
&
table_id
,
meta
::
TableFilesSchema
&
files_schema
)
override
;
Status
DeleteTable
(
const
std
::
string
&
table_id
)
override
;
Status
DeleteTable
(
const
std
::
string
&
table_id
)
override
;
Status
DeleteTableFiles
(
const
std
::
string
&
table_id
)
override
;
Status
DeleteTableFiles
(
const
std
::
string
&
table_id
)
override
;
...
...
cpp/src/db/meta/SqliteMetaImpl.cpp
浏览文件 @
9fdfee96
...
@@ -404,6 +404,40 @@ Status SqliteMetaImpl::AllTables(std::vector<TableSchema>& table_schema_array) {
...
@@ -404,6 +404,40 @@ Status SqliteMetaImpl::AllTables(std::vector<TableSchema>& table_schema_array) {
return
Status
::
OK
();
return
Status
::
OK
();
}
}
Status
SqliteMetaImpl
::
PreloadTable
(
const
std
::
string
&
table_id
,
TableFilesSchema
&
files_schema
)
{
try
{
MetricCollector
metric
;
auto
selected
=
ConnectorPtr
->
select
(
columns
(
&
TableFileSchema
::
size_
,
&
TableFileSchema
::
dimension_
,
&
TableFileSchema
::
location_
,
&
TableFileSchema
::
engine_type_
),
where
(
c
(
&
TableFileSchema
::
table_id_
)
==
table_id
));
TableSchema
table_schema
;
table_schema
.
table_id_
=
table_id
;
auto
status
=
DescribeTable
(
table_schema
);
if
(
!
status
.
ok
())
{
return
status
;
}
int64_t
size
=
0
;
for
(
auto
&
file
:
selected
)
{
TableFileSchema
file_schema
;
file_schema
.
size_
=
std
::
get
<
0
>
(
file
);
file_schema
.
dimension_
=
std
::
get
<
1
>
(
file
);
file_schema
.
location_
=
std
::
get
<
2
>
(
file
);
file_schema
.
engine_type_
=
std
::
get
<
3
>
(
file
);
files_schema
.
push_back
(
file_schema
);
}
}
catch
(
std
::
exception
&
e
)
{
return
HandleException
(
"Encounter exception when lookup all tables"
,
e
);
}
return
Status
::
OK
();
}
Status
SqliteMetaImpl
::
CreateTableFile
(
TableFileSchema
&
file_schema
)
{
Status
SqliteMetaImpl
::
CreateTableFile
(
TableFileSchema
&
file_schema
)
{
if
(
file_schema
.
date_
==
EmptyDate
)
{
if
(
file_schema
.
date_
==
EmptyDate
)
{
file_schema
.
date_
=
Meta
::
GetDate
();
file_schema
.
date_
=
Meta
::
GetDate
();
...
...
cpp/src/db/meta/SqliteMetaImpl.h
浏览文件 @
9fdfee96
...
@@ -33,6 +33,9 @@ class SqliteMetaImpl : public Meta {
...
@@ -33,6 +33,9 @@ class SqliteMetaImpl : public Meta {
Status
Status
AllTables
(
std
::
vector
<
TableSchema
>
&
table_schema_array
)
override
;
AllTables
(
std
::
vector
<
TableSchema
>
&
table_schema_array
)
override
;
Status
PreloadTable
(
const
std
::
string
&
table_id
,
meta
::
TableFilesSchema
&
files_schema
)
override
;
Status
Status
DeleteTable
(
const
std
::
string
&
table_id
)
override
;
DeleteTable
(
const
std
::
string
&
table_id
)
override
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录