Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
31f02992
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,发现更多精彩内容 >>
提交
31f02992
编写于
3月 21, 2019
作者:
J
jinhai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add GroupHandler and RawFileHandler
上级
5b14d5ca
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
10 deletion
+56
-10
pyengine/engine/controller/GroupHandler.py
pyengine/engine/controller/GroupHandler.py
+24
-0
pyengine/engine/controller/RawFileHandler.py
pyengine/engine/controller/RawFileHandler.py
+14
-0
pyengine/engine/controller/VectorEngine.py
pyengine/engine/controller/VectorEngine.py
+18
-10
未找到文件。
pyengine/engine/controller/GroupHandler.py
0 → 100644
浏览文件 @
31f02992
import
os
,
shutil
class
GroupHandler
(
object
):
@
staticmethod
def
CreateGroupDirectory
(
group_id
):
path
=
GetGroupDirectory
(
group_id
)
path
=
path
.
strip
()
path
=
path
.
rstrip
(
"
\\
"
)
if
not
os
.
path
.
exists
():
os
.
makedirs
(
path
)
@
staticmethod
def
DeleteGroupDirectory
(
group_id
):
path
=
GetGroupDirectory
(
group_id
)
path
=
path
.
strip
()
path
=
path
.
rstrip
(
"
\\
"
)
if
os
.
path
.
exists
():
shutil
.
rmtree
(
path
)
@
staticmethod
def
GetGroupDirectory
(
group_id
):
return
DATABASE_DIRECTORY
+
'/'
+
group_id
\ No newline at end of file
pyengine/engine/controller/RawFileHandler.py
0 → 100644
浏览文件 @
31f02992
class
RawFileHandler
(
object
):
@
staticmethod
def
Create
(
filename
,
type
):
# type means: csv, parquet
pass
@
staticmethod
def
Read
(
filename
,
type
):
pass
@
staticmethod
def
Append
(
filename
,
type
,
record
):
pass
\ No newline at end of file
pyengine/engine/controller/VectorEngine.py
浏览文件 @
31f02992
from
engine.model.GroupTable
import
GroupTable
from
engine.model.GroupTable
import
GroupTable
from
engine.model.FileTable
import
FileTable
from
engine.model.FileTable
import
FileTable
from
engine.controller.RawFileHandler
import
RawFileHandler
from
engine.controller.GroupHandler
import
GroupHandler
from
flask
import
jsonify
from
flask
import
jsonify
from
engine
import
db
from
engine
import
db
import
sys
import
sys
,
os
class
VectorEngine
(
object
):
class
VectorEngine
(
object
):
...
@@ -15,6 +17,7 @@ class VectorEngine(object):
...
@@ -15,6 +17,7 @@ class VectorEngine(object):
new_group
=
GroupTable
(
group_id
)
new_group
=
GroupTable
(
group_id
)
db
.
session
.
add
(
new_group
)
db
.
session
.
add
(
new_group
)
db
.
session
.
commit
()
db
.
session
.
commit
()
GroupHandler
.
CreateGroupDirectory
(
group_id
)
return
jsonify
({
'code'
:
0
,
'group_name'
:
group_id
,
'file_number'
:
0
})
return
jsonify
({
'code'
:
0
,
'group_name'
:
group_id
,
'file_number'
:
0
})
@
staticmethod
@
staticmethod
...
@@ -33,6 +36,7 @@ class VectorEngine(object):
...
@@ -33,6 +36,7 @@ class VectorEngine(object):
# old_group = GroupTable(group_id)
# old_group = GroupTable(group_id)
db
.
session
.
delete
(
group
)
db
.
session
.
delete
(
group
)
db
.
session
.
commit
()
db
.
session
.
commit
()
GroupHandler
.
DeleteGroupDirectory
(
group_id
)
return
jsonify
({
'code'
:
0
,
'group_name'
:
group_id
,
'file_number'
:
group
.
file_number
})
return
jsonify
({
'code'
:
0
,
'group_name'
:
group_id
,
'file_number'
:
group
.
file_number
})
else
:
else
:
return
jsonify
({
'code'
:
0
,
'group_name'
:
group_id
,
'file_number'
:
0
})
return
jsonify
({
'code'
:
0
,
'group_name'
:
group_id
,
'file_number'
:
0
})
...
@@ -61,8 +65,8 @@ class VectorEngine(object):
...
@@ -61,8 +65,8 @@ class VectorEngine(object):
CreateIndex
(
group_id
,
index_filename
)
CreateIndex
(
group_id
,
index_filename
)
# create another raw file
# create another raw file
raw_filename
=
file
.
group_id
+
'_'
+
file
.
seq_no
raw_filename
=
file
.
seq_no
InsertVectorIntoRawFile
(
raw_filename
,
vector
)
InsertVectorIntoRawFile
(
group_id
,
raw_filename
,
vector
)
# insert a record into database
# insert a record into database
db
.
session
.
add
(
FileTable
(
group_id
,
raw_filename
,
'raw'
,
1
))
db
.
session
.
add
(
FileTable
(
group_id
,
raw_filename
,
'raw'
,
1
))
db
.
session
.
commit
()
db
.
session
.
commit
()
...
@@ -90,17 +94,21 @@ class VectorEngine(object):
...
@@ -90,17 +94,21 @@ class VectorEngine(object):
# construct response and send back
# construct response and send back
return
jsonify
({
'code'
:
0
})
return
jsonify
({
'code'
:
0
})
@
staticmethod
def
CreateIndex
(
group_id
):
print
(
group_id
)
return
jsonify
({
'code'
:
0
})
@
staticmethod
@
staticmethod
def
CreateIndex
(
group_id
,
filename
):
def
CreateIndex
(
group_id
,
filename
):
print
(
group_id
,
filename
)
path
=
GroupHandler
.
GetGroupDirectory
(
group_id
)
+
'/'
+
filename
print
(
group_id
,
path
)
return
jsonify
({
'code'
:
0
})
return
jsonify
({
'code'
:
0
})
@
staticmethod
@
staticmethod
def
InsertVectorIntoRawFile
(
filename
,
vector
):
def
InsertVectorIntoRawFile
(
group_id
,
filename
,
vector
):
print
(
sys
.
_getframe
().
f_code
.
co_name
)
print
(
sys
.
_getframe
().
f_code
.
co_name
)
path
=
GroupHandler
.
GetGroupDirectory
(
group_id
)
+
'/'
+
filename
# if filename exist
# append
# if filename not exist
# create file
# append
return
filename
return
filename
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录