Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
28e42d0e
M
milvus
项目概览
milvus
/
milvus
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
28e42d0e
编写于
4月 15, 2019
作者:
X
Xu Peng
提交者:
xj.lin
4月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(db): fix id generator errors
Former-commit-id: 1068933b6c74775bfc1ee8641c41d095babaea0c
上级
3863f2d3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
22 deletion
+21
-22
cpp/src/db/id_generators.cpp
cpp/src/db/id_generators.cpp
+15
-10
cpp/src/db/id_generators.h
cpp/src/db/id_generators.h
+2
-5
cpp/src/db/types.h
cpp/src/db/types.h
+4
-7
未找到文件。
cpp/src/db/id_generators.cpp
浏览文件 @
28e42d0e
#include <chrono>
#include <assert.h>
#in
lc
ude "id_generators.h"
#in
cl
ude "id_generators.h"
using
std
::
chrono
;
namespace
vecengine
{
namespace
zilliz
{
namespace
vecwise
{
namespace
engine
{
IDGenerator
::~
IDGenerator
()
{}
IDNumber
SimpleIDGenerator
::
getNextIDNumber
()
{
auto
now
=
chrono
::
system_clock
::
now
();
auto
micros
=
duration_cast
<
chrono
::
microseconds
>
(
now
.
time_since_epoch
()).
count
();
return
micros
*
MAX_IDS_PER_MICRO
auto
now
=
std
::
chrono
::
system_clock
::
now
();
auto
micros
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
.
time_since_epoch
()).
count
();
return
micros
*
MAX_IDS_PER_MICRO
;
}
IDNumbers
&&
SimpleIDGenerator
::
getNextIDNumbers
(
size_t
n
)
{
assert
(
n
<
MAX_IDS_PER_MICRO
);
auto
now
=
chrono
::
system_clock
::
now
();
auto
micros
=
duration_cast
<
chrono
::
microseconds
>
(
now
.
time_since_epoch
()).
count
();
auto
now
=
std
::
chrono
::
system_clock
::
now
();
auto
micros
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
.
time_since_epoch
()).
count
();
micros
*=
MAX_IDS_PER_MICRO
;
IDNumbers
ids
=
IDNumbers
(
n
);
for
(
int
pos
=
0
;
pos
<
n
;
++
pos
)
{
ids
[
pos
]
=
micros
+
pos
;
}
return
ids
;
return
std
::
move
(
ids
)
;
}
}
// namespace vecengine
}
// namespace engine
}
// namespace vecwise
}
// namespace zilliz
cpp/src/db/id_generators.h
浏览文件 @
28e42d0e
#ifndef UTILS_ID_GENERATORS_H_
#define UTILS_ID_GENERATORS_H_
#pragma once
#include <vector>
#include "types.h"
...
...
@@ -24,7 +23,7 @@ public:
virtual
IDNumbers
&&
getNextIDNumbers
(
size_t
n_
)
override
;
private:
const
MAX_IDS_PER_MICRO
=
1000
;
const
size_t
MAX_IDS_PER_MICRO
=
1000
;
};
// SimpleIDGenerator
...
...
@@ -32,5 +31,3 @@ private:
}
// namespace engine
}
// namespace vecwise
}
// namespace zilliz
#endif // UTILS_ID_GENERATORS_H_
cpp/src/db/types.h
浏览文件 @
28e42d0e
#ifndef VECENGINE_TYPES_H_
#define VECENGINE_TYPES_H_
#pragma once
#include <vector>
...
...
@@ -7,13 +6,11 @@ namespace zilliz {
namespace
vecwise
{
namespace
engine
{
#define
uint64_t IDNumber;
#define
IDNumber* IDNumberPtr;
#define
std::vector<IDNumber> IDNumbers;
typedef
uint64_t
IDNumber
;
typedef
IDNumber
*
IDNumberPtr
;
typedef
std
::
vector
<
IDNumber
>
IDNumbers
;
}
// namespace engine
}
// namespace vecwise
}
// namespace zilliz
#endif // VECENGINE_TYPES_H_
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录