Schema Documentation

create_vertex_type

添加点类型。为图新增一个点类型。

函数声明

def create_vertex_type(self, type: str, pk_name: str, class_map: Union[Dict[str, PropertyType], None]) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点类型,不能为空。

pk_name

Y

str

主键名称,不能为空。

class_map

N

Optional[Dict[str, PropertyType]]

属性类型的映射,其中key是属性名,value是属性类型,允许为空。

异常

Type

DESC

ParamException

参数格式不正确,当类型为空、外部唯一标识属性名为空、属性名为空时将抛出异常。

TypeFoundException

边类型在图中已存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.enum import PropertyType
graph.schema().create_vertex_type("personTest", "idCard", None)

drop_vertex_type

删除点类型。删除图中已存在的一个点类型。

函数声明

def drop_vertex_type(self, type: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点类型,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当类型为空时将抛出异常。

TypeNotFoundException

点类型在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 删除点类型 "personTest"
graph.schema().drop_vertex_type("personTest")

create_edge_type

添加边类型。为图中新增一个边类型,并创建从from到to的CombinedEdgeType。

函数声明

def create_edge_type(
        self, type: str, combine_edge_types: Union[List[CombinedEdgeType], CombinedEdgeType],
        direct: bool, allow_repeat: bool, combine_key: Union[str, None], class_map: Union[Dict[str, PropertyType], None]
    ) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

边类型,不能为空。

combine_edge_types

Y

List[CombinedEdgeType], CombinedEdgeType

起始点类型和终止点类型组合集合,不能为空。

direct

Y

bool

边的方向

allow_repeat

Y

bool

是否允许重复

combine_key

Y

Optional[str]

基于属性进行去重,为空表示基于边类型进行去重。

class_map

Y

Optional[Dict[str, PropertyType]]

属性类型的映射,其中key是属性名,value是属性类型,**属性类型不能为空。**

异常

Type

DESC

ParamException

参数格式不正确,当边类型名为空、起始点类型名为空、终止点类型名为空、属性类型为空、allowrepeat为True时combinekey不为null或combineKey在classMap中不存在时将抛出异常。

TypeFoundException

边类型在图中已存在时将抛出异常。

TypeNotFoundException

起始点类型或终止点类型在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.enum import PropertyType
from graphdbapi.v1.graph import CombinedEdgeType
graph.schema().create_edge_type("pserosn_to_pserson", [CombinedEdgeType.init_combined_edge_type("person", "person")], False, False, None, None)

get_vertex_types

获取所有的点类型名。

函数声明

def get_vertex_types(self) -> Set[str]

响应参数

Parameter

Type

DESC

Set[str]

所有点的类型名集合

异常

Type

DESC

DatabaseException

数据库内部异常。

示例

print(graph.schema().get_vertex_types())

drop_edge_type

删除边类型。删除图中已存在的一个边类型。

函数声明

def drop_edge_type(self, type: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

边类型,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当边类型为空时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 删除边类型person_to_person
graph.schema().drop_edge_type("person_to_person")

drop_combined_edge_type

删除边类型中的一对起止点类型。

例:存在以下关系

人--关注-->公司

人--关注-->人

若:type为关注,fromType为人,toType为公司

则:人--关注-->公司(人到公司的关注关系被删除)

函数声明

def drop_combined_edge_type(self, type: str, from_type: str, to_type: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

边类型,不能为空。

from_type

Y

str

起始点类型,不能为空。

to_type

Y

str

终止点类型,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当边类型为空、起始点类型为空或终止点类型为空时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

TypeErrorException

from到to的映射不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

graph.schema().drop_combined_edge_type("person_to_person", "person", "person")

get_edge_types

获取所有的边类型名。

函数声明

def get_edge_types(self) -> Set[str]

响应参数

Parameter

Type

DESC

result

str

操作是否成功的提示

异常

Type

DESC

DatabaseException

数据库内部异常。

示例

print(graph.schema().get_edge_types())

create_property

为某个类型增加属性列。

函数声明

def create_property(self, type: str, is_vertex: bool, property_name: str, is_index: bool, property_type: PropertyType) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

is_vertex

Y

bool

点类型填True,边类型填False,is_vertex需要跟type对应。

property_name

Y

str

属性名,不能为空。

is_index

Y

bool

是否要加索引。True添加索引,False不添加索引

property_type

Y

PropertyType

属性类型,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当类型为空、属性名为空、属性类型为空时将抛出异常。

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

PropertyFoundException

属性名在对应类型中已存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.enum import PropertyType
# 为person点添加gender属性
graph.schema().create_property("pserson", True, "gender", True, PropertyType.INT)

drop_property

删除某个类型的某个属性。

函数声明

def drop_property(self, type: str, is_vertex: bool, property_name: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

is_vertex

Y

bool

点类型填True,边类型填False,is_vertex需要跟type对应。

property_name

Y

str

属性名,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当类型为空、属性名为空、属性类型为空时将抛出异常。

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在对应类型中不存在时将抛出异常。

DatabaseException

数据库内部异常

示例

# 删除点类型person的gender属性
graph.schema().drop_property('person', True, "gender")

get_property_keys

获取某个点/边类型下的属性名和属性类型。

函数声明

def get_property_keys(self, type: str, is_vertex: bool) -> Dict[str, PropertyType]

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

is_vertex

Y

bool

点类型为True,边类型为False,is_vertex需要跟type对应。

响应参数

Parameter

Type

DESC

Dict[str, PropertyType]

该类型所有属性的映射,其中key是属性名,value是属性类型

异常

Type

DESC

ParamException

参数格式不正确,当类型为空时将抛出异常。

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

print(graph.schema().get_property_keys("person", True))

get_property_pk

获取某个点类型下的外部唯一标识。

函数声明

def get_property_pk(self, type: str) -> str

参数说明

Parameter

Optional

Type

DESC

type

Y

str

类型名

响应参数

Parameter

Type

DESC

str

点类型下的外部唯一标识

异常

Type

DESC

ParamException

参数格式不正确,当类型为空时将抛出异常。

TypeNotFoundException

点类型在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 获取person点的主键名
print(graph.schema().get_property_pk('person'))

edit_direct

更新某个边类型的方向。无向or有向。

函数声明

def edit_direct(self, type: str, direct: bool) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

边类型,不能为空。

direct

Y

bool

方向

异常

Type

DESC

ParamException

参数格式不正确,当边类型为空时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 修改边person_to_person为有向
graph.schema().edit_direct('person_to_person', True)

get_edge_direct

获取某个边类型的方向

函数声明

def get_edge_direct(self, type: str) -> bool

参数说明

Parameter

Optional

Type

DESC

type

Y

str

边类型,不能为空。

响应参数

Parameter

Type

DESC

bool

True有向边, False无向边

异常

Type

DESC

ParamException

参数格式不正确,当类型为空时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 打印边person_to_person的方向
print(graph.schema().get_edge_direct('person_to_person'))

create_combined_edge_type

为指定边类型创建从from到to的CombinedEdgeType集合。

函数声明

def create_combined_edge_type(self, type: str, from_type: str, to_type: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

边类型,不能为空。

from_type

Y

str

起始点类型名,不能为空。

to_type

Y

str

终止点类型名,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当边类型名为空、起始点类型名为空、终止点类型名为空时将抛出异常。

EdgeNotFoundException

边在图中不存在时将抛出异常。

TypeNotFoundException

起始点类型或终止点类型在图中不存在时将抛出异常。

TypeErrorException

from到to的映射已存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

graph.schema().create_combined_edge_type('person_to_person', "person", "person")

get_combined_edge_type

根据边类型获取起始点和终止点类型名。

函数声明

def get_combined_edge_type(self, type: str) -> List[CombinedEdgeType]

参数说明

Parameter

Optional

Type

DESC

type

Y

str

边类型,不能为空。

响应参数

Parameter

Type

DESC

List[CombinedEdgeType]

起始点和终止点类型名组合列表

异常

Type

DESC

ParamException

参数格式不正确,当边类型为空时将抛出异常。

EdgeNotFoundException

边在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.graph import CombinedEdgeType
print(graph.schema().get_combined_edge_type("person_to_person"))

rename_type_name

更新某个类型名

函数声明

def rename_type_name(self, type: str, is_vertex: bool, new_type: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

is_vertex

Y

bool

点类型填True,边类型填False,is_vertex需要跟type对应。

new_type

Y

str

新类型名,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当类型为空、新类型名为空时将抛出异常。

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

TypeFoundException

新类型名在图中已存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

graph.schema().rename_type_name("personTest", True, "personTestNew")

rename_property_name

更新类型名

函数声明

def rename_property_name(self, type: str, is_vertex: bool, old_prop_name: str, new_prop_name: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

is_vertex

Y

bool

点类型填True,边类型填False,is_vertex需要跟type对应。

old_prop_name

Y

str

原属性名,不能为空。

new_prop_name

Y

str

新属性名,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当点/边类型为空、原属性名为空、新属性名为空时将抛出异常。

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

PropertyNotFoundException

原属性名在对应类型中不存在时将抛出异常。

PropertyFoundException

新属性名在对应类型中已存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

graph.schema().rename_property_name("person", True, "gender", "genderNew")

create_prop_index

为某个类型的某个属性添加简单索引。

函数声明

def create_prop_index(self, type: str, is_vertex: bool, property: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

is_vertex

Y

bool

点类型填True,边类型填False,is_vertex需要跟type对应。

property

Y

str

属性名,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当类型为空、属性名为空

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在对应类型中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

graph.schema().create_prop_index("person", True, "gender")

drop_prop_index

删除某个类型的某个属性索引。

函数声明

def drop_prop_index(self, type: str, is_vertex: bool, property: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

is_vertex

Y

bool

点类型填True,边类型填False,is_vertex需要跟type对应。

property

Y

str

属性名,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当类型为空、属性名为空时将抛出异常。

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在对应类型中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

graph.schema().drop_prop_index("person", True, "gender")

edit_property_desc

修改属性描述。

函数声明

def edit_property_desc(self, type: str, is_vertex: bool, prop_name: str, desc: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

is_vertex

Y

bool

点类型填True,边类型填False,is_vertex需要跟type对应。

prop_name

Y

str

属性名,不能为空。

desc

Y

str

属性描述

异常

Type

DESC

ParamException

参数格式不正确,当类型为空、属性名为空时将抛出异常。

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在对应类型中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

graph.schema().edit_property_desc("person", True, "gender", "性别")

get_property_desc

获取属性描述。

函数声明

def get_property_desc(self, type: str, is_vertex: bool, prop_name: str) -> Optional[str]

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

is_vertex

Y

bool

点类型填True,边类型填False,is_vertex需要跟type对应。

prop_name

Y

str

属性名,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当类型为空、属性名为空时将抛出异常。

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在对应类型中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

graph.schema().get_property_desc("person", True, "gender")

edit_graph_desc

编辑图描述。

函数声明

def edit_graph_desc(self, desc: str) -> None

参数说明

Parameter

Optional

Type

DESC

desc

Y

str

图描述信息

异常

Type

DESC

DatabaseException

数据库内部异常。

示例

graph.schema().edit_graph_desc("演员")

get_graph_desc

获取图描述

函数声明

def get_graph_desc(self) -> Optional[str]

异常

Type

DESC

DatabaseException

数据库内部异常。

示例

graph.schema().get_graph_desc()

edit_type_desc

修改类型描述。

函数声明

def edit_type_desc(self, type: str, is_vertex: bool, desc: str) -> None

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

prop_name

Y

str

属性名,不能为空。

desc

Y

str

属性描述

异常

Type

DESC

ParamException

参数格式不正确,当类型为空、属性名为空时将抛出异常。

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在对应类型中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

graph.schema().edit_type_desc("person", True, "人物")

get_type_desc

获取类型描述。

函数声明

def get_type_desc(self, type: str, is_vertex: bool) -> Optional[str]

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点/边类型,不能为空。

is_vertex

Y

bool

点类型填True,边类型填False,is_vertex需要跟type对应。

异常

Type

DESC

ParamException

参数格式不正确,当类型为空、属性名为空时将抛出异常。

TypeNotFoundException

点/边类型在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在对应类型中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

graph.schema().get_type_desc("person", True)