mirror of https://github.com/milvus-io/milvus.git
Update for group handle
parent
42039c22af
commit
e5f782eda6
|
@ -1,24 +1,23 @@
|
|||
from engine.model.group_table import GroupTable
|
||||
from engine.model.file_table import FileTable
|
||||
from engine.controller.error_code import ErrorCode
|
||||
from engine import db
|
||||
|
||||
class MetaManager(object):
|
||||
|
||||
def Sync(self):
|
||||
@staticmethod
|
||||
def Sync():
|
||||
db.session.commit()
|
||||
|
||||
def AddGroup(self, group_name, dimension):
|
||||
group = GroupTable.query.filter(GroupTable.group_name==group_id).first()
|
||||
if group:
|
||||
return ErrorCode.ALREADY_EXIST, group_name
|
||||
else:
|
||||
new_group = GroupTable(group_name, dimension)
|
||||
GroupHandler.CreateGroupDirectory(group_id)
|
||||
@staticmethod
|
||||
def AddGroup(group_name, dimension):
|
||||
new_group = GroupTable(group_name, dimension)
|
||||
|
||||
# add into database
|
||||
db.session.add(new_group)
|
||||
self.Sync()
|
||||
return ErrorCode.SUCCESS_CODE, group_name
|
||||
# add into database
|
||||
db.session.add(new_group)
|
||||
db.session.commit()
|
||||
|
||||
return ErrorCode.SUCCESS_CODE, group_name
|
||||
|
||||
@staticmethod
|
||||
def GetGroup(group_name):
|
||||
|
|
|
@ -3,7 +3,7 @@ from engine.settings import DATABASE_DIRECTORY
|
|||
|
||||
class StorageManager(object):
|
||||
@staticmethod
|
||||
def CreateGroup(group_name):
|
||||
def AddGroup(group_name):
|
||||
path = StorageManager.GetGroupDirectory(group_name)
|
||||
path = path.strip()
|
||||
path=path.rstrip("\\")
|
||||
|
|
|
@ -27,12 +27,8 @@ class VectorEngine(object):
|
|||
if(error == ErrorCode.SUCCESS_CODE):
|
||||
return ErrorCode.FAULT_CODE, group_name
|
||||
else:
|
||||
StorageManager.CreateGroup(group_name)
|
||||
new_group = GroupTable(group_name, dimension)
|
||||
|
||||
# add into database
|
||||
db.session.add(new_group)
|
||||
db.session.commit()
|
||||
StorageManager.AddGroup(group_name)
|
||||
MetaManager.AddGroup(group_name, dimension)
|
||||
return VectorEngine.SUCCESS_CODE, group_name
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue