图集和属性

图集(图数据集)

一个图数据集包含:由点和边组成的一张图、这张图上所建立的索引、基于这张图执行的算法、统计信息、权限信息等一系列内容。

查看图集列表

List<Table> tables = client.listGraph();
println(tables);

响应中包含了图集名称以及点、边的总数:

[{"tableName":"","records":[{"totalEdges":"3387374","graph":"default","totalNodes":"403426"}]}]

获取图集信息

List<PairValue> values = client.getGraph("default");

创建图集

client.createGraph(graphName);

删除图集

client.dropGraph(graphName);

切换图集

在创建Connection对象时候指定graphName即可把对ultipa server的操作作用到对应图集上:

UltipaClientDriver driver = new UltipaClientDriver();
Connection client = driver.getConnection(graphName);

或者用另一种方式:

Connection client = new DefaultConnection(graphName);

修改图集名称

client.updateGraph(graphName, newGraphName);

属性(点属性、边属性)

查看点和边属性

List<Table> tables = client.showProperty(UqlProperty.PROPERTY);

查看点属性

List<Table> tables = client.showProperty(UqlProperty.NODE_PROPERTY);

查看边属性

List<Table> tables = client.showProperty(UqlProperty.EDGE_PROPERTY);

创建边属性

CreatePropertyRequest request = new CreatePropertyRequest();
Property property = new Property(propertyName,UqlPropertyType.UQL_STRING);
request.setAttrType(UqlAttrType.EDGE);
request.setProperty(property);
client.createProperty(request);

创建点属性

CreatePropertyRequest request = new CreatePropertyRequest();
Property property = new Property(propertyName,UqlPropertyType.UQL_STRING);
request.setAttrType(UqlAttrType.NODE);
request.setProperty(property);
client.createProperty(request);

删除边属性

DropPropertyRequest request = new DropPropertyRequest();
request.setAttrType(UqlAttrType.EDGE);
request.setPropertyName(propertyName);
client.dropProperty(request);

删除点属性

DropPropertyRequest request = new DropPropertyRequest();
request.setAttrType(UqlAttrType.NODE);
request.setPropertyName(propertyName);
client.dropProperty(request);

加载属性(LTE)

LTERequest request = new LTERequest();
request.setAttrType(UqlAttrType.EDGE);
request.setPropertyName(propertyName);
client.lte(request);

卸载属性(UFE)

UFERequest request = new UFERequest();
request.setAttrType(UqlAttrType.EDGE);
request.setPropertyName(propertyName);
client.ufe(request);

查看统计信息

List<Table> tables = client.stat();
println(tables);