use of com.baidu.hugegraph.structure.graph.BatchEdgeRequest in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategySmaller.
@Test
public void testEdgeBatchUpdateStrategySmaller() {
BatchEdgeRequest req = batchEdgeRequest("price", -3, 1, UpdateStrategy.SMALLER);
List<Edge> edges = edgeAPI.update(req);
assertBatchResponse(edges, "price", -3);
req = batchEdgeRequest("price", 7, 3, UpdateStrategy.SMALLER);
edges = edgeAPI.update(req);
assertBatchResponse(edges, "price", 3);
}
use of com.baidu.hugegraph.structure.graph.BatchEdgeRequest in project incubator-hugegraph-toolchain by apache.
the class BatchElementRequestTest method testEdgeRequestBuildOK.
@Test
public void testEdgeRequestBuildOK() {
List<Edge> edges = ImmutableList.of(createEdge());
Map<String, UpdateStrategy> strategies = ImmutableMap.of("set", INTERSECTION);
BatchEdgeRequest req;
req = new BatchEdgeRequest.Builder().edges(edges).updatingStrategies(strategies).checkVertex(false).createIfNotExist(true).build();
Assert.assertNotNull(req);
Object list = Whitebox.getInternalState(req, "edges");
Assert.assertEquals(edges, list);
Object map = Whitebox.getInternalState(req, "updateStrategies");
Assert.assertEquals(strategies, map);
Object checked = Whitebox.getInternalState(req, "checkVertex");
Assert.assertEquals(false, checked);
Object created = Whitebox.getInternalState(req, "createIfNotExist");
Assert.assertEquals(true, created);
}
use of com.baidu.hugegraph.structure.graph.BatchEdgeRequest 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.BatchEdgeRequest 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.BatchEdgeRequest 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");
}
Aggregations