Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
3b107731
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,发现更多精彩内容 >>
提交
3b107731
编写于
10月 10, 2019
作者:
W
wxyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MS-626 Refactor DataObj to support cache any type data
Former-commit-id: 7795e47deb81657c484d4d90acb49adf9ed4501c
上级
6b025329
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
94 addition
and
65 deletion
+94
-65
cpp/CHANGELOG.md
cpp/CHANGELOG.md
+1
-0
cpp/src/cache/Cache.inl
cpp/src/cache/Cache.inl
+6
-6
cpp/src/cache/CpuCacheMgr.cpp
cpp/src/cache/CpuCacheMgr.cpp
+2
-6
cpp/src/cache/CpuCacheMgr.h
cpp/src/cache/CpuCacheMgr.h
+1
-1
cpp/src/cache/DataObj.h
cpp/src/cache/DataObj.h
+2
-32
cpp/src/cache/GpuCacheMgr.cpp
cpp/src/cache/GpuCacheMgr.cpp
+2
-6
cpp/src/cache/GpuCacheMgr.h
cpp/src/cache/GpuCacheMgr.h
+1
-1
cpp/src/db/engine/ExecutionEngineImpl.cpp
cpp/src/db/engine/ExecutionEngineImpl.cpp
+59
-5
cpp/src/db/engine/ExecutionEngineImpl.h
cpp/src/db/engine/ExecutionEngineImpl.h
+3
-0
cpp/src/wrapper/VecIndex.cpp
cpp/src/wrapper/VecIndex.cpp
+5
-0
cpp/src/wrapper/VecIndex.h
cpp/src/wrapper/VecIndex.h
+5
-1
cpp/unittest/scheduler/test_scheduler.cpp
cpp/unittest/scheduler/test_scheduler.cpp
+1
-1
cpp/unittest/server/test_cache.cpp
cpp/unittest/server/test_cache.cpp
+6
-6
未找到文件。
cpp/CHANGELOG.md
浏览文件 @
3b107731
...
@@ -28,6 +28,7 @@ Please mark all change in change log and use the ticket from JIRA.
...
@@ -28,6 +28,7 @@ Please mark all change in change log and use the ticket from JIRA.
-
MS-609 - Update task construct function
-
MS-609 - Update task construct function
-
MS-611 - Add resources validity check in ResourceMgr
-
MS-611 - Add resources validity check in ResourceMgr
-
MS-619 - Add optimizer class in scheduler
-
MS-619 - Add optimizer class in scheduler
-
MS-626 - Refactor DataObj to support cache any type data
## New Feature
## New Feature
...
...
cpp/src/cache/Cache.inl
浏览文件 @
3b107731
...
@@ -86,11 +86,11 @@ Cache<ItemObj>::insert(const std::string &key, const ItemObj &item) {
...
@@ -86,11 +86,11 @@ Cache<ItemObj>::insert(const std::string &key, const ItemObj &item) {
//if key already exist, subtract old item size
//if key already exist, subtract old item size
if (lru_.exists(key)) {
if (lru_.exists(key)) {
const ItemObj &old_item = lru_.get(key);
const ItemObj &old_item = lru_.get(key);
usage_ -= old_item->
s
ize();
usage_ -= old_item->
S
ize();
}
}
//plus new item size
//plus new item size
usage_ += item->
s
ize();
usage_ += item->
S
ize();
}
}
//if usage exceed capacity, free some items
//if usage exceed capacity, free some items
...
@@ -106,7 +106,7 @@ Cache<ItemObj>::insert(const std::string &key, const ItemObj &item) {
...
@@ -106,7 +106,7 @@ Cache<ItemObj>::insert(const std::string &key, const ItemObj &item) {
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<std::mutex> lock(mutex_);
lru_.put(key, item);
lru_.put(key, item);
SERVER_LOG_DEBUG << "Insert " << key << " size:" << item->
s
ize()
SERVER_LOG_DEBUG << "Insert " << key << " size:" << item->
S
ize()
<< " bytes into cache, usage: " << usage_ << " bytes";
<< " bytes into cache, usage: " << usage_ << " bytes";
}
}
}
}
...
@@ -120,9 +120,9 @@ Cache<ItemObj>::erase(const std::string &key) {
...
@@ -120,9 +120,9 @@ Cache<ItemObj>::erase(const std::string &key) {
}
}
const ItemObj &old_item = lru_.get(key);
const ItemObj &old_item = lru_.get(key);
usage_ -= old_item->
s
ize();
usage_ -= old_item->
S
ize();
SERVER_LOG_DEBUG << "Erase " << key << " size: " << old_item->
s
ize();
SERVER_LOG_DEBUG << "Erase " << key << " size: " << old_item->
S
ize();
lru_.erase(key);
lru_.erase(key);
}
}
...
@@ -160,7 +160,7 @@ Cache<ItemObj>::free_memory() {
...
@@ -160,7 +160,7 @@ Cache<ItemObj>::free_memory() {
auto &obj_ptr = it->second;
auto &obj_ptr = it->second;
key_array.emplace(key);
key_array.emplace(key);
released_size += obj_ptr->
s
ize();
released_size += obj_ptr->
S
ize();
++it;
++it;
}
}
}
}
...
...
cpp/src/cache/CpuCacheMgr.cpp
浏览文件 @
3b107731
...
@@ -59,14 +59,10 @@ CpuCacheMgr::GetInstance() {
...
@@ -59,14 +59,10 @@ CpuCacheMgr::GetInstance() {
return
&
s_mgr
;
return
&
s_mgr
;
}
}
engine
::
VecIndex
Ptr
DataObj
Ptr
CpuCacheMgr
::
GetIndex
(
const
std
::
string
&
key
)
{
CpuCacheMgr
::
GetIndex
(
const
std
::
string
&
key
)
{
DataObjPtr
obj
=
GetItem
(
key
);
DataObjPtr
obj
=
GetItem
(
key
);
if
(
obj
!=
nullptr
)
{
return
obj
;
return
obj
->
data
();
}
return
nullptr
;
}
}
}
// namespace cache
}
// namespace cache
...
...
cpp/src/cache/CpuCacheMgr.h
浏览文件 @
3b107731
...
@@ -35,7 +35,7 @@ class CpuCacheMgr : public CacheMgr<DataObjPtr> {
...
@@ -35,7 +35,7 @@ class CpuCacheMgr : public CacheMgr<DataObjPtr> {
static
CpuCacheMgr
*
static
CpuCacheMgr
*
GetInstance
();
GetInstance
();
engine
::
VecIndex
Ptr
DataObj
Ptr
GetIndex
(
const
std
::
string
&
key
);
GetIndex
(
const
std
::
string
&
key
);
};
};
...
...
cpp/src/cache/DataObj.h
浏览文件 @
3b107731
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
#pragma once
#pragma once
#include "src/wrapper/VecIndex.h"
#include <memory>
#include <memory>
...
@@ -26,38 +25,9 @@ namespace cache {
...
@@ -26,38 +25,9 @@ namespace cache {
class
DataObj
{
class
DataObj
{
public:
public:
explicit
DataObj
(
const
engine
::
VecIndexPtr
&
index
)
:
index_
(
index
)
{
virtual
int64_t
}
Size
()
=
0
;
DataObj
(
const
engine
::
VecIndexPtr
&
index
,
int64_t
size
)
:
index_
(
index
),
size_
(
size
)
{
}
engine
::
VecIndexPtr
data
()
{
return
index_
;
}
const
engine
::
VecIndexPtr
&
data
()
const
{
return
index_
;
}
int64_t
size
()
const
{
if
(
index_
==
nullptr
)
{
return
0
;
}
if
(
size_
>
0
)
{
return
size_
;
}
return
index_
->
Count
()
*
index_
->
Dimension
()
*
sizeof
(
float
);
}
private:
engine
::
VecIndexPtr
index_
=
nullptr
;
int64_t
size_
=
0
;
};
};
using
DataObjPtr
=
std
::
shared_ptr
<
DataObj
>
;
using
DataObjPtr
=
std
::
shared_ptr
<
DataObj
>
;
...
...
cpp/src/cache/GpuCacheMgr.cpp
浏览文件 @
3b107731
...
@@ -71,14 +71,10 @@ GpuCacheMgr::GetInstance(uint64_t gpu_id) {
...
@@ -71,14 +71,10 @@ GpuCacheMgr::GetInstance(uint64_t gpu_id) {
}
}
}
}
engine
::
VecIndex
Ptr
DataObj
Ptr
GpuCacheMgr
::
GetIndex
(
const
std
::
string
&
key
)
{
GpuCacheMgr
::
GetIndex
(
const
std
::
string
&
key
)
{
DataObjPtr
obj
=
GetItem
(
key
);
DataObjPtr
obj
=
GetItem
(
key
);
if
(
obj
!=
nullptr
)
{
return
obj
;
return
obj
->
data
();
}
return
nullptr
;
}
}
}
// namespace cache
}
// namespace cache
...
...
cpp/src/cache/GpuCacheMgr.h
浏览文件 @
3b107731
...
@@ -35,7 +35,7 @@ class GpuCacheMgr : public CacheMgr<DataObjPtr> {
...
@@ -35,7 +35,7 @@ class GpuCacheMgr : public CacheMgr<DataObjPtr> {
static
GpuCacheMgr
*
static
GpuCacheMgr
*
GetInstance
(
uint64_t
gpu_id
);
GetInstance
(
uint64_t
gpu_id
);
engine
::
VecIndex
Ptr
DataObj
Ptr
GetIndex
(
const
std
::
string
&
key
);
GetIndex
(
const
std
::
string
&
key
);
private:
private:
...
...
cpp/src/db/engine/ExecutionEngineImpl.cpp
浏览文件 @
3b107731
...
@@ -91,6 +91,60 @@ ExecutionEngineImpl::CreatetVecIndex(EngineType type) {
...
@@ -91,6 +91,60 @@ ExecutionEngineImpl::CreatetVecIndex(EngineType type) {
return
index
;
return
index
;
}
}
void
ExecutionEngineImpl
::
HybridLoad
()
{
// if (index_type_ != EngineType::FAISS_IVFSQ8Hybrid) {
// return;
// }
//
// const std::string key = location_ + ".quantizer";
// std::vector<uint64_t> gpus;
//
// // cache hit
// {
// int64_t selected = -1;
// void* quantizer = nullptr;
// for (auto& gpu : gpus) {
// auto cache = cache::GpuCacheMgr::GetInstance(gpu);
// if (auto quan = cache->GetIndex(key)) {
// selected = gpu;
// quantizer = quan;
// }
// }
//
// if (selected != -1) {
// // set quantizer into index;
// return;
// }
// }
//
// // cache miss
// {
// std::vector<int64_t> all_free_mem;
// for (auto& gpu : gpus) {
// auto cache = cache::GpuCacheMgr::GetInstance(gpu);
// auto free_mem = cache->CacheCapacity() - cache->CacheUsage();
// all_free_mem.push_back(free_mem);
// }
//
// auto max_e = std::max_element(all_free_mem.begin(), all_free_mem.end());
// auto best = std::distance(all_free_mem.begin(), max_e);
//
// // load to best device;
// // cache quantizer
// }
//
// // if index_type == Hybrid
//
// // 1. quantizer in which gpu
//
// // 2.1 which gpu cache best
//
// // 2.2 load to that gpu cache
//
// // set quantizer into index
}
Status
Status
ExecutionEngineImpl
::
AddWithIds
(
int64_t
n
,
const
float
*
xdata
,
const
int64_t
*
xids
)
{
ExecutionEngineImpl
::
AddWithIds
(
int64_t
n
,
const
float
*
xdata
,
const
int64_t
*
xids
)
{
auto
status
=
index_
->
Add
(
n
,
xdata
,
xids
);
auto
status
=
index_
->
Add
(
n
,
xdata
,
xids
);
...
@@ -133,7 +187,7 @@ ExecutionEngineImpl::Serialize() {
...
@@ -133,7 +187,7 @@ ExecutionEngineImpl::Serialize() {
Status
Status
ExecutionEngineImpl
::
Load
(
bool
to_cache
)
{
ExecutionEngineImpl
::
Load
(
bool
to_cache
)
{
index_
=
cache
::
CpuCacheMgr
::
GetInstance
()
->
GetIndex
(
location_
);
index_
=
std
::
static_pointer_cast
<
VecIndex
>
(
cache
::
CpuCacheMgr
::
GetInstance
()
->
GetIndex
(
location_
)
);
bool
already_in_cache
=
(
index_
!=
nullptr
);
bool
already_in_cache
=
(
index_
!=
nullptr
);
if
(
!
already_in_cache
)
{
if
(
!
already_in_cache
)
{
try
{
try
{
...
@@ -161,7 +215,7 @@ ExecutionEngineImpl::Load(bool to_cache) {
...
@@ -161,7 +215,7 @@ ExecutionEngineImpl::Load(bool to_cache) {
Status
Status
ExecutionEngineImpl
::
CopyToGpu
(
uint64_t
device_id
)
{
ExecutionEngineImpl
::
CopyToGpu
(
uint64_t
device_id
)
{
auto
index
=
cache
::
GpuCacheMgr
::
GetInstance
(
device_id
)
->
GetIndex
(
location_
);
auto
index
=
std
::
static_pointer_cast
<
VecIndex
>
(
cache
::
GpuCacheMgr
::
GetInstance
(
device_id
)
->
GetIndex
(
location_
)
);
bool
already_in_cache
=
(
index
!=
nullptr
);
bool
already_in_cache
=
(
index
!=
nullptr
);
if
(
already_in_cache
)
{
if
(
already_in_cache
)
{
index_
=
index
;
index_
=
index
;
...
@@ -189,7 +243,7 @@ ExecutionEngineImpl::CopyToGpu(uint64_t device_id) {
...
@@ -189,7 +243,7 @@ ExecutionEngineImpl::CopyToGpu(uint64_t device_id) {
Status
Status
ExecutionEngineImpl
::
CopyToCpu
()
{
ExecutionEngineImpl
::
CopyToCpu
()
{
auto
index
=
cache
::
CpuCacheMgr
::
GetInstance
()
->
GetIndex
(
location_
);
auto
index
=
std
::
static_pointer_cast
<
VecIndex
>
(
cache
::
CpuCacheMgr
::
GetInstance
()
->
GetIndex
(
location_
)
);
bool
already_in_cache
=
(
index
!=
nullptr
);
bool
already_in_cache
=
(
index
!=
nullptr
);
if
(
already_in_cache
)
{
if
(
already_in_cache
)
{
index_
=
index
;
index_
=
index
;
...
@@ -322,7 +376,7 @@ ExecutionEngineImpl::Search(int64_t n, const float* data, int64_t k, int64_t npr
...
@@ -322,7 +376,7 @@ ExecutionEngineImpl::Search(int64_t n, const float* data, int64_t k, int64_t npr
Status
Status
ExecutionEngineImpl
::
Cache
()
{
ExecutionEngineImpl
::
Cache
()
{
cache
::
DataObjPtr
obj
=
std
::
make_shared
<
cache
::
DataObj
>
(
index_
,
PhysicalSize
()
);
cache
::
DataObjPtr
obj
=
std
::
static_pointer_cast
<
cache
::
DataObj
>
(
index_
);
milvus
::
cache
::
CpuCacheMgr
::
GetInstance
()
->
InsertItem
(
location_
,
obj
);
milvus
::
cache
::
CpuCacheMgr
::
GetInstance
()
->
InsertItem
(
location_
,
obj
);
return
Status
::
OK
();
return
Status
::
OK
();
...
@@ -330,7 +384,7 @@ ExecutionEngineImpl::Cache() {
...
@@ -330,7 +384,7 @@ ExecutionEngineImpl::Cache() {
Status
Status
ExecutionEngineImpl
::
GpuCache
(
uint64_t
gpu_id
)
{
ExecutionEngineImpl
::
GpuCache
(
uint64_t
gpu_id
)
{
cache
::
DataObjPtr
obj
=
std
::
make_shared
<
cache
::
DataObj
>
(
index_
,
PhysicalSize
()
);
cache
::
DataObjPtr
obj
=
std
::
static_pointer_cast
<
cache
::
DataObj
>
(
index_
);
milvus
::
cache
::
GpuCacheMgr
::
GetInstance
(
gpu_id
)
->
InsertItem
(
location_
,
obj
);
milvus
::
cache
::
GpuCacheMgr
::
GetInstance
(
gpu_id
)
->
InsertItem
(
location_
,
obj
);
return
Status
::
OK
();
return
Status
::
OK
();
...
...
cpp/src/db/engine/ExecutionEngineImpl.h
浏览文件 @
3b107731
...
@@ -104,6 +104,9 @@ class ExecutionEngineImpl : public ExecutionEngine {
...
@@ -104,6 +104,9 @@ class ExecutionEngineImpl : public ExecutionEngine {
VecIndexPtr
VecIndexPtr
Load
(
const
std
::
string
&
location
);
Load
(
const
std
::
string
&
location
);
void
HybridLoad
();
protected:
protected:
VecIndexPtr
index_
=
nullptr
;
VecIndexPtr
index_
=
nullptr
;
EngineType
index_type_
;
EngineType
index_type_
;
...
...
cpp/src/wrapper/VecIndex.cpp
浏览文件 @
3b107731
...
@@ -34,6 +34,11 @@
...
@@ -34,6 +34,11 @@
namespace
milvus
{
namespace
milvus
{
namespace
engine
{
namespace
engine
{
int64_t
VecIndex
::
Size
()
{
return
Count
()
*
Dimension
()
*
sizeof
(
float
);
}
struct
FileIOReader
{
struct
FileIOReader
{
std
::
fstream
fs
;
std
::
fstream
fs
;
std
::
string
name
;
std
::
string
name
;
...
...
cpp/src/wrapper/VecIndex.h
浏览文件 @
3b107731
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include <memory>
#include <memory>
#include <string>
#include <string>
#include "cache/DataObj.h"
#include "knowhere/common/BinarySet.h"
#include "knowhere/common/BinarySet.h"
#include "knowhere/common/Config.h"
#include "knowhere/common/Config.h"
#include "utils/Status.h"
#include "utils/Status.h"
...
@@ -48,7 +49,7 @@ class VecIndex;
...
@@ -48,7 +49,7 @@ class VecIndex;
using
VecIndexPtr
=
std
::
shared_ptr
<
VecIndex
>
;
using
VecIndexPtr
=
std
::
shared_ptr
<
VecIndex
>
;
class
VecIndex
{
class
VecIndex
:
public
cache
::
DataObj
{
public:
public:
virtual
Status
virtual
Status
BuildAll
(
const
int64_t
&
nb
,
const
float
*
xb
,
const
int64_t
*
ids
,
const
Config
&
cfg
,
const
int64_t
&
nt
=
0
,
BuildAll
(
const
int64_t
&
nb
,
const
float
*
xb
,
const
int64_t
*
ids
,
const
Config
&
cfg
,
const
int64_t
&
nt
=
0
,
...
@@ -81,6 +82,9 @@ class VecIndex {
...
@@ -81,6 +82,9 @@ class VecIndex {
virtual
int64_t
virtual
int64_t
Count
()
=
0
;
Count
()
=
0
;
int64_t
Size
()
override
;
virtual
knowhere
::
BinarySet
virtual
knowhere
::
BinarySet
Serialize
()
=
0
;
Serialize
()
=
0
;
...
...
cpp/unittest/scheduler/test_scheduler.cpp
浏览文件 @
3b107731
...
@@ -141,7 +141,7 @@ insert_dummy_index_into_gpu_cache(uint64_t device_id) {
...
@@ -141,7 +141,7 @@ insert_dummy_index_into_gpu_cache(uint64_t device_id) {
mock_index
->
ntotal_
=
1000
;
mock_index
->
ntotal_
=
1000
;
engine
::
VecIndexPtr
index
(
mock_index
);
engine
::
VecIndexPtr
index
(
mock_index
);
cache
::
DataObjPtr
obj
=
std
::
make_shared
<
cache
::
DataObj
>
(
index
);
cache
::
DataObjPtr
obj
=
std
::
static_pointer_cast
<
cache
::
DataObj
>
(
index
);
cache
::
GpuCacheMgr
::
GetInstance
(
device_id
)
->
InsertItem
(
"location"
,
obj
);
cache
::
GpuCacheMgr
::
GetInstance
(
device_id
)
->
InsertItem
(
"location"
,
obj
);
}
}
...
...
cpp/unittest/server/test_cache.cpp
浏览文件 @
3b107731
...
@@ -145,7 +145,7 @@ TEST(CacheTest, CPU_CACHE_TEST) {
...
@@ -145,7 +145,7 @@ TEST(CacheTest, CPU_CACHE_TEST) {
for
(
uint64_t
i
=
0
;
i
<
item_count
;
i
++
)
{
for
(
uint64_t
i
=
0
;
i
<
item_count
;
i
++
)
{
//each vector is 1k byte, total size less than 1G
//each vector is 1k byte, total size less than 1G
ms
::
engine
::
VecIndexPtr
mock_index
=
std
::
make_shared
<
MockVecIndex
>
(
256
,
1000000
);
ms
::
engine
::
VecIndexPtr
mock_index
=
std
::
make_shared
<
MockVecIndex
>
(
256
,
1000000
);
ms
::
cache
::
DataObjPtr
data_obj
=
std
::
make_shared
<
ms
::
cache
::
DataObj
>
(
mock_index
);
ms
::
cache
::
DataObjPtr
data_obj
=
std
::
static_pointer_cast
<
ms
::
cache
::
DataObj
>
(
mock_index
);
cpu_mgr
->
InsertItem
(
"index_"
+
std
::
to_string
(
i
),
data_obj
);
cpu_mgr
->
InsertItem
(
"index_"
+
std
::
to_string
(
i
),
data_obj
);
}
}
ASSERT_LT
(
cpu_mgr
->
ItemCount
(),
g_num
);
ASSERT_LT
(
cpu_mgr
->
ItemCount
(),
g_num
);
...
@@ -169,7 +169,7 @@ TEST(CacheTest, CPU_CACHE_TEST) {
...
@@ -169,7 +169,7 @@ TEST(CacheTest, CPU_CACHE_TEST) {
//each vector is 1k byte, total size less than 6G
//each vector is 1k byte, total size less than 6G
ms
::
engine
::
VecIndexPtr
mock_index
=
std
::
make_shared
<
MockVecIndex
>
(
256
,
6000000
);
ms
::
engine
::
VecIndexPtr
mock_index
=
std
::
make_shared
<
MockVecIndex
>
(
256
,
6000000
);
ms
::
cache
::
DataObjPtr
data_obj
=
std
::
make_shared
<
ms
::
cache
::
DataObj
>
(
mock_index
);
ms
::
cache
::
DataObjPtr
data_obj
=
std
::
static_pointer_cast
<
ms
::
cache
::
DataObj
>
(
mock_index
);
cpu_mgr
->
InsertItem
(
"index_6g"
,
data_obj
);
cpu_mgr
->
InsertItem
(
"index_6g"
,
data_obj
);
ASSERT_TRUE
(
cpu_mgr
->
ItemExists
(
"index_6g"
));
ASSERT_TRUE
(
cpu_mgr
->
ItemExists
(
"index_6g"
));
}
}
...
@@ -183,7 +183,7 @@ TEST(CacheTest, GPU_CACHE_TEST) {
...
@@ -183,7 +183,7 @@ TEST(CacheTest, GPU_CACHE_TEST) {
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
//each vector is 1k byte
//each vector is 1k byte
ms
::
engine
::
VecIndexPtr
mock_index
=
std
::
make_shared
<
MockVecIndex
>
(
256
,
1000
);
ms
::
engine
::
VecIndexPtr
mock_index
=
std
::
make_shared
<
MockVecIndex
>
(
256
,
1000
);
ms
::
cache
::
DataObjPtr
data_obj
=
std
::
make_shared
<
ms
::
cache
::
DataObj
>
(
mock_index
);
ms
::
cache
::
DataObjPtr
data_obj
=
std
::
static_pointer_cast
<
ms
::
cache
::
DataObj
>
(
mock_index
);
gpu_mgr
->
InsertItem
(
"index_"
+
std
::
to_string
(
i
),
data_obj
);
gpu_mgr
->
InsertItem
(
"index_"
+
std
::
to_string
(
i
),
data_obj
);
}
}
...
@@ -196,8 +196,8 @@ TEST(CacheTest, GPU_CACHE_TEST) {
...
@@ -196,8 +196,8 @@ TEST(CacheTest, GPU_CACHE_TEST) {
// TODO(myh): use gpu index to mock
// TODO(myh): use gpu index to mock
//each vector is 1k byte, total size less than 2G
//each vector is 1k byte, total size less than 2G
ms
::
engine
::
VecIndexPtr
mock_index
=
std
::
make_shared
<
MockVecIndex
>
(
256
,
2000000
);
ms
::
engine
::
VecIndexPtr
mock_index
=
std
::
make_shared
<
MockVecIndex
>
(
256
,
2000000
);
ms
::
cache
::
DataObjPtr
data_obj
=
std
::
make_shared
<
ms
::
cache
::
DataObj
>
(
mock_index
);
ms
::
cache
::
DataObjPtr
data_obj
=
std
::
static_pointer_cast
<
ms
::
cache
::
DataObj
>
(
mock_index
);
std
::
cout
<<
data_obj
->
s
ize
()
<<
std
::
endl
;
std
::
cout
<<
data_obj
->
S
ize
()
<<
std
::
endl
;
gpu_mgr
->
InsertItem
(
"index_"
+
std
::
to_string
(
i
),
data_obj
);
gpu_mgr
->
InsertItem
(
"index_"
+
std
::
to_string
(
i
),
data_obj
);
}
}
...
@@ -227,7 +227,7 @@ TEST(CacheTest, INVALID_TEST) {
...
@@ -227,7 +227,7 @@ TEST(CacheTest, INVALID_TEST) {
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
//each vector is 1k byte
//each vector is 1k byte
ms
::
engine
::
VecIndexPtr
mock_index
=
std
::
make_shared
<
MockVecIndex
>
(
256
,
2
);
ms
::
engine
::
VecIndexPtr
mock_index
=
std
::
make_shared
<
MockVecIndex
>
(
256
,
2
);
ms
::
cache
::
DataObjPtr
data_obj
=
std
::
make_shared
<
ms
::
cache
::
DataObj
>
(
mock_index
);
ms
::
cache
::
DataObjPtr
data_obj
=
std
::
static_pointer_cast
<
ms
::
cache
::
DataObj
>
(
mock_index
);
mgr
.
InsertItem
(
"index_"
+
std
::
to_string
(
i
),
data_obj
);
mgr
.
InsertItem
(
"index_"
+
std
::
to_string
(
i
),
data_obj
);
}
}
ASSERT_EQ
(
mgr
.
GetItem
(
"index_0"
),
nullptr
);
ASSERT_EQ
(
mgr
.
GetItem
(
"index_0"
),
nullptr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录