use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategyBigger.
@Test
public void testEdgeBatchUpdateStrategyBigger() {
// TODO: Add date comparison after fixing the date serialization bug
BatchEdgeRequest req = batchEdgeRequest("price", -3, 1, UpdateStrategy.BIGGER);
List<Edge> edges = edgeAPI.update(req);
assertBatchResponse(edges, "price", 1);
req = batchEdgeRequest("price", 7, 3, UpdateStrategy.BIGGER);
edges = edgeAPI.update(req);
assertBatchResponse(edges, "price", 7);
}
use of com.baidu.hugegraph.structure.graph.Edge 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.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeApiTest method testBatchCreateWithMoreThanBatchSize.
@Test
public void testBatchCreateWithMoreThanBatchSize() {
List<Vertex> persons = super.create100PersonBatch();
List<Vertex> softwares = super.create50SoftwareBatch();
vertexAPI.create(persons);
vertexAPI.create(softwares);
List<Edge> edges = new ArrayList<>(1000);
for (int i = 0; i < 1000; i++) {
Edge edge = new Edge("created");
edge.sourceLabel("person");
edge.targetLabel("software");
edge.sourceId("person:Person-" + i);
edge.targetId("software:Software-" + i);
edge.property("date", "2017-08-24");
edge.property("city", "Hongkong");
edges.add(edge);
}
Utils.assertResponseError(400, () -> {
edgeAPI.create(edges, true);
});
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeApiTest method testBatchCreateWithValidVertexAndCheck.
@Test
public void testBatchCreateWithValidVertexAndCheck() {
VertexLabel person = schema().getVertexLabel("person");
VertexLabel software = schema().getVertexLabel("software");
List<Vertex> persons = super.create100PersonBatch();
List<Vertex> softwares = super.create50SoftwareBatch();
vertexAPI.create(persons);
vertexAPI.create(softwares);
List<Edge> createds = super.create50CreatedBatch();
List<Edge> knows = super.create50KnowsBatch();
List<String> createdIds = edgeAPI.create(createds, true);
List<String> knowsIds = edgeAPI.create(knows, true);
Assert.assertEquals(50, createdIds.size());
Assert.assertEquals(50, knowsIds.size());
for (int i = 0; i < 50; i++) {
Edge created = edgeAPI.get(createdIds.get(i));
Assert.assertEquals("created", created.label());
Assert.assertEquals("person", created.sourceLabel());
Assert.assertEquals("software", created.targetLabel());
Assert.assertEquals(person.id() + ":Person-" + i, created.sourceId());
Assert.assertEquals(software.id() + ":Software-" + i, created.targetId());
String date = Utils.formatDate("2017-03-24");
Map<String, Object> props = ImmutableMap.of("date", date, "city", "Hongkong");
Assert.assertEquals(props, created.properties());
}
for (int i = 0; i < 50; i++) {
Edge know = edgeAPI.get(knowsIds.get(i));
Assert.assertEquals("knows", know.label());
Assert.assertEquals("person", know.sourceLabel());
Assert.assertEquals("person", know.targetLabel());
Assert.assertEquals(person.id() + ":Person-" + i, know.sourceId());
Assert.assertEquals(person.id() + ":Person-" + (i + 50), know.targetId());
String date = Utils.formatDate("2017-03-24");
Map<String, Object> props = ImmutableMap.of("date", date);
Assert.assertEquals(props, know.properties());
}
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class TraverserManager method edges.
public Edges edges(Shard shard, String page, long pageLimit) {
E.checkArgument(page == null || pageLimit >= 0, "Page limit must be >= 0 when page is not null");
Edges edges = this.edgesAPI.scan(shard, page, pageLimit);
for (Edge edge : edges.results()) {
edge.attachManager(this.graphManager);
}
return edges;
}
Aggregations