Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
6191bc79
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,发现更多精彩内容 >>
提交
6191bc79
编写于
9月 05, 2019
作者:
G
groot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change api
Former-commit-id: 15b60db0b146173e65a7d31558cc8091f222a913
上级
b2e029c4
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
137 addition
and
131 deletion
+137
-131
cpp/src/db/DBImpl.cpp
cpp/src/db/DBImpl.cpp
+3
-1
cpp/src/db/engine/ExecutionEngineImpl.cpp
cpp/src/db/engine/ExecutionEngineImpl.cpp
+2
-1
cpp/src/grpc/gen-milvus/milvus.pb.cc
cpp/src/grpc/gen-milvus/milvus.pb.cc
+94
-94
cpp/src/grpc/gen-milvus/milvus.pb.h
cpp/src/grpc/gen-milvus/milvus.pb.h
+21
-21
cpp/src/grpc/milvus.proto
cpp/src/grpc/milvus.proto
+1
-1
cpp/src/sdk/examples/grpcsimple/src/ClientTest.cpp
cpp/src/sdk/examples/grpcsimple/src/ClientTest.cpp
+1
-1
cpp/src/sdk/grpc/ClientProxy.cpp
cpp/src/sdk/grpc/ClientProxy.cpp
+3
-4
cpp/src/sdk/include/MilvusApi.h
cpp/src/sdk/include/MilvusApi.h
+6
-1
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
+6
-7
未找到文件。
cpp/src/db/DBImpl.cpp
浏览文件 @
6191bc79
...
...
@@ -250,7 +250,9 @@ Status DBImpl::CreateIndex(const std::string& table_id, const TableIndex& index)
}
//step 2: update index info
if
(
!
utils
::
IsSameIndex
(
old_index
,
index
))
{
TableIndex
new_index
=
index
;
new_index
.
metric_type_
=
old_index
.
metric_type_
;
//dont change metric type, it was defined by CreateTable
if
(
!
utils
::
IsSameIndex
(
old_index
,
new_index
))
{
DropIndex
(
table_id
);
status
=
meta_ptr_
->
UpdateTableIndexParam
(
table_id
,
index
);
...
...
cpp/src/db/engine/ExecutionEngineImpl.cpp
浏览文件 @
6191bc79
...
...
@@ -301,7 +301,8 @@ Status ExecutionEngineImpl::Search(long n,
}
ENGINE_LOG_DEBUG
<<
"Search Params: [k] "
<<
k
<<
" [nprobe] "
<<
nprobe
;
auto
ec
=
index_
->
Search
(
n
,
data
,
distances
,
labels
,
Config
::
object
{{
"k"
,
k
},
{
"nprobe"
,
nprobe
}});
auto
cfg
=
Config
::
object
{{
"k"
,
k
},
{
"nprobe"
,
nprobe
}};
auto
ec
=
index_
->
Search
(
n
,
data
,
distances
,
labels
,
cfg
);
if
(
ec
!=
server
::
KNOWHERE_SUCCESS
)
{
ENGINE_LOG_ERROR
<<
"Search error"
;
return
Status
::
Error
(
"Search: Search Error"
);
...
...
cpp/src/grpc/gen-milvus/milvus.pb.cc
浏览文件 @
6191bc79
...
...
@@ -367,6 +367,7 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_milvus_2eproto::offsets[] PROT
PROTOBUF_FIELD_OFFSET
(
::
milvus
::
grpc
::
TableSchema
,
table_name_
),
PROTOBUF_FIELD_OFFSET
(
::
milvus
::
grpc
::
TableSchema
,
dimension_
),
PROTOBUF_FIELD_OFFSET
(
::
milvus
::
grpc
::
TableSchema
,
index_file_size_
),
PROTOBUF_FIELD_OFFSET
(
::
milvus
::
grpc
::
TableSchema
,
metric_type_
),
~
0u
,
// no _has_bits_
PROTOBUF_FIELD_OFFSET
(
::
milvus
::
grpc
::
Range
,
_internal_metadata_
),
~
0u
,
// no _extensions_
...
...
@@ -460,7 +461,6 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_milvus_2eproto::offsets[] PROT
~
0u
,
// no _weak_field_map_
PROTOBUF_FIELD_OFFSET
(
::
milvus
::
grpc
::
Index
,
index_type_
),
PROTOBUF_FIELD_OFFSET
(
::
milvus
::
grpc
::
Index
,
nlist_
),
PROTOBUF_FIELD_OFFSET
(
::
milvus
::
grpc
::
Index
,
metric_type_
),
~
0u
,
// no _has_bits_
PROTOBUF_FIELD_OFFSET
(
::
milvus
::
grpc
::
IndexParam
,
_internal_metadata_
),
~
0u
,
// no _extensions_
...
...
@@ -479,19 +479,19 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_milvus_2eproto::offsets[] PROT
static
const
::
PROTOBUF_NAMESPACE_ID
::
internal
::
MigrationSchema
schemas
[]
PROTOBUF_SECTION_VARIABLE
(
protodesc_cold
)
=
{
{
0
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
TableName
)},
{
7
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
TableSchema
)},
{
1
5
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
Range
)},
{
2
2
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
RowRecord
)},
{
2
8
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
InsertParam
)},
{
3
6
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
VectorIds
)},
{
4
3
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
SearchParam
)},
{
5
3
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
SearchInFilesParam
)},
{
6
0
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
QueryResult
)},
{
6
7
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
TopKQueryResult
)},
{
7
4
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
StringReply
)},
{
8
1
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
BoolReply
)},
{
8
8
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
TableRowCount
)},
{
9
5
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
Command
)},
{
10
1
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
Index
)},
{
1
6
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
Range
)},
{
2
3
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
RowRecord
)},
{
2
9
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
InsertParam
)},
{
3
7
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
VectorIds
)},
{
4
4
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
SearchParam
)},
{
5
4
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
SearchInFilesParam
)},
{
6
1
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
QueryResult
)},
{
6
8
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
TopKQueryResult
)},
{
7
5
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
StringReply
)},
{
8
2
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
BoolReply
)},
{
8
9
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
TableRowCount
)},
{
9
6
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
Command
)},
{
10
2
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
Index
)},
{
109
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
IndexParam
)},
{
116
,
-
1
,
sizeof
(
::
milvus
::
grpc
::
DeleteByRangeParam
)},
};
...
...
@@ -519,35 +519,35 @@ static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] =
const
char
descriptor_table_protodef_milvus_2eproto
[]
PROTOBUF_SECTION_VARIABLE
(
protodesc_cold
)
=
"
\n\014
milvus.proto
\022\013
milvus.grpc
\032\014
status.prot"
"o
\"
D
\n\t
TableName
\022
#
\n\006
status
\030\001
\001
(
\013
2
\023
.milvus."
"grpc.Status
\022\022\n\n
table_name
\030\002
\001
(
\t\"
e
\n\013
Table"
"grpc.Status
\022\022\n\n
table_name
\030\002
\001
(
\t\"
z
\n\013
Table"
"Schema
\022
*
\n\n
table_name
\030\001
\001
(
\013
2
\026
.milvus.grpc"
".TableName
\022\021\n\t
dimension
\030\002
\001
(
\003\022\027\n\017
index_f"
"ile_size
\030\003
\001
(
\003\
"
/
\n\005
Range
\022\023\n\013
start_value
\030\001
"
"
\001
(
\t\022\021\n\t
end_value
\030\002
\001
(
\t\"
\n\t
RowRecord
\022\023\n\013
"
"
vector_data
\030\001
\003
(
\002\"
i
\n\013
InsertParam
\022\022\n\n
tabl
"
"
e_name
\030\001
\001
(
\t\022
0
\n\020
row_record_array
\030\002
\003
(
\013
2
\026
"
"
.milvus.grpc.RowRecord
\022\024\n\014
row_id_array
\030\003
"
"
\003
(
\003\"
I
\n\t
VectorIds
\022
#
\n\006
status
\030\001
\001
(
\013
2
\023
.milv
"
"
us.grpc.Status
\022\027\n\017
vector_id_array
\030\002
\003
(
\003\"
"
"
\242\001\n\013
SearchParam
\022\022\n\n
table_name
\030\001
\001
(
\t\022
2
\n\022
q
"
"
uery_record_array
\030\002
\003
(
\013
2
\026
.milvus.grpc.Ro
"
"
wRecord
\022
-
\n\021
query_range_array
\030\003
\003
(
\013
2
\022
.mil
"
"
vus.grpc.Range
\022\014\n\004
topk
\030\004
\001
(
\003\022\016\n\006
nprobe
\030\005
"
"
\001
(
\003\"
[
\n\022
SearchInFilesParam
\022\025\n\r
file_id_ar
"
"
ray
\030\001
\003
(
\t\022
.
\n\014
search_param
\030\002
\001
(
\013
2
\030
.milvus
"
"
.grpc.SearchParam
\"
+
\n\013
QueryResult
\022\n\n\002
id
\030\001
"
"
\001
(
\003\022\020\n\010
distance
\030\002
\001
(
\001\"
m
\n\017
TopKQueryResul
"
"
t
\022
#
\n\006
status
\030\001
\001
(
\013
2
\023
.milvus.grpc.Status
\022
5
"
"
\n\023
query_result_arrays
\030\002
\003
(
\013
2
\030
.milvus.grp
"
"
c.QueryResult
\"
H
\n\013
StringReply
\022
#
\n\006
status
\030\001
"
"
\001
(
\013
2
\023
.milvus.grpc.Status
\022\024\n\014
string_repl
"
"
y
\030\002
\001
(
\t\"
D
\n\t
BoolReply
\022
#
\n\006
status
\030\001
\001
(
\013
2
\023
.m
"
"
ilvus.grpc.Status
\022\022\n\n
bool_reply
\030\002
\001
(
\010\"
M
\n
"
"
\
r
TableRowCount
\022
#
\n\006
status
\030\001
\001
(
\013
2
\023
.milvus.
"
"
grpc.Status
\022\027\n\017
table_row_count
\030\002
\001
(
\003\"\026\n\007
"
"
Command
\022\013\n\003
cmd
\030\001
\001
(
\t\"
\?
\n\005
Index
\022\022\n\n
index_t
"
"
ype
\030\001
\001
(
\005\022\r\n\005
nlist
\030\002
\001
(
\005\022\023\n\013
metric_type
\030
"
"
\00
3
\001
(
\005\"
[
\n\n
IndexParam
\022
*
\n\n
table_name
\030\001
\001
(
\013
2"
"ile_size
\030\003
\001
(
\003\
022\023\n\013
metric_type
\030\004
\001
(
\005\"
/
\n\005
R
"
"
ange
\022\023\n\013
start_value
\030\001
\001
(
\t\022\021\n\t
end_value
\030\002
"
"
\001
(
\t\"
\n\t
RowRecord
\022\023\n\013
vector_data
\030\001
\003
(
\002\"
i
"
"
\n\013
InsertParam
\022\022\n\n
table_name
\030\001
\001
(
\t\022
0
\n\020
row
"
"
_record_array
\030\002
\003
(
\013
2
\026
.milvus.grpc.RowRec
"
"
ord
\022\024\n\014
row_id_array
\030\003
\003
(
\003\"
I
\n\t
VectorIds
\022
#
"
"
\n\006
status
\030\001
\001
(
\013
2
\023
.milvus.grpc.Status
\022\027\n\017
v
"
"
ector_id_array
\030\002
\003
(
\003\"\242\001\n\013
SearchParam
\022\022\n\n
"
"
table_name
\030\001
\001
(
\t\022
2
\n\022
query_record_array
\030\002
"
"
\003
(
\013
2
\026
.milvus.grpc.RowRecord
\022
-
\n\021
query_ra
"
"
nge_array
\030\003
\003
(
\013
2
\022
.milvus.grpc.Range
\022\014\n\004
t
"
"
opk
\030\004
\001
(
\003\022\016\n\006
nprobe
\030\005
\001
(
\003\"
[
\n\022
SearchInFil
"
"
esParam
\022\025\n\r
file_id_array
\030\001
\003
(
\t\022
.
\n\014
search
"
"
_param
\030\002
\001
(
\013
2
\030
.milvus.grpc.SearchParam
\"
+
"
"
\n\013
QueryResult
\022\n\n\002
id
\030\001
\001
(
\003\022\020\n\010
distance
\030\002
"
"
\001
(
\001\"
m
\n\017
TopKQueryResult
\022
#
\n\006
status
\030\001
\001
(
\013
2
\023
"
"
.milvus.grpc.Status
\022
5
\n\023
query_result_arra
"
"
ys
\030\002
\003
(
\013
2
\030
.milvus.grpc.QueryResult
\"
H
\n\013
St
"
"
ringReply
\022
#
\n\006
status
\030\001
\001
(
\013
2
\023
.milvus.grpc.
"
"
Status
\022\024\n\014
string_reply
\030\002
\001
(
\t\"
D
\n\t
BoolRepl
"
"
y
\022
#
\n\006
status
\030\001
\001
(
\013
2
\023
.milvus.grpc.Status
\022\022
"
"
\
n\n
bool_reply
\030\002
\001
(
\010\"
M
\n\r
TableRowCount
\022
#
\n\006
s
"
"
tatus
\030\001
\001
(
\013
2
\023
.milvus.grpc.Status
\022\027\n\017
tabl
"
"
e_row_count
\030\002
\001
(
\003\"\026\n\007
Command
\022\013\n\003
cmd
\030\001
\001
(
"
"
\t\"
*
\n\005
Index
\022\022\n\n
index_type
\030\001
\001
(
\005\022\r\n\005
nlist
\030
"
"
\00
2
\001
(
\005\"
[
\n\n
IndexParam
\022
*
\n\n
table_name
\030\001
\001
(
\013
2"
"
\026
.milvus.grpc.TableName
\022
!
\n\005
index
\030\002
\001
(
\013
2
\022
"
".milvus.grpc.Index
\"
K
\n\022
DeleteByRangeParam"
"
\022
!
\n\005
range
\030\001
\001
(
\013
2
\022
.milvus.grpc.Range
\022\022\n\n
t"
...
...
@@ -979,16 +979,16 @@ TableSchema::TableSchema(const TableSchema& from)
table_name_
=
nullptr
;
}
::
memcpy
(
&
dimension_
,
&
from
.
dimension_
,
static_cast
<
size_t
>
(
reinterpret_cast
<
char
*>
(
&
index_file_siz
e_
)
-
reinterpret_cast
<
char
*>
(
&
dimension_
))
+
sizeof
(
index_file_siz
e_
));
static_cast
<
size_t
>
(
reinterpret_cast
<
char
*>
(
&
metric_typ
e_
)
-
reinterpret_cast
<
char
*>
(
&
dimension_
))
+
sizeof
(
metric_typ
e_
));
// @@protoc_insertion_point(copy_constructor:milvus.grpc.TableSchema)
}
void
TableSchema
::
SharedCtor
()
{
::
PROTOBUF_NAMESPACE_ID
::
internal
::
InitSCC
(
&
scc_info_TableSchema_milvus_2eproto
.
base
);
::
memset
(
&
table_name_
,
0
,
static_cast
<
size_t
>
(
reinterpret_cast
<
char
*>
(
&
index_file_siz
e_
)
-
reinterpret_cast
<
char
*>
(
&
table_name_
))
+
sizeof
(
index_file_siz
e_
));
reinterpret_cast
<
char
*>
(
&
metric_typ
e_
)
-
reinterpret_cast
<
char
*>
(
&
table_name_
))
+
sizeof
(
metric_typ
e_
));
}
TableSchema
::~
TableSchema
()
{
...
...
@@ -1020,8 +1020,8 @@ void TableSchema::Clear() {
}
table_name_
=
nullptr
;
::
memset
(
&
dimension_
,
0
,
static_cast
<
size_t
>
(
reinterpret_cast
<
char
*>
(
&
index_file_siz
e_
)
-
reinterpret_cast
<
char
*>
(
&
dimension_
))
+
sizeof
(
index_file_siz
e_
));
reinterpret_cast
<
char
*>
(
&
metric_typ
e_
)
-
reinterpret_cast
<
char
*>
(
&
dimension_
))
+
sizeof
(
metric_typ
e_
));
_internal_metadata_
.
Clear
();
}
...
...
@@ -1054,6 +1054,13 @@ const char* TableSchema::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID
CHK_
(
ptr
);
}
else
goto
handle_unusual
;
continue
;
// int32 metric_type = 4;
case
4
:
if
(
PROTOBUF_PREDICT_TRUE
(
static_cast
<::
PROTOBUF_NAMESPACE_ID
::
uint8
>
(
tag
)
==
32
))
{
metric_type_
=
::
PROTOBUF_NAMESPACE_ID
::
internal
::
ReadVarint
(
&
ptr
);
CHK_
(
ptr
);
}
else
goto
handle_unusual
;
continue
;
default:
{
handle_unusual:
if
((
tag
&
7
)
==
4
||
tag
==
0
)
{
...
...
@@ -1121,6 +1128,19 @@ bool TableSchema::MergePartialFromCodedStream(
break
;
}
// int32 metric_type = 4;
case
4
:
{
if
(
static_cast
<
::
PROTOBUF_NAMESPACE_ID
::
uint8
>
(
tag
)
==
(
32
&
0xFF
))
{
DO_
((
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
ReadPrimitive
<
::
PROTOBUF_NAMESPACE_ID
::
int32
,
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
TYPE_INT32
>
(
input
,
&
metric_type_
)));
}
else
{
goto
handle_unusual
;
}
break
;
}
default:
{
handle_unusual:
if
(
tag
==
0
)
{
...
...
@@ -1164,6 +1184,11 @@ void TableSchema::SerializeWithCachedSizes(
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
WriteInt64
(
3
,
this
->
index_file_size
(),
output
);
}
// int32 metric_type = 4;
if
(
this
->
metric_type
()
!=
0
)
{
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
WriteInt32
(
4
,
this
->
metric_type
(),
output
);
}
if
(
_internal_metadata_
.
have_unknown_fields
())
{
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormat
::
SerializeUnknownFields
(
_internal_metadata_
.
unknown_fields
(),
output
);
...
...
@@ -1194,6 +1219,11 @@ void TableSchema::SerializeWithCachedSizes(
target
=
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
WriteInt64ToArray
(
3
,
this
->
index_file_size
(),
target
);
}
// int32 metric_type = 4;
if
(
this
->
metric_type
()
!=
0
)
{
target
=
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
WriteInt32ToArray
(
4
,
this
->
metric_type
(),
target
);
}
if
(
_internal_metadata_
.
have_unknown_fields
())
{
target
=
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormat
::
SerializeUnknownFieldsToArray
(
_internal_metadata_
.
unknown_fields
(),
target
);
...
...
@@ -1236,6 +1266,13 @@ size_t TableSchema::ByteSizeLong() const {
this
->
index_file_size
());
}
// int32 metric_type = 4;
if
(
this
->
metric_type
()
!=
0
)
{
total_size
+=
1
+
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
Int32Size
(
this
->
metric_type
());
}
int
cached_size
=
::
PROTOBUF_NAMESPACE_ID
::
internal
::
ToCachedSize
(
total_size
);
SetCachedSize
(
cached_size
);
return
total_size
;
...
...
@@ -1272,6 +1309,9 @@ void TableSchema::MergeFrom(const TableSchema& from) {
if
(
from
.
index_file_size
()
!=
0
)
{
set_index_file_size
(
from
.
index_file_size
());
}
if
(
from
.
metric_type
()
!=
0
)
{
set_metric_type
(
from
.
metric_type
());
}
}
void
TableSchema
::
CopyFrom
(
const
::
PROTOBUF_NAMESPACE_ID
::
Message
&
from
)
{
...
...
@@ -1298,6 +1338,7 @@ void TableSchema::InternalSwap(TableSchema* other) {
swap
(
table_name_
,
other
->
table_name_
);
swap
(
dimension_
,
other
->
dimension_
);
swap
(
index_file_size_
,
other
->
index_file_size_
);
swap
(
metric_type_
,
other
->
metric_type_
);
}
::
PROTOBUF_NAMESPACE_ID
::
Metadata
TableSchema
::
GetMetadata
()
const
{
...
...
@@ -5314,15 +5355,15 @@ Index::Index(const Index& from)
_internal_metadata_
(
nullptr
)
{
_internal_metadata_
.
MergeFrom
(
from
.
_internal_metadata_
);
::
memcpy
(
&
index_type_
,
&
from
.
index_type_
,
static_cast
<
size_t
>
(
reinterpret_cast
<
char
*>
(
&
metric_type
_
)
-
reinterpret_cast
<
char
*>
(
&
index_type_
))
+
sizeof
(
metric_type
_
));
static_cast
<
size_t
>
(
reinterpret_cast
<
char
*>
(
&
nlist
_
)
-
reinterpret_cast
<
char
*>
(
&
index_type_
))
+
sizeof
(
nlist
_
));
// @@protoc_insertion_point(copy_constructor:milvus.grpc.Index)
}
void
Index
::
SharedCtor
()
{
::
memset
(
&
index_type_
,
0
,
static_cast
<
size_t
>
(
reinterpret_cast
<
char
*>
(
&
metric_type
_
)
-
reinterpret_cast
<
char
*>
(
&
index_type_
))
+
sizeof
(
metric_type
_
));
reinterpret_cast
<
char
*>
(
&
nlist
_
)
-
reinterpret_cast
<
char
*>
(
&
index_type_
))
+
sizeof
(
nlist
_
));
}
Index
::~
Index
()
{
...
...
@@ -5349,8 +5390,8 @@ void Index::Clear() {
(
void
)
cached_has_bits
;
::
memset
(
&
index_type_
,
0
,
static_cast
<
size_t
>
(
reinterpret_cast
<
char
*>
(
&
metric_type
_
)
-
reinterpret_cast
<
char
*>
(
&
index_type_
))
+
sizeof
(
metric_type
_
));
reinterpret_cast
<
char
*>
(
&
nlist
_
)
-
reinterpret_cast
<
char
*>
(
&
index_type_
))
+
sizeof
(
nlist
_
));
_internal_metadata_
.
Clear
();
}
...
...
@@ -5376,13 +5417,6 @@ const char* Index::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
CHK_
(
ptr
);
}
else
goto
handle_unusual
;
continue
;
// int32 metric_type = 3;
case
3
:
if
(
PROTOBUF_PREDICT_TRUE
(
static_cast
<::
PROTOBUF_NAMESPACE_ID
::
uint8
>
(
tag
)
==
24
))
{
metric_type_
=
::
PROTOBUF_NAMESPACE_ID
::
internal
::
ReadVarint
(
&
ptr
);
CHK_
(
ptr
);
}
else
goto
handle_unusual
;
continue
;
default:
{
handle_unusual:
if
((
tag
&
7
)
==
4
||
tag
==
0
)
{
...
...
@@ -5439,19 +5473,6 @@ bool Index::MergePartialFromCodedStream(
break
;
}
// int32 metric_type = 3;
case
3
:
{
if
(
static_cast
<
::
PROTOBUF_NAMESPACE_ID
::
uint8
>
(
tag
)
==
(
24
&
0xFF
))
{
DO_
((
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
ReadPrimitive
<
::
PROTOBUF_NAMESPACE_ID
::
int32
,
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
TYPE_INT32
>
(
input
,
&
metric_type_
)));
}
else
{
goto
handle_unusual
;
}
break
;
}
default:
{
handle_unusual:
if
(
tag
==
0
)
{
...
...
@@ -5489,11 +5510,6 @@ void Index::SerializeWithCachedSizes(
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
WriteInt32
(
2
,
this
->
nlist
(),
output
);
}
// int32 metric_type = 3;
if
(
this
->
metric_type
()
!=
0
)
{
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
WriteInt32
(
3
,
this
->
metric_type
(),
output
);
}
if
(
_internal_metadata_
.
have_unknown_fields
())
{
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormat
::
SerializeUnknownFields
(
_internal_metadata_
.
unknown_fields
(),
output
);
...
...
@@ -5517,11 +5533,6 @@ void Index::SerializeWithCachedSizes(
target
=
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
WriteInt32ToArray
(
2
,
this
->
nlist
(),
target
);
}
// int32 metric_type = 3;
if
(
this
->
metric_type
()
!=
0
)
{
target
=
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
WriteInt32ToArray
(
3
,
this
->
metric_type
(),
target
);
}
if
(
_internal_metadata_
.
have_unknown_fields
())
{
target
=
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormat
::
SerializeUnknownFieldsToArray
(
_internal_metadata_
.
unknown_fields
(),
target
);
...
...
@@ -5557,13 +5568,6 @@ size_t Index::ByteSizeLong() const {
this
->
nlist
());
}
// int32 metric_type = 3;
if
(
this
->
metric_type
()
!=
0
)
{
total_size
+=
1
+
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
Int32Size
(
this
->
metric_type
());
}
int
cached_size
=
::
PROTOBUF_NAMESPACE_ID
::
internal
::
ToCachedSize
(
total_size
);
SetCachedSize
(
cached_size
);
return
total_size
;
...
...
@@ -5597,9 +5601,6 @@ void Index::MergeFrom(const Index& from) {
if
(
from
.
nlist
()
!=
0
)
{
set_nlist
(
from
.
nlist
());
}
if
(
from
.
metric_type
()
!=
0
)
{
set_metric_type
(
from
.
metric_type
());
}
}
void
Index
::
CopyFrom
(
const
::
PROTOBUF_NAMESPACE_ID
::
Message
&
from
)
{
...
...
@@ -5625,7 +5626,6 @@ void Index::InternalSwap(Index* other) {
_internal_metadata_
.
Swap
(
&
other
->
_internal_metadata_
);
swap
(
index_type_
,
other
->
index_type_
);
swap
(
nlist_
,
other
->
nlist_
);
swap
(
metric_type_
,
other
->
metric_type_
);
}
::
PROTOBUF_NAMESPACE_ID
::
Metadata
Index
::
GetMetadata
()
const
{
...
...
cpp/src/grpc/gen-milvus/milvus.pb.h
浏览文件 @
6191bc79
...
...
@@ -397,6 +397,7 @@ class TableSchema :
kTableNameFieldNumber
=
1
,
kDimensionFieldNumber
=
2
,
kIndexFileSizeFieldNumber
=
3
,
kMetricTypeFieldNumber
=
4
,
};
// .milvus.grpc.TableName table_name = 1;
bool
has_table_name
()
const
;
...
...
@@ -416,6 +417,11 @@ class TableSchema :
::
PROTOBUF_NAMESPACE_ID
::
int64
index_file_size
()
const
;
void
set_index_file_size
(
::
PROTOBUF_NAMESPACE_ID
::
int64
value
);
// int32 metric_type = 4;
void
clear_metric_type
();
::
PROTOBUF_NAMESPACE_ID
::
int32
metric_type
()
const
;
void
set_metric_type
(
::
PROTOBUF_NAMESPACE_ID
::
int32
value
);
// @@protoc_insertion_point(class_scope:milvus.grpc.TableSchema)
private:
class
_Internal
;
...
...
@@ -424,6 +430,7 @@ class TableSchema :
::
milvus
::
grpc
::
TableName
*
table_name_
;
::
PROTOBUF_NAMESPACE_ID
::
int64
dimension_
;
::
PROTOBUF_NAMESPACE_ID
::
int64
index_file_size_
;
::
PROTOBUF_NAMESPACE_ID
::
int32
metric_type_
;
mutable
::
PROTOBUF_NAMESPACE_ID
::
internal
::
CachedSize
_cached_size_
;
friend
struct
::
TableStruct_milvus_2eproto
;
};
...
...
@@ -2325,7 +2332,6 @@ class Index :
enum
:
int
{
kIndexTypeFieldNumber
=
1
,
kNlistFieldNumber
=
2
,
kMetricTypeFieldNumber
=
3
,
};
// int32 index_type = 1;
void
clear_index_type
();
...
...
@@ -2337,11 +2343,6 @@ class Index :
::
PROTOBUF_NAMESPACE_ID
::
int32
nlist
()
const
;
void
set_nlist
(
::
PROTOBUF_NAMESPACE_ID
::
int32
value
);
// int32 metric_type = 3;
void
clear_metric_type
();
::
PROTOBUF_NAMESPACE_ID
::
int32
metric_type
()
const
;
void
set_metric_type
(
::
PROTOBUF_NAMESPACE_ID
::
int32
value
);
// @@protoc_insertion_point(class_scope:milvus.grpc.Index)
private:
class
_Internal
;
...
...
@@ -2349,7 +2350,6 @@ class Index :
::
PROTOBUF_NAMESPACE_ID
::
internal
::
InternalMetadataWithArena
_internal_metadata_
;
::
PROTOBUF_NAMESPACE_ID
::
int32
index_type_
;
::
PROTOBUF_NAMESPACE_ID
::
int32
nlist_
;
::
PROTOBUF_NAMESPACE_ID
::
int32
metric_type_
;
mutable
::
PROTOBUF_NAMESPACE_ID
::
internal
::
CachedSize
_cached_size_
;
friend
struct
::
TableStruct_milvus_2eproto
;
};
...
...
@@ -2834,6 +2834,20 @@ inline void TableSchema::set_index_file_size(::PROTOBUF_NAMESPACE_ID::int64 valu
// @@protoc_insertion_point(field_set:milvus.grpc.TableSchema.index_file_size)
}
// int32 metric_type = 4;
inline
void
TableSchema
::
clear_metric_type
()
{
metric_type_
=
0
;
}
inline
::
PROTOBUF_NAMESPACE_ID
::
int32
TableSchema
::
metric_type
()
const
{
// @@protoc_insertion_point(field_get:milvus.grpc.TableSchema.metric_type)
return
metric_type_
;
}
inline
void
TableSchema
::
set_metric_type
(
::
PROTOBUF_NAMESPACE_ID
::
int32
value
)
{
metric_type_
=
value
;
// @@protoc_insertion_point(field_set:milvus.grpc.TableSchema.metric_type)
}
// -------------------------------------------------------------------
// Range
...
...
@@ -3855,20 +3869,6 @@ inline void Index::set_nlist(::PROTOBUF_NAMESPACE_ID::int32 value) {
// @@protoc_insertion_point(field_set:milvus.grpc.Index.nlist)
}
// int32 metric_type = 3;
inline
void
Index
::
clear_metric_type
()
{
metric_type_
=
0
;
}
inline
::
PROTOBUF_NAMESPACE_ID
::
int32
Index
::
metric_type
()
const
{
// @@protoc_insertion_point(field_get:milvus.grpc.Index.metric_type)
return
metric_type_
;
}
inline
void
Index
::
set_metric_type
(
::
PROTOBUF_NAMESPACE_ID
::
int32
value
)
{
metric_type_
=
value
;
// @@protoc_insertion_point(field_set:milvus.grpc.Index.metric_type)
}
// -------------------------------------------------------------------
// IndexParam
...
...
cpp/src/grpc/milvus.proto
浏览文件 @
6191bc79
...
...
@@ -19,6 +19,7 @@ message TableSchema {
TableName
table_name
=
1
;
int64
dimension
=
2
;
int64
index_file_size
=
3
;
int32
metric_type
=
4
;
}
/**
...
...
@@ -127,7 +128,6 @@ message Command {
message
Index
{
int32
index_type
=
1
;
int32
nlist
=
2
;
int32
metric_type
=
3
;
}
/**
...
...
cpp/src/sdk/examples/grpcsimple/src/ClientTest.cpp
浏览文件 @
6191bc79
...
...
@@ -96,6 +96,7 @@ TableSchema BuildTableSchema() {
tb_schema
.
table_name
=
TABLE_NAME
;
tb_schema
.
dimension
=
TABLE_DIMENSION
;
tb_schema
.
index_file_size
=
TABLE_INDEX_FILE_SIZE
;
tb_schema
.
metric_type
=
MetricType
::
L2
;
return
tb_schema
;
}
...
...
@@ -291,7 +292,6 @@ ClientTest::Test(const std::string& address, const std::string& port) {
index
.
table_name
=
TABLE_NAME
;
index
.
index_type
=
IndexType
::
gpu_ivfflat
;
index
.
nlist
=
16384
;
index
.
metric_type
=
1
;
Status
stat
=
conn
->
CreateIndex
(
index
);
std
::
cout
<<
"CreateIndex function call status: "
<<
stat
.
ToString
()
<<
std
::
endl
;
...
...
cpp/src/sdk/grpc/ClientProxy.cpp
浏览文件 @
6191bc79
...
...
@@ -84,6 +84,7 @@ ClientProxy::CreateTable(const TableSchema ¶m) {
schema
.
mutable_table_name
()
->
set_table_name
(
param
.
table_name
);
schema
.
set_dimension
(
param
.
dimension
);
schema
.
set_index_file_size
(
param
.
index_file_size
);
schema
.
set_metric_type
((
int32_t
)
param
.
metric_type
);
return
client_ptr_
->
CreateTable
(
schema
);
}
catch
(
std
::
exception
&
ex
)
{
...
...
@@ -116,11 +117,9 @@ ClientProxy::CreateIndex(const IndexParam &index_param) {
try
{
//TODO:add index params
::
milvus
::
grpc
::
IndexParam
grpc_index_param
;
grpc_index_param
.
mutable_table_name
()
->
set_table_name
(
index_param
.
table_name
);
grpc_index_param
.
mutable_table_name
()
->
set_table_name
(
index_param
.
table_name
);
grpc_index_param
.
mutable_index
()
->
set_index_type
((
int32_t
)
index_param
.
index_type
);
grpc_index_param
.
mutable_index
()
->
set_nlist
(
index_param
.
nlist
);
grpc_index_param
.
mutable_index
()
->
set_metric_type
(
index_param
.
metric_type
);
return
client_ptr_
->
CreateIndex
(
grpc_index_param
);
}
catch
(
std
::
exception
&
ex
)
{
...
...
@@ -273,6 +272,7 @@ ClientProxy::DescribeTable(const std::string &table_name, TableSchema &table_sch
table_schema
.
table_name
=
grpc_schema
.
table_name
().
table_name
();
table_schema
.
dimension
=
grpc_schema
.
dimension
();
table_schema
.
index_file_size
=
grpc_schema
.
index_file_size
();
table_schema
.
metric_type
=
(
MetricType
)
grpc_schema
.
metric_type
();
return
status
;
}
catch
(
std
::
exception
&
ex
)
{
...
...
@@ -378,7 +378,6 @@ ClientProxy::DescribeIndex(const std::string &table_name, IndexParam &index_para
Status
status
=
client_ptr_
->
DescribeIndex
(
grpc_table_name
,
grpc_index_param
);
index_param
.
index_type
=
(
IndexType
)(
grpc_index_param
.
mutable_index
()
->
index_type
());
index_param
.
nlist
=
grpc_index_param
.
mutable_index
()
->
nlist
();
index_param
.
metric_type
=
grpc_index_param
.
mutable_index
()
->
metric_type
();
return
status
;
...
...
cpp/src/sdk/include/MilvusApi.h
浏览文件 @
6191bc79
...
...
@@ -22,6 +22,11 @@ enum class IndexType {
mix_nsg
,
};
enum
class
MetricType
{
L2
=
1
,
IP
=
2
,
};
/**
* @brief Connect API parameter
*/
...
...
@@ -37,6 +42,7 @@ struct TableSchema {
std
::
string
table_name
;
///< Table name
int64_t
dimension
=
0
;
///< Vector dimension, must be a positive value
int64_t
index_file_size
=
0
;
///< Index file size, must be a positive value
MetricType
metric_type
=
MetricType
::
L2
;
///< Index metric type
};
/**
...
...
@@ -77,7 +83,6 @@ struct IndexParam {
std
::
string
table_name
;
IndexType
index_type
;
int32_t
nlist
;
int32_t
metric_type
;
};
/**
...
...
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
浏览文件 @
6191bc79
...
...
@@ -144,11 +144,17 @@ CreateTableTask::OnExecute() {
return
SetError
(
res
,
"Invalid index file size: "
+
std
::
to_string
(
schema_
->
index_file_size
()));
}
res
=
ValidationUtil
::
ValidateTableIndexMetricType
(
schema_
->
metric_type
());
if
(
res
!=
SERVER_SUCCESS
)
{
return
SetError
(
res
,
"Invalid index metric type: "
+
std
::
to_string
(
schema_
->
metric_type
()));
}
//step 2: construct table schema
engine
::
meta
::
TableSchema
table_info
;
table_info
.
table_id_
=
schema_
->
table_name
().
table_name
();
table_info
.
dimension_
=
(
uint16_t
)
schema_
->
dimension
();
table_info
.
index_file_size_
=
schema_
->
index_file_size
();
table_info
.
metric_type_
=
schema_
->
metric_type
();
//step 3: create table
engine
::
Status
stat
=
DBWrapper
::
DB
()
->
CreateTable
(
table_info
);
...
...
@@ -261,16 +267,10 @@ CreateIndexTask::OnExecute() {
return
SetError
(
res
,
"Invalid index nlist: "
+
std
::
to_string
(
grpc_index
.
nlist
()));
}
res
=
ValidationUtil
::
ValidateTableIndexMetricType
(
grpc_index
.
metric_type
());
if
(
res
!=
SERVER_SUCCESS
)
{
return
SetError
(
res
,
"Invalid index metric type: "
+
std
::
to_string
(
grpc_index
.
metric_type
()));
}
//step 2: check table existence
engine
::
TableIndex
index
;
index
.
engine_type_
=
grpc_index
.
index_type
();
index
.
nlist_
=
grpc_index
.
nlist
();
index
.
metric_type_
=
grpc_index
.
metric_type
();
stat
=
DBWrapper
::
DB
()
->
CreateIndex
(
table_name_
,
index
);
if
(
!
stat
.
ok
())
{
return
SetError
(
SERVER_BUILD_INDEX_ERROR
,
stat
.
ToString
());
...
...
@@ -927,7 +927,6 @@ DescribeIndexTask::OnExecute() {
index_param_
->
mutable_table_name
()
->
set_table_name
(
table_name_
);
index_param_
->
mutable_index
()
->
set_index_type
(
index
.
engine_type_
);
index_param_
->
mutable_index
()
->
set_nlist
(
index
.
nlist_
);
index_param_
->
mutable_index
()
->
set_metric_type
(
index
.
metric_type_
);
rc
.
ElapseFromBegin
(
"totally cost"
);
}
catch
(
std
::
exception
&
ex
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录