use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method batchEdgeRequest.
private BatchEdgeRequest batchEdgeRequest(String key, Object oldData, Object newData, UpdateStrategy strategy) {
// Init old vertices & edges
graph().addVertices(this.createNVertexBatch("object", oldData, BATCH_SIZE * 2));
graph().addEdges(this.createNEdgesBatch("object", "updates", oldData, BATCH_SIZE));
List<Edge> edges = this.createNEdgesBatch("object", "updates", newData, BATCH_SIZE);
Map<String, UpdateStrategy> strategies = ImmutableMap.of(key, strategy);
BatchEdgeRequest req;
req = new BatchEdgeRequest.Builder().edges(edges).updatingStrategies(strategies).checkVertex(false).createIfNotExist(true).build();
return req;
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategyUnion.
@Test
public void testEdgeBatchUpdateStrategyUnion() {
BatchEdgeRequest req = batchEdgeRequest("set", "old", "new", UpdateStrategy.UNION);
List<Edge> edges = edgeAPI.update(req);
assertBatchResponse(edges, "set", "new", "old");
req = batchEdgeRequest("set", "old", "old", UpdateStrategy.UNION);
edges = edgeAPI.update(req);
assertBatchResponse(edges, "set", "old");
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategyIntersection.
@Test
public void testEdgeBatchUpdateStrategyIntersection() {
BatchEdgeRequest req = batchEdgeRequest("set", "old", "new", INTERSECTION);
List<Edge> edges = edgeAPI.update(req);
assertBatchResponse(edges, "set");
req = batchEdgeRequest("set", "old", "old", INTERSECTION);
edges = edgeAPI.update(req);
assertBatchResponse(edges, "set", "old");
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testEdgeBatchUpdateWithNullValues.
@Test
public void testEdgeBatchUpdateWithNullValues() {
BatchEdgeRequest req = batchEdgeRequest("price", 1, null, UpdateStrategy.OVERRIDE);
List<Edge> edges = edgeAPI.update(req);
assertBatchResponse(edges, "price", 1);
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategySum.
/* Edge Test */
@Test
public void testEdgeBatchUpdateStrategySum() {
BatchEdgeRequest req = batchEdgeRequest("price", -1, 1, UpdateStrategy.SUM);
List<Edge> edges = edgeAPI.update(req);
assertBatchResponse(edges, "price", 0);
req = batchEdgeRequest("price", 2, 3, UpdateStrategy.SUM);
edges = edgeAPI.update(req);
assertBatchResponse(edges, "price", 5);
}
Aggregations