使用批量插入点边的接口提升插入点边的性能
数据类型
Java与Ultipa数据类型的对应关系
Java | Ultipa |
---|---|
int | int32 |
String | string |
float | float |
double | double |
long | uint32 |
long | int64 |
String | uint64 |
java.util.Date | datetime |
java.util.Date | timestamp |
insertBulkNodes
参数 | 类型 | 说明 |
---|---|---|
schema | String | insertBulkNodes 只允许一个 schema |
properties | List<Property> | 插入的点的属性列表 |
nodes | List<Node> | 插入的点的数据 |
insertType | Ultipa.InsertType | NORMAL、OVERWRITE、UPSERT |
silent | boolean | 是否返回插入的 uuids,silent 为 true 不返回,为 false 返回 |
示例:
List<Property> propertyList = new ArrayList<>();
Property name = new Property();
name.setName("name");
name.setType(Ultipa.PropertyType.STRING);
propertyList.add(name);
Property age = new Property();
age.setName("age");
age.setType(Ultipa.PropertyType.INT32);
propertyList.add(age);
List<Node> nodeList = new ArrayList<>();
Node person1 = new Node();
person1.setSchema("person");
person1.setID("1");
Value value1 = new Value();
value1.put("name","person1");
value1.put("age",10);
person1.setValues(value1);
nodeList.add(person1);
Node person2 = new Node();
person2.setSchema("person");
person2.setID("2");
Value value2 = new Value();
value2.put("name","person2");
value2.put("age",20);
person2.setValues(value2);
nodeList.add(person2);
Response response = client.insertBulkNodes("person",propertyList,nodeList,Ultipa.InsertType.NORMAL,false);
insertBulkEdges
参数 | 类型 | 说明 |
---|---|---|
schema | String | insertBulkEdges 只允许一个 schema |
properties | List<Property> | 插入的边的属性列表 |
edges | List<Edge> | 插入的边的数据 |
insertType | Ultipa.InsertType | NORMAL、OVERWRITE、UPSERT |
silent | boolean | 是否返回插入的 uuids,silent 为 true 不返回,为 false 返回 |
示例:
List<Property> propertyList = new ArrayList<>();
Property typeProp = new Property();
typeProp.setName("type");
typeProp.setType(Ultipa.PropertyType.STRING);
propertyList.add(typeProp);
Property amountProp = new Property();
amountProp.setName("amount");
amountProp.setType(Ultipa.PropertyType.DOUBLE);
propertyList.add(amountProp);
List<Edge> edgeList = new ArrayList<>();
Edge edge1 = new Edge();
edge1.setSchema("transfer");
edge1.setFrom("1001");
edge1.setTo("1002");
Value value1 = new Value();
value1.put("type", "1");
value1.put("amount",100.0);
edge1.setValues(value1);
edgeList.add(edge1);
Edge edge2 = new Edge();
edge2.setSchema("transfer");
edge2.setFrom("1002");
edge2.setTo("1003");
Value value2 = new Value();
value2.put("type", "2");
value2.put("amount",200.0);
edge2.setValues(value2);
edgeList.add(edge2);
Response response = client.insertBulkEdges("transfer",propertyList,edgeList,Ultipa.InsertType.NORMAL,false);