use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class BaseClientTest method create50SoftwareBatch.
protected List<Vertex> create50SoftwareBatch() {
List<Vertex> vertices = new ArrayList<>(50);
for (int i = 0; i < 50; i++) {
Vertex vertex = new Vertex("software");
vertex.property("name", "Software" + "-" + i);
vertex.property("lang", "java");
vertex.property("price", 328);
vertices.add(vertex);
}
return vertices;
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testVertexBatchUpdateWithNullValues.
@Test
public void testVertexBatchUpdateWithNullValues() {
BatchVertexRequest req = batchVertexRequest("price", 1, null, UpdateStrategy.OVERRIDE);
List<Vertex> vertices = vertexAPI.update(req);
assertBatchResponse(vertices, "price", 1);
}
use of com.baidu.hugegraph.structure.graph.Vertex 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.Vertex 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.Vertex in project incubator-hugegraph-toolchain by apache.
the class TraverserManager method vertices.
public Vertices vertices(Shard shard, String page, long pageLimit) {
E.checkArgument(page == null || pageLimit >= 0, "Page limit must be >= 0 when page is not null");
Vertices vertices = this.verticesAPI.scan(shard, page, pageLimit);
for (Vertex vertex : vertices.results()) {
vertex.attachManager(this.graphManager);
}
return vertices;
}
Aggregations