更新时间:2022-06-30 GMT+08:00
批量更新边属性
您可以使用GES提供的接口批量更新边属性。示例代码如下:
public static void updateBatchEdges(GraphClient graphClient) throws ApiException { // 构造边信息,不指定index EdgeWithIndex edgeWithoutIndex = new EdgeWithIndex(); edgeWithoutIndex.setSource("46"); edgeWithoutIndex.setTarget("37"); edgeWithoutIndex.setLabel("rate"); Map<String, List<Object>> properties = new HashMap<>(); properties.put("Rating", Arrays.asList("5")); properties.put("Datetime", Arrays.asList("2020-01-0120:30:05")); edgeWithoutIndex.setProperties(properties); // 构造边信息,指定index EdgeWithIndex edgeWithIndex = new EdgeWithIndex(); edgeWithIndex.setSource("46"); edgeWithIndex.setTarget("38"); edgeWithIndex.setIndex("0"); edgeWithIndex.setProperties(properties); // 组成边列表 List<EdgeWithIndex> edges = new ArrayList<>(); edges.add(edgeWithoutIndex); edges.add(edgeWithIndex); // 构造更新批量边属性请求 UpdateBatchEdgePropertyReq updateBatchEdgeReq = new UpdateBatchEdgePropertyReq(); updateBatchEdgeReq.setEdges(edges); // 执行更新批量边属性请求 Map<String, Object> result = graphClient.updateBatchEdge("batch-update", updateBatchEdgeReq); }
父主题: 使用业务面SDK