Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
101abe5d
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,发现更多精彩内容 >>
提交
101abe5d
编写于
3月 20, 2019
作者:
J
jinhai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Before add real logic code
上级
7d18b6b0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
73 addition
and
16 deletion
+73
-16
README.md
README.md
+20
-0
pyengine/engine/controller/IndexManage.py
pyengine/engine/controller/IndexManage.py
+52
-15
pyengine/engine/controller/VectorEngine.py
pyengine/engine/controller/VectorEngine.py
+0
-0
pyengine/engine/model/GroupTable.py
pyengine/engine/model/GroupTable.py
+1
-1
未找到文件。
README.md
浏览文件 @
101abe5d
...
...
@@ -25,3 +25,23 @@
-
`python`
# enter python3 interaction environment
-
`from engine import db`
-
`db.create_all()`
-
table desc
group_table
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| group_name | varchar(100) | YES | | NULL | |
| file_number | int(11) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
file_table
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| group_name | varchar(100) | YES | | NULL | |
| filename | varchar(100) | YES | | NULL | |
| row_number | int(11) | YES | | NULL | |
+------------+--------------+------+-----+---------+----------------+
pyengine/engine/controller/IndexManage.py
浏览文件 @
101abe5d
from
flask
import
Flask
from
flask
import
Flask
,
jsonify
,
request
from
flask_restful
import
Resource
,
Api
from
engine
import
app
,
db
from
engine.model.GroupTable
import
GroupTable
# app = Flask(__name__)
api
=
Api
(
app
)
from
flask_restful
import
reqparse
from
flask_restful
import
request
class
Vector
(
Resource
):
def
__init__
(
self
):
self
.
__parser
=
reqparse
.
RequestParser
()
self
.
__parser
.
add_argument
(
'groupid'
,
type
=
str
)
self
.
__parser
.
add_argument
(
'vec'
,
type
=
str
)
self
.
__parser
.
add_argument
(
'vector'
,
type
=
float
,
action
=
'append'
,
location
=
[
'json'
])
def
post
(
self
):
# args = self.__parser.parse_args()
# vec = args['vec']
# groupid = args['groupid']
def
post
(
self
,
groupid
):
args
=
self
.
__parser
.
parse_args
()
vector
=
args
[
'vector'
]
# add vector into file
print
(
"vector: "
,
vector
)
return
"vector post"
class
VectorSearch
(
Resource
):
def
__init__
(
self
):
self
.
__parser
=
reqparse
.
RequestParser
()
self
.
__parser
.
add_argument
(
'
groupid'
,
type
=
str
)
self
.
__parser
.
add_argument
(
'
vector'
,
type
=
float
,
action
=
'append'
,
location
=
[
'json'
]
)
def
post
(
self
):
def
post
(
self
,
groupid
):
args
=
self
.
__parser
.
parse_args
()
print
(
'vector: '
,
args
[
'vector'
])
# go to search every thing
return
"vectorSearch post"
...
...
@@ -35,6 +40,7 @@ class Index(Resource):
self
.
__parser
.
add_argument
(
'groupid'
,
type
=
str
)
def
post
(
self
):
# go to create index for specific group
return
"index post"
...
...
@@ -44,25 +50,56 @@ class Group(Resource):
self
.
__parser
.
add_argument
(
'groupid'
,
type
=
str
)
def
post
(
self
,
groupid
):
return
"group post"
args
=
self
.
__parser
.
parse_args
()
group
=
GroupTable
.
query
.
filter
(
GroupTable
.
group_name
==
groupid
).
first
()
if
(
group
):
return
jsonify
({
'code'
:
1
,
'group_name'
:
groupid
,
'file_number'
:
group
.
file_number
})
else
:
new_group
=
GroupTable
(
groupid
)
db
.
session
.
add
(
new_group
)
db
.
session
.
commit
()
return
jsonify
({
'code'
:
0
,
'group_name'
:
groupid
,
'file_number'
:
0
})
def
get
(
self
,
groupid
):
return
"group get"
args
=
self
.
__parser
.
parse_args
()
group
=
GroupTable
.
query
.
filter
(
GroupTable
.
group_name
==
groupid
).
first
()
if
(
group
):
return
jsonify
({
'code'
:
0
,
'group_name'
:
groupid
,
'file_number'
:
group
.
file_number
})
else
:
return
jsonify
({
'code'
:
1
,
'group_name'
:
groupid
,
'file_number'
:
0
})
# not found
def
delete
(
self
,
groupid
):
return
"group delete"
args
=
self
.
__parser
.
parse_args
()
group
=
GroupTable
.
query
.
filter
(
GroupTable
.
group_name
==
groupid
).
first
()
if
(
group
):
# old_group = GroupTable(groupid)
db
.
session
.
delete
(
group
)
db
.
session
.
commit
()
return
jsonify
({
'code'
:
0
,
'group_name'
:
groupid
,
'file_number'
:
group
.
file_number
})
else
:
return
jsonify
({
'code'
:
0
,
'group_name'
:
groupid
,
'file_number'
:
0
})
class
GroupList
(
Resource
):
def
get
(
self
):
return
"grouplist get"
group
=
GroupTable
.
query
.
all
()
group_list
=
[]
for
group_tuple
in
group
:
group_item
=
{}
group_item
[
'group_name'
]
=
group_tuple
.
group_name
group_item
[
'file_number'
]
=
group_tuple
.
file_number
group_list
.
append
(
group_item
)
print
(
group_list
)
return
jsonify
(
results
=
group_list
)
api
.
add_resource
(
Vector
,
'/vector'
)
api
.
add_resource
(
Vector
,
'/vector
/add/<groupid>
'
)
api
.
add_resource
(
Group
,
'/vector/group/<groupid>'
)
api
.
add_resource
(
GroupList
,
'/vector/group'
)
api
.
add_resource
(
Index
,
'/vector/index'
)
api
.
add_resource
(
VectorSearch
,
'/vector/search'
)
api
.
add_resource
(
VectorSearch
,
'/vector/search
/<groupid>
'
)
# if __name__ == '__main__':
...
...
pyengine/engine/controller/VectorEngine.py
0 → 100644
浏览文件 @
101abe5d
pyengine/engine/model/GroupTable.py
浏览文件 @
101abe5d
...
...
@@ -11,4 +11,4 @@ class GroupTable(db.Model):
self
.
file_number
=
0
def
__repr__
(
self
):
return
'<GroupTable $r>'
%
self
.
group_name
\ No newline at end of file
return
'<GroupTable $s>'
%
self
.
group_name
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录