Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
095fccd4
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,发现更多精彩内容 >>
提交
095fccd4
编写于
4月 09, 2019
作者:
J
jinhai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update Group handle
Former-commit-id: 763ec1587990a4c47ee52e1e255ca75e1b91320a
上级
c40c2172
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
40 addition
and
36 deletion
+40
-36
pyengine/engine/controller/meta_manager.py
pyengine/engine/controller/meta_manager.py
+11
-5
pyengine/engine/controller/storage_manager.py
pyengine/engine/controller/storage_manager.py
+8
-0
pyengine/engine/controller/tests/test_vector_engine.py
pyengine/engine/controller/tests/test_vector_engine.py
+4
-8
pyengine/engine/controller/vector_engine.py
pyengine/engine/controller/vector_engine.py
+15
-21
pyengine/engine/controller/views.py
pyengine/engine/controller/views.py
+2
-2
未找到文件。
pyengine/engine/controller/meta_manager.py
浏览文件 @
095fccd4
...
@@ -27,8 +27,14 @@ class MetaManager(object):
...
@@ -27,8 +27,14 @@ class MetaManager(object):
else
:
else
:
return
ErrorCode
.
FAULT_CODE
,
None
return
ErrorCode
.
FAULT_CODE
,
None
# def DeleteGroup(group_id):
@
staticmethod
# group = GroupTable.query.filter(GroupTable.group_name==group_id).first()
def
DeleteGroup
(
group
):
# if(group):
db
.
session
.
delete
(
group
)
# db.session.delete(group)
# else:
@
staticmethod
\ No newline at end of file
def
DeleteGroupFiles
(
group_name
):
records
=
FileTable
.
query
.
filter
(
FileTable
.
group_name
==
group_name
).
all
()
for
record
in
records
:
print
(
"record.group_name: "
,
record
.
group_name
)
db
.
session
.
delete
(
record
)
\ No newline at end of file
pyengine/engine/controller/storage_manager.py
浏览文件 @
095fccd4
...
@@ -14,6 +14,14 @@ class StorageManager(object):
...
@@ -14,6 +14,14 @@ class StorageManager(object):
def
GetGroupDirectory
(
group_name
):
def
GetGroupDirectory
(
group_name
):
return
DATABASE_DIRECTORY
+
'/'
+
group_name
return
DATABASE_DIRECTORY
+
'/'
+
group_name
@
staticmethod
def
DeleteGroup
(
group_id
):
path
=
StorageManager
.
GetGroupDirectory
(
group_id
)
path
=
path
.
strip
()
path
=
path
.
rstrip
(
"
\\
"
)
if
os
.
path
.
exists
(
path
):
shutil
.
rmtree
(
path
)
def
Read
():
def
Read
():
pass
pass
...
...
pyengine/engine/controller/tests/test_vector_engine.py
浏览文件 @
095fccd4
...
@@ -21,10 +21,9 @@ class TestVectorEngine:
...
@@ -21,10 +21,9 @@ class TestVectorEngine:
def
test_group
(
self
):
def
test_group
(
self
):
# Make sure there is no group
# Make sure there is no group
code
,
group_id
,
file_number
=
VectorEngine
.
DeleteGroup
(
'test_group'
)
code
,
group_id
=
VectorEngine
.
DeleteGroup
(
'test_group'
)
assert
code
==
VectorEngine
.
SUCCESS_CODE
assert
code
==
VectorEngine
.
SUCCESS_CODE
assert
group_id
==
'test_group'
assert
group_id
==
'test_group'
assert
file_number
==
0
# Add a group
# Add a group
code
,
group_id
=
VectorEngine
.
AddGroup
(
'test_group'
,
8
)
code
,
group_id
=
VectorEngine
.
AddGroup
(
'test_group'
,
8
)
...
@@ -32,10 +31,9 @@ class TestVectorEngine:
...
@@ -32,10 +31,9 @@ class TestVectorEngine:
assert
group_id
==
'test_group'
assert
group_id
==
'test_group'
# Check the group existing
# Check the group existing
code
,
group_id
,
file_number
=
VectorEngine
.
GetGroup
(
'test_group'
)
code
,
group_id
=
VectorEngine
.
GetGroup
(
'test_group'
)
assert
code
==
VectorEngine
.
SUCCESS_CODE
assert
code
==
VectorEngine
.
SUCCESS_CODE
assert
group_id
==
'test_group'
assert
group_id
==
'test_group'
assert
file_number
==
0
# Check the group list
# Check the group list
code
,
group_list
=
VectorEngine
.
GetGroupList
()
code
,
group_list
=
VectorEngine
.
GetGroupList
()
...
@@ -63,16 +61,14 @@ class TestVectorEngine:
...
@@ -63,16 +61,14 @@ class TestVectorEngine:
assert
code
==
VectorEngine
.
SUCCESS_CODE
assert
code
==
VectorEngine
.
SUCCESS_CODE
# Remove the group
# Remove the group
code
,
group_id
,
file_number
=
VectorEngine
.
DeleteGroup
(
'test_group'
)
code
,
group_id
=
VectorEngine
.
DeleteGroup
(
'test_group'
)
assert
code
==
VectorEngine
.
SUCCESS_CODE
assert
code
==
VectorEngine
.
SUCCESS_CODE
assert
group_id
==
'test_group'
assert
group_id
==
'test_group'
assert
file_number
==
0
# Check the group is disppeared
# Check the group is disppeared
code
,
group_id
,
file_number
=
VectorEngine
.
GetGroup
(
'test_group'
)
code
,
group_id
=
VectorEngine
.
GetGroup
(
'test_group'
)
assert
code
==
VectorEngine
.
FAULT_CODE
assert
code
==
VectorEngine
.
FAULT_CODE
assert
group_id
==
'test_group'
assert
group_id
==
'test_group'
assert
file_number
==
0
# Check SearchVector interface
# Check SearchVector interface
code
,
vector_ids
=
VectorEngine
.
SearchVector
(
'test_group'
,
self
.
__vector
,
self
.
__limit
)
code
,
vector_ids
=
VectorEngine
.
SearchVector
(
'test_group'
,
self
.
__vector
,
self
.
__limit
)
...
...
pyengine/engine/controller/vector_engine.py
浏览文件 @
095fccd4
...
@@ -24,41 +24,35 @@ class VectorEngine(object):
...
@@ -24,41 +24,35 @@ class VectorEngine(object):
@
staticmethod
@
staticmethod
def
AddGroup
(
group_name
,
dimension
):
def
AddGroup
(
group_name
,
dimension
):
error
,
group
=
MetaManager
.
GetGroup
(
group_name
)
error
,
group
=
MetaManager
.
GetGroup
(
group_name
)
if
(
error
==
ErrorCode
.
SUCCESS_CODE
)
:
if
error
==
ErrorCode
.
SUCCESS_CODE
:
return
ErrorCode
.
FAULT_CODE
,
group_name
return
ErrorCode
.
FAULT_CODE
,
group_name
else
:
else
:
StorageManager
.
AddGroup
(
group_name
)
StorageManager
.
AddGroup
(
group_name
)
MetaManager
.
AddGroup
(
group_name
,
dimension
)
MetaManager
.
AddGroup
(
group_name
,
dimension
)
return
VectorEngin
e
.
SUCCESS_CODE
,
group_name
return
ErrorCod
e
.
SUCCESS_CODE
,
group_name
@
staticmethod
@
staticmethod
def
GetGroup
(
group_id
):
def
GetGroup
(
group_name
):
group
=
GroupTable
.
query
.
filter
(
GroupTable
.
group_name
==
group_id
).
first
()
error
,
_
=
MetaManager
.
GetGroup
(
group_name
)
if
group
:
return
error
,
group_name
return
VectorEngine
.
SUCCESS_CODE
,
group_id
,
group
.
file_number
else
:
return
VectorEngine
.
FAULT_CODE
,
group_id
,
0
@
staticmethod
@
staticmethod
def
DeleteGroup
(
group_
id
):
def
DeleteGroup
(
group_
name
):
group
=
GroupTable
.
query
.
filter
(
GroupTable
.
group_name
==
group_
id
).
first
()
group
=
GroupTable
.
query
.
filter
(
GroupTable
.
group_name
==
group_
name
).
first
()
if
(
group
):
if
(
group
):
# old_group = GroupTable(group_id)
MetaManager
.
DeleteGroup
(
group
)
db
.
session
.
delete
(
group
)
StorageManager
.
DeleteGroup
(
group_name
)
db
.
session
.
commit
()
GroupHandler
.
DeleteGroupDirectory
(
group_id
)
records
=
FileTable
.
query
.
filter
(
FileTable
.
group_name
==
group_
id
).
all
()
records
=
FileTable
.
query
.
filter
(
FileTable
.
group_name
==
group_
name
).
all
()
for
record
in
records
:
for
record
in
records
:
print
(
"record.group_name: "
,
record
.
group_name
)
print
(
"record.group_name: "
,
record
.
group_name
)
db
.
session
.
delete
(
record
)
db
.
session
.
delete
(
record
)
db
.
session
.
commit
()
db
.
session
.
commit
()
return
VectorEngine
.
SUCCESS_CODE
,
group_
id
,
group
.
file_number
return
VectorEngine
.
SUCCESS_CODE
,
group_
name
else
:
else
:
return
VectorEngine
.
SUCCESS_CODE
,
group_
id
,
0
return
VectorEngine
.
SUCCESS_CODE
,
group_
name
@
staticmethod
@
staticmethod
...
@@ -78,7 +72,7 @@ class VectorEngine(object):
...
@@ -78,7 +72,7 @@ class VectorEngine(object):
@
staticmethod
@
staticmethod
def
AddVector
(
group_id
,
vectors
):
def
AddVector
(
group_id
,
vectors
):
print
(
group_id
,
vectors
)
print
(
group_id
,
vectors
)
code
,
_
,
_
=
VectorEngine
.
GetGroup
(
group_id
)
code
,
_
,
=
VectorEngine
.
GetGroup
(
group_id
)
if
code
==
VectorEngine
.
FAULT_CODE
:
if
code
==
VectorEngine
.
FAULT_CODE
:
return
VectorEngine
.
GROUP_NOT_EXIST
,
'invalid'
return
VectorEngine
.
GROUP_NOT_EXIST
,
'invalid'
...
@@ -140,7 +134,7 @@ class VectorEngine(object):
...
@@ -140,7 +134,7 @@ class VectorEngine(object):
@
staticmethod
@
staticmethod
def
SearchVector
(
group_id
,
vector
,
limit
):
def
SearchVector
(
group_id
,
vector
,
limit
):
# Check the group exist
# Check the group exist
code
,
_
,
_
=
VectorEngine
.
GetGroup
(
group_id
)
code
,
_
=
VectorEngine
.
GetGroup
(
group_id
)
if
code
==
VectorEngine
.
FAULT_CODE
:
if
code
==
VectorEngine
.
FAULT_CODE
:
return
VectorEngine
.
GROUP_NOT_EXIST
,
{}
return
VectorEngine
.
GROUP_NOT_EXIST
,
{}
...
@@ -168,7 +162,7 @@ class VectorEngine(object):
...
@@ -168,7 +162,7 @@ class VectorEngine(object):
@
staticmethod
@
staticmethod
def
CreateIndex
(
group_id
):
def
CreateIndex
(
group_id
):
# Check the group exist
# Check the group exist
code
,
_
,
_
=
VectorEngine
.
GetGroup
(
group_id
)
code
,
_
=
VectorEngine
.
GetGroup
(
group_id
)
if
code
==
VectorEngine
.
FAULT_CODE
:
if
code
==
VectorEngine
.
FAULT_CODE
:
return
VectorEngine
.
GROUP_NOT_EXIST
return
VectorEngine
.
GROUP_NOT_EXIST
...
...
pyengine/engine/controller/views.py
浏览文件 @
095fccd4
...
@@ -63,11 +63,11 @@ class Group(Resource):
...
@@ -63,11 +63,11 @@ class Group(Resource):
return
jsonify
({
'code'
:
code
,
'group'
:
group_id
,
'filenumber'
:
0
})
return
jsonify
({
'code'
:
code
,
'group'
:
group_id
,
'filenumber'
:
0
})
def
get
(
self
,
group_id
):
def
get
(
self
,
group_id
):
code
,
group_id
,
file_number
=
VectorEngine
.
GetGroup
(
group_id
)
code
,
group_id
=
VectorEngine
.
GetGroup
(
group_id
)
return
jsonify
({
'code'
:
code
,
'group'
:
group_id
,
'filenumber'
:
0
})
return
jsonify
({
'code'
:
code
,
'group'
:
group_id
,
'filenumber'
:
0
})
def
delete
(
self
,
group_id
):
def
delete
(
self
,
group_id
):
code
,
group_id
,
file_number
=
VectorEngine
.
DeleteGroup
(
group_id
)
code
,
group_id
=
VectorEngine
.
DeleteGroup
(
group_id
)
return
jsonify
({
'code'
:
code
,
'group'
:
group_id
,
'filenumber'
:
0
})
return
jsonify
({
'code'
:
code
,
'group'
:
group_id
,
'filenumber'
:
0
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录