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);
}
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();
});
}
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();
});
}
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();
}
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();
}
Aggregations