Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
a90ac944
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,发现更多精彩内容 >>
提交
a90ac944
编写于
3月 27, 2019
作者:
X
xj.lin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add function test
上级
e8eb5f58
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
61 addition
and
5 deletion
+61
-5
pyengine/engine/controller/vector_engine.py
pyengine/engine/controller/vector_engine.py
+6
-4
pyengine/engine/controller/views.py
pyengine/engine/controller/views.py
+1
-0
pyengine/engine/settings.py
pyengine/engine/settings.py
+1
-1
pyengine/tests/test_function.py
pyengine/tests/test_function.py
+53
-0
未找到文件。
pyengine/engine/controller/vector_engine.py
浏览文件 @
a90ac944
...
...
@@ -108,7 +108,8 @@ class VectorEngine(object):
FileTable
.
query
.
filter
(
FileTable
.
group_name
==
group_id
).
filter
(
FileTable
.
type
==
'raw'
).
update
({
'row_number'
:
file
.
row_number
+
1
,
'type'
:
'index'
,
'filename'
:
index_filename
})
pass
db
.
session
.
commit
()
VectorEngine
.
group_dict
=
None
else
:
# we still can insert into exist raw file, update database
...
...
@@ -152,9 +153,9 @@ class VectorEngine(object):
vectors
.
append
(
vector
)
result
=
scheduler_instance
.
search
(
index_map
,
vectors
,
limit
)
vector_id
=
0
#
vector_id = 0
return
VectorEngine
.
SUCCESS_CODE
,
vector_id
return
VectorEngine
.
SUCCESS_CODE
,
result
@
staticmethod
...
...
@@ -184,7 +185,8 @@ class VectorEngine(object):
VectorEngine
.
group_dict
[
group_id
].
append
(
vector
)
print
(
'InsertVectorIntoRawFile: '
,
VectorEngine
.
group_dict
[
group_id
])
# print('InsertVectorIntoRawFile: ', VectorEngine.group_dict[group_id])
print
(
"cache size: "
,
len
(
VectorEngine
.
group_dict
[
group_id
]))
return
filename
...
...
pyengine/engine/controller/views.py
浏览文件 @
a90ac944
...
...
@@ -16,6 +16,7 @@ class Vector(Resource):
self
.
__parser
.
add_argument
(
'vector'
,
type
=
float
,
action
=
'append'
,
location
=
[
'json'
])
def
post
(
self
,
group_id
):
print
(
request
.
json
)
args
=
self
.
__parser
.
parse_args
()
vector
=
args
[
'vector'
]
code
=
VectorEngine
.
AddVector
(
group_id
,
vector
)
...
...
pyengine/engine/settings.py
浏览文件 @
a90ac944
...
...
@@ -5,5 +5,5 @@ SQLALCHEMY_TRACK_MODIFICATIONS = False
# SECRET_KEY='A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
SQLALCHEMY_DATABASE_URI
=
"mysql+pymysql://vecwise@127.0.0.1:3306/vecdata"
ROW_LIMIT
=
1000000
0
ROW_LIMIT
=
1000000
DATABASE_DIRECTORY
=
'/tmp'
\ No newline at end of file
pyengine/tests/test_function.py
0 → 100644
浏览文件 @
a90ac944
import
unittest
import
numpy
as
np
import
requests
import
logging
import
json
url
=
"http://127.0.0.1:5000"
# TODO: LOG and Assert
class
TestEngineFunction
(
unittest
.
TestCase
):
def
test_1m_add
(
self
):
d
=
4
nb
=
120
nq
=
1
k
=
10
_
,
xb
,
xq
=
get_dataset
(
d
,
nb
,
1
,
nq
)
groupid
=
"5m"
# route_group = url + "/vector/group/" + groupid
# r = requests.post(route_group, json={"dimension": d})
#
# # import dataset
# vector_add_route = url + "/vector/add/" + groupid
# for i in xb:
# data = dict()
# data['vector'] = i.tolist()
# r = requests.post(vector_add_route, json=data)
# search dataset
vector_search_route
=
url
+
"/vector/search/"
+
groupid
data
=
dict
()
data
[
'vector'
]
=
xq
.
tolist
()
data
[
'limit'
]
=
k
r
=
requests
.
get
(
vector_search_route
,
json
=
data
)
print
(
"finish"
)
def
get_dataset
(
d
,
nb
,
nt
,
nq
):
d1
=
10
# intrinsic dimension (more or less)
n
=
nb
+
nt
+
nq
rs
=
np
.
random
.
RandomState
(
1338
)
x
=
rs
.
normal
(
size
=
(
n
,
d1
))
x
=
np
.
dot
(
x
,
rs
.
rand
(
d1
,
d
))
x
=
x
*
(
rs
.
rand
(
d
)
*
4
+
0.1
)
x
=
np
.
sin
(
x
)
x
=
x
.
astype
(
'float32'
)
return
x
[:
nt
],
x
[
nt
:
-
nq
],
x
[
-
nq
:]
if
__name__
==
"__main__"
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录