use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelTest method testResetVertexLabelId.
@Test
public void testResetVertexLabelId() {
SchemaManager schema = schema();
VertexLabel player = schema.vertexLabel("player").properties("name").create();
Assert.assertTrue(player.id() > 0);
player.resetId();
Assert.assertEquals(0L, player.id());
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelTest method testAppendVertexLabelWithUserData.
@Test
public void testAppendVertexLabelWithUserData() {
SchemaManager schema = schema();
VertexLabel player = schema.vertexLabel("player").properties("name").create();
Assert.assertEquals(1, player.userdata().size());
String time = (String) player.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
try {
Thread.sleep(10);
} catch (InterruptedException e) {
Assert.fail(e.getMessage());
}
Assert.assertTrue(createTime.before(DateUtil.now()));
player = schema.vertexLabel("player").userdata("super_vl", "person").append();
Assert.assertEquals(2, player.userdata().size());
Assert.assertEquals("person", player.userdata().get("super_vl"));
time = (String) player.userdata().get("~create_time");
Assert.assertEquals(createTime, DateUtil.parse(time));
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelTest method testSetCheckExist.
@Test
public void testSetCheckExist() {
SchemaManager schema = schema();
VertexLabel player = schema.vertexLabel("player").properties("name").build();
Assert.assertTrue(player.checkExist());
player.checkExist(false);
Assert.assertFalse(player.checkExist());
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method createNEdgesBatch.
private List<Edge> createNEdgesBatch(String vertexLabel, String edgeLabel, Object symbol, int num) {
VertexLabel vLabel = schema().getVertexLabel(vertexLabel);
List<Edge> edges = new ArrayList<>(num);
for (int i = 1; i <= num; i++) {
Edge edge = new Edge(edgeLabel);
edge.sourceLabel(vertexLabel);
edge.targetLabel(vertexLabel);
edge.sourceId(vLabel.id() + ":" + i);
edge.targetId(vLabel.id() + ":" + i * 2);
edge.property("name", String.valueOf(i));
if (symbol instanceof Number) {
edge.property("price", (int) symbol * i);
}
edge.property("date", new Date(System.currentTimeMillis() + i));
edge.property("set", ImmutableSet.of(String.valueOf(symbol) + i));
edge.property("list", ImmutableList.of(String.valueOf(symbol) + i));
edges.add(edge);
}
return edges;
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class BaseClientTest method create50CreatedBatch.
protected List<Edge> create50CreatedBatch() {
VertexLabel person = schema().getVertexLabel("person");
VertexLabel software = schema().getVertexLabel("software");
List<Edge> edges = new ArrayList<>(50);
for (int i = 0; i < 50; i++) {
Edge edge = new Edge("created");
edge.sourceLabel("person");
edge.targetLabel("software");
edge.sourceId(person.id() + ":Person-" + i);
edge.targetId(software.id() + ":Software-" + i);
edge.property("date", "2017-03-24");
edge.property("city", "Hongkong");
edges.add(edge);
}
return edges;
}
Aggregations