Search in sources :

Example 26 with VertexLabel

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());
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Example 27 with VertexLabel

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));
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Date(java.util.Date) Test(org.junit.Test)

Example 28 with VertexLabel

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());
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Example 29 with VertexLabel

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;
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) ArrayList(java.util.ArrayList) Edge(com.baidu.hugegraph.structure.graph.Edge) Date(java.util.Date)

Example 30 with VertexLabel

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;
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) ArrayList(java.util.ArrayList) Edge(com.baidu.hugegraph.structure.graph.Edge)

Aggregations

VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)46 Test (org.junit.Test)31 HugeClient (com.baidu.hugegraph.driver.HugeClient)7 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)7 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)6 ExternalException (com.baidu.hugegraph.exception.ExternalException)5 ServerException (com.baidu.hugegraph.exception.ServerException)5 Edge (com.baidu.hugegraph.structure.graph.Edge)5 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 RestResult (com.baidu.hugegraph.rest.RestResult)3 Vertex (com.baidu.hugegraph.structure.graph.Vertex)3 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)3 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)2 VertexLabelEntity (com.baidu.hugegraph.entity.schema.VertexLabelEntity)1 VertexLabelStyle (com.baidu.hugegraph.entity.schema.VertexLabelStyle)1 Record (com.baidu.hugegraph.loader.builder.Record)1 VertexBuilder (com.baidu.hugegraph.loader.builder.VertexBuilder)1 ParseException (com.baidu.hugegraph.loader.exception.ParseException)1 ElementMapping (com.baidu.hugegraph.loader.mapping.ElementMapping)1