in hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/tinkerpop/TestGraph.java [429:548]
public void initModernSchema(IdStrategy idStrategy) {
SchemaManager schema = this.graph.schema();
schema.propertyKey("weight").asDouble().ifNotExist().create();
schema.propertyKey("name").ifNotExist().create();
schema.propertyKey("lang").ifNotExist().create();
schema.propertyKey("age").asInt().ifNotExist().create();
schema.propertyKey("year").asInt().ifNotExist().create();
schema.propertyKey("acl").ifNotExist().create();
schema.propertyKey("temp").ifNotExist().create();
schema.propertyKey("peter").ifNotExist().create();
schema.propertyKey("vadas").ifNotExist().create();
schema.propertyKey("josh").ifNotExist().create();
schema.propertyKey("marko").ifNotExist().create();
schema.propertyKey("ripple").ifNotExist().create();
schema.propertyKey("lop").ifNotExist().create();
schema.propertyKey("test").ifNotExist().create();
schema.propertyKey("p").ifNotExist().create();
switch (idStrategy) {
case AUTOMATIC:
schema.vertexLabel("name")
.ifNotExist().create();
schema.vertexLabel("person")
.properties("name", "age", "test")
.nullableKeys("name", "age", "test")
.ifNotExist().create();
schema.vertexLabel("software")
.properties("name", "lang", "temp")
.nullableKeys("name", "lang", "temp")
.ifNotExist().create();
schema.vertexLabel("dog")
.properties("name")
.nullableKeys("name")
.ifNotExist().create();
schema.vertexLabel(DEFAULT_VL)
.properties("name", "age", "p")
.nullableKeys("name", "age", "p")
.ifNotExist().create();
schema.vertexLabel("animal")
.properties("name", "age", "peter", "josh", "marko",
"vadas", "ripple", "lop")
.nullableKeys("name", "age", "peter", "josh", "marko",
"vadas", "ripple", "lop")
.ifNotExist().create();
break;
case CUSTOMIZE_STRING:
schema.vertexLabel("person")
.properties("name", "age")
.nullableKeys("name", "age")
.useCustomizeStringId().ifNotExist().create();
schema.vertexLabel("software")
.properties("name", "lang")
.nullableKeys("name", "lang")
.useCustomizeStringId().ifNotExist().create();
schema.vertexLabel("dog")
.properties("name")
.nullableKeys("name")
.useCustomizeStringId().ifNotExist().create();
schema.vertexLabel(DEFAULT_VL)
.properties("name", "age", "p")
.nullableKeys("name", "age", "p")
.useCustomizeStringId().ifNotExist().create();
schema.vertexLabel("animal")
.properties("name", "age")
.nullableKeys("name", "age")
.useCustomizeStringId().ifNotExist().create();
break;
default:
throw new AssertionError("Id strategy must be customize or automatic");
}
schema.edgeLabel("knows").link("person", "person")
.properties("weight", "year")
.nullableKeys("weight", "year")
.ifNotExist().create();
schema.edgeLabel("created").link("person", "software")
.properties("weight")
.nullableKeys("weight")
.ifNotExist().create();
schema.edgeLabel("codeveloper").link("person", "person")
.properties("year")
.nullableKeys("year")
.ifNotExist().create();
schema.edgeLabel("createdBy").link("software", "person")
.properties("weight", "year", "acl")
.nullableKeys("weight", "year", "acl")
.ifNotExist().create();
schema.edgeLabel("uses").link("person", "software")
.ifNotExist().create();
schema.edgeLabel("likes").link("person", "software")
.ifNotExist().create();
schema.edgeLabel("foo").link("person", "software")
.ifNotExist().create();
schema.edgeLabel("bar").link("person", "software")
.ifNotExist().create();
schema.indexLabel("personByName").onV("person").by("name")
.ifNotExist().create();
schema.indexLabel("personByAge").onV("person").by("age").range()
.ifNotExist().create();
schema.indexLabel("softwareByName").onV("software").by("name")
.ifNotExist().create();
schema.indexLabel("softwareByLang").onV("software").by("lang")
.ifNotExist().create();
schema.indexLabel("dogByName").onV("dog").by("name")
.ifNotExist().create();
schema.indexLabel("vertexByName").onV("vertex").by("name")
.ifNotExist().create();
schema.indexLabel("vertexByAge").onV("vertex").by("age").range()
.ifNotExist().create();
schema.indexLabel("knowsByWeight").onE("knows").by("weight").range()
.ifNotExist().create();
schema.indexLabel("createdByWeight").onE("created").by("weight")
.range().ifNotExist().create();
schema.indexLabel("personByNameAge").onV("person").by("name", "age")
.ifNotExist().create();
schema.indexLabel("vertexByP").onV("vertex").by("p")
.ifNotExist().create();
}