Search in sources :

Example 86 with SchemaManager

use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.

the class IndexLabelCoreTest method testRebuildIndexLabelOfEdgeLabel.

@Test
public void testRebuildIndexLabelOfEdgeLabel() {
    super.initPropertyKeys();
    SchemaManager schema = graph().schema();
    schema.vertexLabel("author").properties("id", "name").primaryKeys("id").create();
    schema.vertexLabel("book").properties("name").primaryKeys("name").create();
    schema.edgeLabel("authored").singleTime().link("author", "book").properties("contribution").create();
    Vertex james = graph().addVertex(T.label, "author", "id", 1, "name", "James Gosling");
    Vertex java1 = graph().addVertex(T.label, "book", "name", "java-1");
    schema.indexLabel("authoredByContri").onE("authored").secondary().by("contribution").create();
    EdgeLabel authored = schema.getEdgeLabel("authored");
    Assert.assertEquals(1, authored.indexLabels().size());
    assertContainsIl(authored.indexLabels(), "authoredByContri");
    james.addEdge("authored", java1, "contribution", "test");
    graph().tx().commit();
    Edge edge = graph().traversal().E().hasLabel("authored").has("contribution", "test").next();
    Assert.assertNotNull(edge);
    schema.indexLabel("authoredByContri").rebuild();
    Assert.assertEquals(1, authored.indexLabels().size());
    assertContainsIl(authored.indexLabels(), "authoredByContri");
    edge = graph().traversal().E().hasLabel("authored").has("contribution", "test").next();
    Assert.assertNotNull(edge);
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) EdgeLabel(com.baidu.hugegraph.schema.EdgeLabel) SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Edge(org.apache.tinkerpop.gremlin.structure.Edge) Test(org.junit.Test)

Example 87 with SchemaManager

use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.

the class IndexLabelCoreTest method testAddIndexLabelByUndefinedProperty.

@Test
public void testAddIndexLabelByUndefinedProperty() {
    super.initPropertyKeys();
    SchemaManager schema = graph().schema();
    schema.vertexLabel("author").properties("id", "name").primaryKeys("id").create();
    schema.vertexLabel("book").properties("name").primaryKeys("name").create();
    schema.edgeLabel("authored").singleTime().link("author", "book").properties("contribution").create();
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        schema.indexLabel("authorByData").onV("author").by("undefined-property").secondary().create();
    });
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        schema.indexLabel("authoredByData").onE("authored").by("undefined-property").secondary().create();
    });
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 88 with SchemaManager

use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.

the class IndexLabelCoreTest method testAddIndexLabelWithFieldsContainSameProp.

@Test
public void testAddIndexLabelWithFieldsContainSameProp() {
    super.initPropertyKeys();
    SchemaManager schema = graph().schema();
    schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        schema.indexLabel("personByAgeAndCity").onV("person").secondary().by("age", "city", "age").create();
    });
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 89 with SchemaManager

use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.

the class IndexLabelCoreTest method testRemoveNotExistIndexLabel.

@Test
public void testRemoveNotExistIndexLabel() {
    SchemaManager schema = graph().schema();
    schema.indexLabel("not-exist-il").remove();
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 90 with SchemaManager

use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.

the class PropertyCoreTest method initSchema.

@Before
public void initSchema() {
    SchemaManager schema = graph().schema();
    schema.propertyKey("id").asInt().create();
    schema.propertyKey("string").asText().create();
    schema.propertyKey("bool").asBoolean().create();
    schema.propertyKey("byte").asByte().create();
    schema.propertyKey("int").asInt().create();
    schema.propertyKey("long").asLong().create();
    schema.propertyKey("float").asFloat().create();
    schema.propertyKey("double").asDouble().create();
    schema.propertyKey("blob").asBlob().create();
    schema.propertyKey("time").asDate().create();
    schema.propertyKey("uuid").asUUID().create();
    schema.propertyKey("list_string").asText().valueList().create();
    schema.propertyKey("list_bool").asBoolean().valueList().create();
    schema.propertyKey("list_byte").asByte().valueList().create();
    schema.propertyKey("list_int").asInt().valueList().create();
    schema.propertyKey("list_long").asLong().valueList().create();
    schema.propertyKey("list_float").asFloat().valueList().create();
    schema.propertyKey("list_double").asDouble().valueList().create();
    schema.propertyKey("list_blob").asBlob().valueList().create();
    schema.propertyKey("list_time").asDate().valueList().create();
    schema.propertyKey("list_uuid").asUUID().valueList().create();
    schema.propertyKey("set_string").asText().valueSet().create();
    schema.propertyKey("set_bool").asBoolean().valueSet().create();
    schema.propertyKey("set_byte").asByte().valueSet().create();
    schema.propertyKey("set_int").asInt().valueSet().create();
    schema.propertyKey("set_long").asLong().valueSet().create();
    schema.propertyKey("set_float").asFloat().valueSet().create();
    schema.propertyKey("set_double").asDouble().valueSet().create();
    schema.propertyKey("set_blob").asBlob().valueSet().create();
    schema.propertyKey("set_time").asDate().valueSet().create();
    schema.propertyKey("set_uuid").asUUID().valueSet().create();
    schema.vertexLabel("person").properties("id", "string", "bool", "byte", "int", "long", "float", "double", "time", "uuid", "blob", "list_string", "list_bool", "list_byte", "list_int", "list_long", "list_float", "list_double", "list_time", "list_uuid", "list_blob", "set_string", "set_bool", "set_byte", "set_int", "set_long", "set_float", "set_double", "set_time", "set_uuid", "set_blob").nullableKeys("string", "bool", "byte", "int", "long", "float", "double", "time", "uuid", "blob", "list_string", "list_bool", "list_byte", "list_int", "list_long", "list_float", "list_double", "list_time", "list_uuid", "list_blob", "set_string", "set_bool", "set_byte", "set_int", "set_long", "set_float", "set_double", "set_time", "set_uuid", "set_blob").primaryKeys("id").create();
    schema.edgeLabel("transfer").properties("id", "string", "bool", "byte", "int", "long", "float", "double", "time", "uuid", "blob", "list_string", "list_bool", "list_byte", "list_int", "list_long", "list_float", "list_double", "list_time", "list_uuid", "list_blob", "set_string", "set_bool", "set_byte", "set_int", "set_long", "set_float", "set_double", "set_time", "set_uuid", "set_blob").nullableKeys("string", "bool", "byte", "int", "long", "float", "double", "time", "uuid", "blob", "list_string", "list_bool", "list_byte", "list_int", "list_long", "list_float", "list_double", "list_time", "list_uuid", "list_blob", "set_string", "set_bool", "set_byte", "set_int", "set_long", "set_float", "set_double", "set_time", "set_uuid", "set_blob").link("person", "person").create();
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Before(org.junit.Before)

Aggregations

SchemaManager (com.baidu.hugegraph.schema.SchemaManager)261 Test (org.junit.Test)227 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)90 HugeGraph (com.baidu.hugegraph.HugeGraph)76 FakeVertex (com.baidu.hugegraph.testutil.FakeObjects.FakeVertex)40 Edge (org.apache.tinkerpop.gremlin.structure.Edge)30 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)27 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)22 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)20 EdgeLabel (com.baidu.hugegraph.schema.EdgeLabel)19 FakeEdge (com.baidu.hugegraph.testutil.FakeObjects.FakeEdge)19 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)15 Id (com.baidu.hugegraph.backend.id.Id)12 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)8 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)7 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)7 Date (java.util.Date)6 Before (org.junit.Before)6 HashSet (java.util.HashSet)3 HugeException (com.baidu.hugegraph.HugeException)2