Search in sources :

Example 41 with EdgeLabel

use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.

the class EdgeLabelApiTest method testAppendWithSourceOrTargetLabel.

@Test
public void testAppendWithSourceOrTargetLabel() {
    EdgeLabel edgeLabel1 = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").singleTime().properties("date").build();
    edgeLabel1 = edgeLabelAPI.create(edgeLabel1);
    Assert.assertEquals("created", edgeLabel1.name());
    Assert.assertEquals("person", edgeLabel1.sourceLabel());
    Assert.assertEquals("software", edgeLabel1.targetLabel());
    Assert.assertEquals(Frequency.SINGLE, edgeLabel1.frequency());
    Set<String> props = ImmutableSet.of("date");
    Assert.assertEquals(props, edgeLabel1.properties());
    EdgeLabel edgeLabel2 = schema().edgeLabel("created").sourceLabel("person").targetLabel("person").properties("city").build();
    Utils.assertResponseError(400, () -> {
        edgeLabelAPI.append(edgeLabel2);
    });
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) Test(org.junit.Test)

Example 42 with EdgeLabel

use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.

the class JobApiTest method testRebuildEdgeLabel.

@Test
public void testRebuildEdgeLabel() {
    EdgeLabel created = schema().getEdgeLabel("created");
    long taskId = rebuildAPI.rebuild(created);
    Task task = taskAPI.get(taskId);
    Assert.assertNotNull(task);
    Assert.assertEquals(taskId, task.id());
    waitUntilTaskCompleted(taskId);
}
Also used : Task(com.baidu.hugegraph.structure.Task) EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) Test(org.junit.Test)

Example 43 with EdgeLabel

use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.

the class RebuildAPI method rebuildIndex.

private long rebuildIndex(SchemaElement element) {
    E.checkArgument(element instanceof VertexLabel || element instanceof EdgeLabel || element instanceof IndexLabel, "Only VertexLabel, EdgeLabel and IndexLabel support " + "rebuild, but got '%s'", element);
    String path = String.join(PATH_SPLITOR, this.path(), element.type());
    RestResult result = this.client.put(path, element.name(), element);
    @SuppressWarnings("unchecked") Map<String, Object> task = result.readObject(Map.class);
    return TaskAPI.parseTaskId(task);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel)

Example 44 with EdgeLabel

use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.

the class EdgeLabelAPI method checkCreateOrUpdate.

@Override
protected Object checkCreateOrUpdate(SchemaElement schemaElement) {
    EdgeLabel edgeLabel = (EdgeLabel) schemaElement;
    Object el = edgeLabel;
    if (this.client.apiVersionLt("0.54")) {
        E.checkArgument(edgeLabel.ttl() == 0L && edgeLabel.ttlStartTime() == null, "Not support ttl until api version 0.54");
        el = edgeLabel.switchV53();
    }
    return el;
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel)

Aggregations

EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)44 Test (org.junit.Test)31 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)9 HugeClient (com.baidu.hugegraph.driver.HugeClient)8 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)6 ExternalException (com.baidu.hugegraph.exception.ExternalException)4 ServerException (com.baidu.hugegraph.exception.ServerException)4 Date (java.util.Date)4 RestResult (com.baidu.hugegraph.rest.RestResult)3 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)3 ArrayList (java.util.ArrayList)3 Task (com.baidu.hugegraph.structure.Task)2 BaseApiTest (com.baidu.hugegraph.api.BaseApiTest)1 EdgeLabelEntity (com.baidu.hugegraph.entity.schema.EdgeLabelEntity)1 EdgeLabelStyle (com.baidu.hugegraph.entity.schema.EdgeLabelStyle)1 Edge (com.baidu.hugegraph.structure.graph.Edge)1 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)1 HashSet (java.util.HashSet)1