Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
92261e38
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
261
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
92261e38
编写于
1月 18, 2021
作者:
F
FluorineDog
提交者:
yefu.chen
1月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add system property and optimize easy assert
Signed-off-by:
N
FluorineDog
<
guilin.gou@zilliz.com
>
上级
48821690
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
127 addition
and
8 deletion
+127
-8
internal/core/src/common/CMakeLists.txt
internal/core/src/common/CMakeLists.txt
+1
-0
internal/core/src/common/LoadInfo.h
internal/core/src/common/LoadInfo.h
+2
-0
internal/core/src/common/Schema.cpp
internal/core/src/common/Schema.cpp
+10
-7
internal/core/src/common/SystemProperty.cpp
internal/core/src/common/SystemProperty.cpp
+66
-0
internal/core/src/common/SystemProperty.h
internal/core/src/common/SystemProperty.h
+39
-0
internal/core/src/utils/EasyAssert.h
internal/core/src/utils/EasyAssert.h
+9
-1
未找到文件。
internal/core/src/common/CMakeLists.txt
浏览文件 @
92261e38
set
(
COMMON_SRC
Schema.cpp
Types.cpp
SystemProperty.cpp
)
add_library
(
milvus_common
...
...
internal/core/src/common/LoadInfo.h
浏览文件 @
92261e38
...
...
@@ -22,6 +22,8 @@ struct LoadIndexInfo {
milvus
::
knowhere
::
VecIndexPtr
index
;
};
// NOTE: field_id can be system field
// NOTE: Refer to common/SystemProperty.cpp for details
struct
LoadFieldDataInfo
{
int64_t
field_id
;
void
*
blob
;
...
...
internal/core/src/common/Schema.cpp
浏览文件 @
92261e38
...
...
@@ -12,6 +12,7 @@
#include "common/Schema.h"
#include <google/protobuf/text_format.h>
#include <boost/lexical_cast.hpp>
#include "common/SystemProperty.h"
namespace
milvus
{
...
...
@@ -32,15 +33,17 @@ Schema::ParseFrom(const milvus::proto::schema::CollectionSchema& schema_proto) {
schema
->
set_auto_id
(
schema_proto
.
autoid
());
// NOTE: only two system
std
::
set
<
std
::
string
>
system_field_names
=
{
"RowID"
,
"Timestamp"
};
for
(
const
milvus
::
proto
::
schema
::
FieldSchema
&
child
:
schema_proto
.
fields
())
{
auto
field_offset
=
FieldOffset
(
schema
->
size
());
auto
field_id
=
child
.
fieldid
();
auto
name
=
child
.
name
();
if
(
field_id
<
100
)
{
auto
field_id
=
FieldId
(
child
.
fieldid
());
auto
name
=
FieldName
(
child
.
name
());
if
(
field_id
.
get
()
<
100
)
{
// system field id
AssertInfo
(
system_field_names
.
count
(
name
),
"id of non system field should be >= 100"
);
auto
is_system
=
SystemProperty
::
Instance
().
SystemFieldVerify
(
name
,
field_id
);
AssertInfo
(
is_system
,
"invalid system type: name("
+
name
.
get
()
+
"), id("
+
std
::
to_string
(
field_id
.
get
())
+
")"
);
continue
;
}
...
...
@@ -64,9 +67,9 @@ Schema::ParseFrom(const milvus::proto::schema::CollectionSchema& schema_proto) {
auto
dim
=
boost
::
lexical_cast
<
int64_t
>
(
type_map
.
at
(
"dim"
));
AssertInfo
(
index_map
.
count
(
"metric_type"
),
"index not found"
);
auto
metric_type
=
GetMetricType
(
index_map
.
at
(
"metric_type"
));
schema
->
AddField
(
FieldName
(
name
),
FieldId
(
field_id
)
,
data_type
,
dim
,
metric_type
);
schema
->
AddField
(
name
,
field_id
,
data_type
,
dim
,
metric_type
);
}
else
{
schema
->
AddField
(
FieldName
(
name
),
FieldId
(
field_id
)
,
data_type
);
schema
->
AddField
(
name
,
field_id
,
data_type
);
}
}
return
schema
;
...
...
internal/core/src/common/SystemProperty.cpp
0 → 100644
浏览文件 @
92261e38
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License
#include "common/SystemProperty.h"
#include "utils/EasyAssert.h"
namespace
milvus
{
class
SystemPropertyImpl
:
public
SystemProperty
{
public:
[[
nodiscard
]]
bool
SystemFieldVerify
(
const
FieldName
&
field_name
,
FieldId
field_id
)
const
override
{
if
(
!
name_to_types_
.
count
(
field_name
))
{
return
false
;
}
if
(
!
id_to_types_
.
count
(
field_id
))
{
return
false
;
}
auto
left_id
=
name_to_types_
.
at
(
field_name
);
auto
right_id
=
id_to_types_
.
at
(
field_id
);
return
left_id
==
right_id
;
}
SystemFieldType
GetSystemFieldType
(
FieldName
field_name
)
const
override
{
Assert
(
name_to_types_
.
count
(
field_name
));
return
name_to_types_
.
at
(
field_name
);
}
SystemFieldType
GetSystemFieldType
(
FieldId
field_id
)
const
override
{
Assert
(
id_to_types_
.
count
(
field_id
));
return
id_to_types_
.
at
(
field_id
);
}
friend
const
SystemProperty
&
SystemProperty
::
Instance
();
private:
std
::
map
<
FieldName
,
SystemFieldType
>
name_to_types_
;
std
::
map
<
FieldId
,
SystemFieldType
>
id_to_types_
;
};
const
SystemProperty
&
SystemProperty
::
Instance
()
{
static
auto
impl
=
[]
{
SystemPropertyImpl
impl
;
using
Type
=
SystemFieldType
;
impl
.
name_to_types_
.
emplace
(
FieldName
(
"RowID"
),
Type
::
RowId
);
impl
.
id_to_types_
.
emplace
(
FieldId
(
0
),
Type
::
RowId
);
impl
.
name_to_types_
.
emplace
(
FieldName
(
"Timestamp"
),
Type
::
Timestamp
);
impl
.
id_to_types_
.
emplace
(
FieldId
(
1
),
Type
::
Timestamp
);
return
impl
;
}();
return
impl
;
}
};
// namespace milvus
internal/core/src/common/SystemProperty.h
0 → 100644
浏览文件 @
92261e38
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License
#pragma once
#include "common/Types.h"
namespace
milvus
{
enum
class
SystemFieldType
{
Invalid
=
0
,
RowId
=
1
,
Timestamp
=
2
,
};
class
SystemProperty
{
public:
static
const
SystemProperty
&
Instance
();
public:
virtual
bool
SystemFieldVerify
(
const
FieldName
&
field_name
,
FieldId
field_id
)
const
=
0
;
virtual
SystemFieldType
GetSystemFieldType
(
FieldId
field_id
)
const
=
0
;
virtual
SystemFieldType
GetSystemFieldType
(
FieldName
field_name
)
const
=
0
;
};
}
// namespace milvus
internal/core/src/utils/EasyAssert.h
浏览文件 @
92261e38
...
...
@@ -32,7 +32,15 @@ ThrowWithTrace(const std::exception& exception);
}
// namespace milvus::impl
#define AssertInfo(expr, info) milvus::impl::EasyAssertInfo(bool(expr), #expr, __FILE__, __LINE__, (info))
#define AssertInfo(expr, info) \
do { \
auto _expr_res = bool(expr); \
/* call func only when needed */
\
if (!_expr_res) { \
milvus::impl::EasyAssertInfo(_expr_res, #expr, __FILE__, __LINE__, (info)); \
} \
} while (0)
#define Assert(expr) AssertInfo((expr), "")
#define PanicInfo(info) \
do { \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录