2017-08-16 19:47:38 +08:00
|
|
|
/*
|
|
|
|
|
* Copyright 2017 HugeGraph Authors
|
|
|
|
|
*
|
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with this
|
|
|
|
|
* work for additional information regarding copyright ownership. The ASF
|
|
|
|
|
* licenses this file to You under the Apache License, Version 2.0 (the
|
|
|
|
|
* "License"); you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
2017-08-17 16:26:01 +08:00
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
|
* under the License.
|
2017-08-16 19:47:38 +08:00
|
|
|
*/
|
2017-08-17 16:26:01 +08:00
|
|
|
|
2017-08-16 19:47:38 +08:00
|
|
|
package com.baidu.hugegraph.tinkerpop;
|
|
|
|
|
|
2017-08-23 13:44:18 +08:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
2017-08-22 16:59:08 +08:00
|
|
|
import java.util.Iterator;
|
2017-08-23 13:44:18 +08:00
|
|
|
import java.util.List;
|
2017-08-22 16:59:08 +08:00
|
|
|
|
2017-08-16 19:47:38 +08:00
|
|
|
import org.apache.commons.configuration.Configuration;
|
|
|
|
|
import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
|
|
|
|
|
import org.apache.tinkerpop.gremlin.structure.Edge;
|
|
|
|
|
import org.apache.tinkerpop.gremlin.structure.Graph;
|
|
|
|
|
import org.apache.tinkerpop.gremlin.structure.T;
|
|
|
|
|
import org.apache.tinkerpop.gremlin.structure.Transaction;
|
|
|
|
|
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
2017-08-22 16:59:08 +08:00
|
|
|
import org.apache.tinkerpop.gremlin.structure.io.Io;
|
2017-08-16 19:47:38 +08:00
|
|
|
|
2017-08-22 16:59:08 +08:00
|
|
|
import com.baidu.hugegraph.HugeGraph;
|
2017-08-31 15:32:06 +08:00
|
|
|
import com.baidu.hugegraph.io.HugeGraphIoRegistry;
|
2017-08-22 16:59:08 +08:00
|
|
|
import com.baidu.hugegraph.schema.SchemaManager;
|
|
|
|
|
import com.baidu.hugegraph.structure.HugeFeatures;
|
|
|
|
|
import com.baidu.hugegraph.type.define.IdStrategy;
|
2017-08-16 19:47:38 +08:00
|
|
|
|
2017-08-31 15:32:06 +08:00
|
|
|
@Graph.OptIn("com.baidu.hugegraph.tinkerpop.StructureBasicSuite")
|
|
|
|
|
@Graph.OptIn("com.baidu.hugegraph.tinkerpop.ProcessStandardTest")
|
2017-12-15 17:10:43 +08:00
|
|
|
@Graph.OptIn("com.baidu.hugegraph.tinkerpop.StructurePerformanceTest")
|
|
|
|
|
@Graph.OptIn("com.baidu.hugegraph.tinkerpop.ProcessPerformanceTest")
|
2017-08-16 19:47:38 +08:00
|
|
|
public class TestGraph implements Graph {
|
|
|
|
|
|
2017-08-22 17:28:00 +08:00
|
|
|
public static final String DEFAULT_VL = "vertex";
|
|
|
|
|
|
2017-08-31 15:32:06 +08:00
|
|
|
private static volatile int id = 666;
|
|
|
|
|
|
2017-08-16 19:47:38 +08:00
|
|
|
private HugeGraph graph;
|
2017-08-25 11:57:13 +08:00
|
|
|
private String loadedGraph = null;
|
2017-11-15 15:10:25 +08:00
|
|
|
private boolean initedBackend = false;
|
2017-08-22 20:55:37 +08:00
|
|
|
private boolean isLastIdCustomized = false;
|
2017-08-29 20:24:42 +08:00
|
|
|
private boolean autoPerson = false;
|
|
|
|
|
private boolean ioTest = false;
|
2017-08-16 19:47:38 +08:00
|
|
|
|
|
|
|
|
public TestGraph(HugeGraph graph) {
|
|
|
|
|
this.graph = graph;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public HugeGraph hugeGraph() {
|
|
|
|
|
return this.graph;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-15 15:10:25 +08:00
|
|
|
protected void initBackend() {
|
|
|
|
|
this.graph.initBackend();
|
|
|
|
|
this.initedBackend = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void clearBackend() {
|
|
|
|
|
this.graph.clearBackend();
|
|
|
|
|
this.initedBackend = false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-21 21:01:40 +08:00
|
|
|
protected void clearSchema() {
|
|
|
|
|
// Clear schema and graph data will be cleared at same time
|
2017-09-22 14:52:15 +08:00
|
|
|
SchemaManager schema = this.graph.schema();
|
2017-08-21 21:01:40 +08:00
|
|
|
|
|
|
|
|
schema.getIndexLabels().stream().forEach(elem -> {
|
2017-09-22 14:52:15 +08:00
|
|
|
schema.indexLabel(elem.name()).remove();
|
2017-08-21 21:01:40 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
schema.getEdgeLabels().stream().forEach(elem -> {
|
2017-09-22 14:52:15 +08:00
|
|
|
schema.edgeLabel(elem.name()).remove();
|
2017-08-21 21:01:40 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
schema.getVertexLabels().stream().forEach(elem -> {
|
2017-09-22 14:52:15 +08:00
|
|
|
schema.vertexLabel(elem.name()).remove();
|
2017-08-21 21:01:40 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
schema.getPropertyKeys().stream().forEach(elem -> {
|
2017-09-22 14:52:15 +08:00
|
|
|
schema.propertyKey(elem.name()).remove();
|
2017-08-21 21:01:40 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-22 14:52:15 +08:00
|
|
|
protected void clearVariables() {
|
|
|
|
|
Variables variables = this.variables();
|
|
|
|
|
variables.keys().forEach(key -> variables.remove(key));
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-16 19:47:38 +08:00
|
|
|
@Override
|
|
|
|
|
public Vertex addVertex(Object... keyValues) {
|
2017-08-23 13:44:18 +08:00
|
|
|
boolean needRedefineSchema = false;
|
|
|
|
|
boolean hasId = false;
|
2017-08-22 17:28:00 +08:00
|
|
|
IdStrategy idStrategy = IdStrategy.AUTOMATIC;
|
|
|
|
|
String defaultVL = DEFAULT_VL;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < keyValues.length; i += 2) {
|
2017-08-23 19:40:32 +08:00
|
|
|
if(keyValues[i] == null){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 13:44:18 +08:00
|
|
|
if (keyValues[i].equals(T.id)) {
|
|
|
|
|
hasId = true;
|
|
|
|
|
if (!this.isLastIdCustomized) {
|
|
|
|
|
needRedefineSchema = true;
|
|
|
|
|
idStrategy = IdStrategy.CUSTOMIZE;
|
|
|
|
|
}
|
2017-08-22 20:55:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keyValues[i].equals(T.label) &&
|
2017-08-23 19:40:32 +08:00
|
|
|
i + 1 < keyValues.length &&
|
2017-08-22 20:55:37 +08:00
|
|
|
"person".equals(keyValues[i + 1]) &&
|
2017-08-29 20:24:42 +08:00
|
|
|
this.loadedGraph == null &&
|
|
|
|
|
!this.autoPerson) {
|
2017-08-23 13:44:18 +08:00
|
|
|
needRedefineSchema = true;
|
2017-08-22 17:28:00 +08:00
|
|
|
defaultVL = "person";
|
2017-08-21 21:01:40 +08:00
|
|
|
}
|
|
|
|
|
}
|
2017-08-22 16:23:47 +08:00
|
|
|
|
2017-08-25 11:57:13 +08:00
|
|
|
if (needRedefineSchema && this.loadedGraph == null) {
|
2017-08-22 17:28:00 +08:00
|
|
|
this.clearSchema();
|
|
|
|
|
this.tx().commit();
|
|
|
|
|
this.initBasicSchema(idStrategy, defaultVL);
|
|
|
|
|
this.tx().commit();
|
2017-08-29 20:24:42 +08:00
|
|
|
if (!this.autoPerson &&
|
|
|
|
|
defaultVL.equals("person") &&
|
|
|
|
|
idStrategy == IdStrategy.AUTOMATIC) {
|
|
|
|
|
this.autoPerson = true;
|
|
|
|
|
}
|
2017-08-22 20:55:37 +08:00
|
|
|
|
2017-08-23 13:44:18 +08:00
|
|
|
this.isLastIdCustomized = idStrategy == IdStrategy.CUSTOMIZE;
|
|
|
|
|
}
|
2017-08-25 11:57:13 +08:00
|
|
|
|
|
|
|
|
if (!hasId && (this.isLastIdCustomized || needAddIdToLoadGraph())) {
|
2017-08-23 13:44:18 +08:00
|
|
|
List<Object> kvs = new ArrayList<>(Arrays.asList(keyValues));
|
|
|
|
|
kvs.add(T.id);
|
|
|
|
|
kvs.add(String.valueOf(id++));
|
|
|
|
|
keyValues = kvs.toArray();
|
2017-08-22 17:28:00 +08:00
|
|
|
}
|
|
|
|
|
|
2017-08-18 20:31:26 +08:00
|
|
|
return this.graph.addVertex(keyValues);
|
2017-08-16 19:47:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Iterator<Vertex> vertices(Object... vertexIds) {
|
|
|
|
|
return this.graph.vertices(vertexIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Iterator<Edge> edges(Object... edgeIds) {
|
|
|
|
|
return this.graph.edges(edgeIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Transaction tx() {
|
|
|
|
|
return this.graph.tx();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void close() throws Exception {
|
|
|
|
|
this.graph.close();
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-25 11:57:13 +08:00
|
|
|
@Override
|
|
|
|
|
public <C extends GraphComputer> C compute(Class<C> graphComputerClass)
|
|
|
|
|
throws IllegalArgumentException {
|
|
|
|
|
return this.graph.compute(graphComputerClass);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public GraphComputer compute() throws IllegalArgumentException {
|
|
|
|
|
return this.graph.compute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
|
|
@Override
|
|
|
|
|
public <I extends Io> I io(final Io.Builder<I> builder) {
|
|
|
|
|
return (I) builder.graph(this).onMapper(mapper ->
|
2017-08-31 15:32:06 +08:00
|
|
|
mapper.addRegistry(HugeGraphIoRegistry.getInstance())
|
|
|
|
|
).create();
|
2017-08-25 11:57:13 +08:00
|
|
|
}
|
|
|
|
|
|
2017-08-16 19:47:38 +08:00
|
|
|
@Override
|
|
|
|
|
public Variables variables() {
|
|
|
|
|
return this.graph.variables();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Configuration configuration() {
|
|
|
|
|
return this.graph.configuration();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public HugeFeatures features() {
|
|
|
|
|
return this.graph.features();
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-22 20:55:37 +08:00
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|
return this.graph.toString();
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-25 11:57:13 +08:00
|
|
|
public void loadedGraph(String loadedGraph) {
|
2017-08-16 19:47:38 +08:00
|
|
|
this.loadedGraph = loadedGraph;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-25 11:57:13 +08:00
|
|
|
public String loadedGraph() {
|
|
|
|
|
return this.loadedGraph;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-15 15:10:25 +08:00
|
|
|
public boolean initedBackend() {
|
|
|
|
|
return this.initedBackend;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-29 20:24:42 +08:00
|
|
|
public void autoPerson(Boolean autoPerson) {
|
|
|
|
|
this.autoPerson = autoPerson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ioTest(Boolean ioTest) {
|
|
|
|
|
this.ioTest = ioTest;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-22 20:55:37 +08:00
|
|
|
public void isLastIdCustomized(boolean isLastIdCustomized) {
|
|
|
|
|
this.isLastIdCustomized = isLastIdCustomized;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-25 11:57:13 +08:00
|
|
|
private boolean needAddIdToLoadGraph() {
|
2017-09-13 20:38:17 +08:00
|
|
|
if (this.graph.name().endsWith("standard") ||
|
|
|
|
|
this.loadedGraph == null) {
|
2017-08-25 11:57:13 +08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
switch (this.loadedGraph) {
|
|
|
|
|
case "gryo":
|
|
|
|
|
case "graphsonv2d0":
|
|
|
|
|
return true;
|
|
|
|
|
case "graphml":
|
|
|
|
|
case "graphsonv1d0":
|
|
|
|
|
case "regularLoad":
|
|
|
|
|
return false;
|
|
|
|
|
default:
|
|
|
|
|
throw new AssertionError(String.format(
|
|
|
|
|
"Wrong IO type %s", this.loadedGraph));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 19:40:32 +08:00
|
|
|
public void initPropertyKey(String key, String type) {
|
|
|
|
|
SchemaManager schema = this.graph.schema();
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case "Boolean":
|
|
|
|
|
schema.propertyKey(key).asBoolean().ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "Integer":
|
|
|
|
|
schema.propertyKey(key).asInt().ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "Long":
|
|
|
|
|
schema.propertyKey(key).asLong().ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "Float":
|
|
|
|
|
schema.propertyKey(key).asFloat().ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "Double":
|
|
|
|
|
schema.propertyKey(key).asDouble().ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "String":
|
|
|
|
|
schema.propertyKey(key).ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "IntegerArray":
|
|
|
|
|
schema.propertyKey(key).asInt().valueList()
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "LongArray":
|
|
|
|
|
schema.propertyKey(key).asLong().valueList()
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "FloatArray":
|
|
|
|
|
schema.propertyKey(key).asFloat().valueList()
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "DoubleArray":
|
|
|
|
|
schema.propertyKey(key).asDouble().valueList()
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "StringArray":
|
|
|
|
|
schema.propertyKey(key).valueList().ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "UniformList":
|
|
|
|
|
schema.propertyKey(key).valueList().ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case "MixedList":
|
|
|
|
|
case "Map":
|
|
|
|
|
case "Serializable":
|
2017-08-29 20:24:42 +08:00
|
|
|
break;
|
2017-08-23 19:40:32 +08:00
|
|
|
default:
|
|
|
|
|
throw new RuntimeException(
|
|
|
|
|
String.format("Wrong type %s for %s", type, key));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-16 19:47:38 +08:00
|
|
|
public void initGratefulSchema() {
|
|
|
|
|
SchemaManager schema = this.graph.schema();
|
|
|
|
|
|
|
|
|
|
schema.propertyKey("id").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("weight").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("name").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("songType").asText().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("performances").asInt().ifNotExist().create();
|
|
|
|
|
|
2017-09-13 20:38:17 +08:00
|
|
|
IdStrategy idStrategy = this.graph.name().endsWith("standard") ?
|
2017-08-25 11:57:13 +08:00
|
|
|
IdStrategy.AUTOMATIC : IdStrategy.CUSTOMIZE;
|
|
|
|
|
switch (idStrategy) {
|
|
|
|
|
case AUTOMATIC:
|
|
|
|
|
schema.vertexLabel("song")
|
|
|
|
|
.properties("id", "name", "songType", "performances")
|
2017-09-11 16:37:01 +08:00
|
|
|
.nullableKeys("id", "name", "songType", "performances")
|
2017-08-25 11:57:13 +08:00
|
|
|
.ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("artist")
|
|
|
|
|
.properties("id", "name")
|
|
|
|
|
.nullableKeys("id", "name")
|
2017-08-25 11:57:13 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case CUSTOMIZE:
|
|
|
|
|
schema.vertexLabel("song")
|
|
|
|
|
.properties("id", "name", "songType", "performances")
|
2017-09-11 16:37:01 +08:00
|
|
|
.nullableKeys("id", "name", "songType", "performances")
|
2017-08-25 11:57:13 +08:00
|
|
|
.useCustomizeId().ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("artist")
|
|
|
|
|
.properties("id", "name")
|
|
|
|
|
.nullableKeys("id", "name")
|
2017-08-25 11:57:13 +08:00
|
|
|
.useCustomizeId().ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new AssertionError(String.format(
|
|
|
|
|
"Id strategy must be customize or automatic"));
|
|
|
|
|
}
|
2017-08-16 19:47:38 +08:00
|
|
|
|
|
|
|
|
schema.edgeLabel("followedBy")
|
2017-09-11 16:37:01 +08:00
|
|
|
.link("song", "song")
|
|
|
|
|
.properties("weight")
|
|
|
|
|
.nullableKeys("weight")
|
2017-08-16 19:47:38 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("sungBy").link("song", "artist")
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("writtenBy").link("song", "artist")
|
|
|
|
|
.ifNotExist().create();
|
2017-09-04 21:25:45 +08:00
|
|
|
|
|
|
|
|
schema.indexLabel("songByName").onV("song").by("name")
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("songBySongType").onV("song").by("songType")
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("songByPerf").onV("song").by("performances")
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("artistByName").onV("artist").by("name")
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("followedByByWeight").onE("followedBy").by("weight")
|
|
|
|
|
.search().ifNotExist().create();
|
2017-08-16 19:47:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void initModernSchema() {
|
|
|
|
|
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();
|
2017-08-29 20:24:42 +08:00
|
|
|
schema.propertyKey("acl").ifNotExist().create();
|
2017-08-31 19:47:25 +08:00
|
|
|
schema.propertyKey("temp").ifNotExist().create();
|
2017-09-15 11:45:37 +08:00
|
|
|
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();
|
|
|
|
|
|
2017-08-16 19:47:38 +08:00
|
|
|
|
2017-09-13 20:38:17 +08:00
|
|
|
IdStrategy idStrategy = this.graph.name().endsWith("standard") ?
|
2017-08-25 11:57:13 +08:00
|
|
|
IdStrategy.AUTOMATIC : IdStrategy.CUSTOMIZE;
|
|
|
|
|
switch (idStrategy) {
|
|
|
|
|
case AUTOMATIC:
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("person")
|
|
|
|
|
.properties("name", "age")
|
|
|
|
|
.nullableKeys("name", "age")
|
2017-08-25 11:57:13 +08:00
|
|
|
.ifNotExist().create();
|
2017-08-31 19:47:25 +08:00
|
|
|
schema.vertexLabel("software")
|
|
|
|
|
.properties("name", "lang", "temp")
|
2017-09-11 16:37:01 +08:00
|
|
|
.nullableKeys("name", "lang", "temp")
|
2017-08-25 11:57:13 +08:00
|
|
|
.ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("dog")
|
|
|
|
|
.properties("name")
|
|
|
|
|
.nullableKeys("name")
|
2017-08-25 11:57:13 +08:00
|
|
|
.ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel(DEFAULT_VL)
|
|
|
|
|
.properties("name", "age")
|
|
|
|
|
.nullableKeys("name", "age")
|
2017-08-25 11:57:13 +08:00
|
|
|
.ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("animal")
|
2017-09-15 11:45:37 +08:00
|
|
|
.properties("name", "age", "peter", "josh", "marko",
|
|
|
|
|
"vadas", "ripple", "lop")
|
|
|
|
|
.nullableKeys("name", "age", "peter", "josh", "marko",
|
|
|
|
|
"vadas", "ripple", "lop")
|
2017-08-31 19:47:25 +08:00
|
|
|
.ifNotExist().create();
|
2017-08-25 11:57:13 +08:00
|
|
|
break;
|
|
|
|
|
case CUSTOMIZE:
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("person")
|
|
|
|
|
.properties("name", "age")
|
|
|
|
|
.nullableKeys("name", "age")
|
2017-08-25 11:57:13 +08:00
|
|
|
.useCustomizeId().ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("software")
|
|
|
|
|
.properties("name", "lang")
|
|
|
|
|
.nullableKeys("name", "lang")
|
2017-08-25 11:57:13 +08:00
|
|
|
.useCustomizeId().ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("dog")
|
|
|
|
|
.properties("name")
|
|
|
|
|
.nullableKeys("name")
|
2017-08-25 11:57:13 +08:00
|
|
|
.useCustomizeId().ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel(DEFAULT_VL)
|
|
|
|
|
.properties("name", "age")
|
|
|
|
|
.nullableKeys("name", "age")
|
2017-08-25 11:57:13 +08:00
|
|
|
.useCustomizeId().ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("animal")
|
|
|
|
|
.properties("name", "age")
|
|
|
|
|
.nullableKeys("name", "age")
|
2017-08-31 19:47:25 +08:00
|
|
|
.useCustomizeId().ifNotExist().create();
|
2017-08-25 11:57:13 +08:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new AssertionError(String.format(
|
|
|
|
|
"Id strategy must be customize or automatic"));
|
|
|
|
|
}
|
2017-08-31 19:47:25 +08:00
|
|
|
|
2017-08-16 19:47:38 +08:00
|
|
|
schema.edgeLabel("knows").link("person", "person")
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("weight", "year")
|
|
|
|
|
.nullableKeys("weight", "year")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-16 19:47:38 +08:00
|
|
|
schema.edgeLabel("created").link("person", "software")
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("weight")
|
|
|
|
|
.nullableKeys("weight")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-29 20:24:42 +08:00
|
|
|
schema.edgeLabel("codeveloper").link("person", "person")
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("year")
|
|
|
|
|
.nullableKeys("year")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-29 20:24:42 +08:00
|
|
|
schema.edgeLabel("createdBy").link("software", "person")
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("weight", "year", "acl")
|
|
|
|
|
.nullableKeys("weight", "year", "acl")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-31 19:47:25 +08:00
|
|
|
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();
|
2017-08-29 20:24:42 +08:00
|
|
|
|
2017-08-31 19:47:25 +08:00
|
|
|
schema.indexLabel("personByName").onV("person").by("name")
|
2017-08-29 20:24:42 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("personByAge").onV("person").by("age").search()
|
|
|
|
|
.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").search()
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("knowsByWeight").onE("knows").by("weight").search()
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("createdByWeight").onE("created").by("weight")
|
2017-08-31 19:47:25 +08:00
|
|
|
.search().ifNotExist().create();
|
|
|
|
|
schema.indexLabel("personByNameAge").onV("person").by("name", "age")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-16 19:47:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void initClassicSchema() {
|
|
|
|
|
SchemaManager schema = this.graph.schema();
|
|
|
|
|
|
|
|
|
|
schema.propertyKey("id").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("weight").asFloat().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("name").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("lang").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("age").asInt().ifNotExist().create();
|
|
|
|
|
|
2017-09-13 20:38:17 +08:00
|
|
|
IdStrategy idStrategy = this.graph.name().endsWith("standard") ?
|
2017-08-25 11:57:13 +08:00
|
|
|
IdStrategy.AUTOMATIC : IdStrategy.CUSTOMIZE;
|
|
|
|
|
switch (idStrategy) {
|
|
|
|
|
case AUTOMATIC:
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("vertex")
|
|
|
|
|
.properties("id", "name", "age", "lang")
|
|
|
|
|
.nullableKeys("id", "name", "age", "lang")
|
2017-08-25 11:57:13 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case CUSTOMIZE:
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("vertex")
|
|
|
|
|
.properties("id", "name", "age", "lang")
|
|
|
|
|
.nullableKeys("id", "name", "age", "lang")
|
2017-08-25 11:57:13 +08:00
|
|
|
.useCustomizeId().ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new AssertionError(String.format(
|
|
|
|
|
"Id strategy must be customize or automatic"));
|
|
|
|
|
}
|
2017-08-16 19:47:38 +08:00
|
|
|
|
|
|
|
|
schema.edgeLabel("knows").link("vertex", "vertex")
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("weight")
|
|
|
|
|
.nullableKeys("weight")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-16 19:47:38 +08:00
|
|
|
schema.edgeLabel("created").link("vertex", "vertex")
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("weight")
|
|
|
|
|
.nullableKeys("weight")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-29 20:24:42 +08:00
|
|
|
|
2017-09-15 11:45:37 +08:00
|
|
|
schema.indexLabel("vertexByAge").onV("vertex").by("age").search()
|
|
|
|
|
.ifNotExist().create();
|
2017-08-16 19:47:38 +08:00
|
|
|
}
|
|
|
|
|
|
2017-08-22 17:28:00 +08:00
|
|
|
public void initBasicSchema(IdStrategy idStrategy, String defaultVL) {
|
2017-08-21 21:01:40 +08:00
|
|
|
this.initBasicPropertyKey();
|
2017-08-22 17:28:00 +08:00
|
|
|
this.initBasicVertexLabelV(idStrategy, defaultVL);
|
|
|
|
|
this.initBasicVertexLabelAndEdgeLabelExceptV(defaultVL);
|
2017-08-21 21:01:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initBasicPropertyKey() {
|
2017-08-16 19:47:38 +08:00
|
|
|
SchemaManager schema = this.graph.schema();
|
|
|
|
|
|
2017-08-29 20:24:42 +08:00
|
|
|
schema.propertyKey("__id").ifNotExist().create();
|
2017-08-16 19:47:38 +08:00
|
|
|
schema.propertyKey("oid").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("communityIndex").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("test").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("testing").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("data").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("name").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("location").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("status").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("boolean").asBoolean().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("float").asFloat().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("since").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("double").asDouble().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("string").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("integer").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("long").asLong().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("x").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("y").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("age").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("lang").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("some").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("that").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("any").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("this").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("year").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("xxx").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("yyy").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("favoriteColor").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("uuid").asUuid().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("myId").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("myEdgeId").asInt().ifNotExist().create();
|
2017-08-18 20:31:26 +08:00
|
|
|
schema.propertyKey("state").ifNotExist().create();
|
2017-08-22 16:23:47 +08:00
|
|
|
schema.propertyKey("acl").ifNotExist().create();
|
2017-08-23 19:40:32 +08:00
|
|
|
schema.propertyKey("stars").asInt().ifNotExist().create();
|
2017-08-25 11:57:13 +08:00
|
|
|
schema.propertyKey("aKey").asDouble().ifNotExist().create();
|
2017-08-24 15:10:09 +08:00
|
|
|
schema.propertyKey("b").asBoolean().ifNotExist().create();
|
2017-08-29 20:24:42 +08:00
|
|
|
schema.propertyKey("s").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("n").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("d").asDouble().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("f").asFloat().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("i").asInt().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("l").asLong().ifNotExist().create();
|
2017-08-31 19:47:25 +08:00
|
|
|
schema.propertyKey("here").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("to-change").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("to-remove").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("to-keep").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("to-drop").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("dropped").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("not-dropped").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("old").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("new").ifNotExist().create();
|
2017-09-15 11:45:37 +08:00
|
|
|
schema.propertyKey("color").ifNotExist().create();
|
2017-09-15 18:23:50 +08:00
|
|
|
schema.propertyKey("every").ifNotExist().create();
|
|
|
|
|
schema.propertyKey("gremlin.partitionGraphStrategy.partition")
|
|
|
|
|
.ifNotExist().create();
|
2017-11-15 15:10:25 +08:00
|
|
|
schema.propertyKey("blah").asDouble().ifNotExist().create();
|
|
|
|
|
schema.propertyKey("bloop").asInt().ifNotExist().create();
|
2017-09-15 18:23:50 +08:00
|
|
|
|
2017-08-29 20:24:42 +08:00
|
|
|
|
|
|
|
|
if (this.ioTest) {
|
|
|
|
|
schema.propertyKey("weight").asFloat().ifNotExist().create();
|
|
|
|
|
} else {
|
|
|
|
|
schema.propertyKey("weight").asDouble().ifNotExist().create();
|
|
|
|
|
}
|
2017-08-21 21:01:40 +08:00
|
|
|
}
|
|
|
|
|
|
2017-08-22 17:28:00 +08:00
|
|
|
private void initBasicVertexLabelV(IdStrategy idStrategy,
|
|
|
|
|
String defaultVL) {
|
2017-08-21 21:01:40 +08:00
|
|
|
SchemaManager schema = this.graph.schema();
|
|
|
|
|
switch (idStrategy) {
|
|
|
|
|
case CUSTOMIZE:
|
2017-08-22 16:23:47 +08:00
|
|
|
schema.vertexLabel(defaultVL)
|
|
|
|
|
.properties("__id", "oid", "name", "state", "status",
|
2017-08-24 15:10:09 +08:00
|
|
|
"some", "that", "any", "this", "lang", "b",
|
|
|
|
|
"communityIndex", "test", "testing", "acl",
|
2017-08-21 21:01:40 +08:00
|
|
|
"favoriteColor", "aKey", "age", "boolean",
|
|
|
|
|
"float", "double", "string", "integer",
|
2017-08-29 20:24:42 +08:00
|
|
|
"long", "myId", "location", "x", "y", "s",
|
2017-08-31 19:47:25 +08:00
|
|
|
"n", "d", "f", "i", "l", "to-change",
|
2017-11-15 15:10:25 +08:00
|
|
|
"to-remove", "to-keep", "old", "new",
|
|
|
|
|
"gremlin.partitionGraphStrategy.partition",
|
|
|
|
|
"color", "blah")
|
2017-09-11 16:37:01 +08:00
|
|
|
.nullableKeys("__id", "oid", "name", "state", "status",
|
|
|
|
|
"some", "that", "any", "this", "lang", "b",
|
|
|
|
|
"communityIndex", "test", "testing", "acl",
|
|
|
|
|
"favoriteColor", "aKey", "age", "boolean",
|
|
|
|
|
"float", "double", "string", "integer",
|
|
|
|
|
"long", "myId", "location", "x", "y", "s",
|
|
|
|
|
"n", "d", "f", "i", "l", "to-change",
|
2017-09-15 11:45:37 +08:00
|
|
|
"to-remove", "to-keep", "old", "new",
|
2017-09-15 18:23:50 +08:00
|
|
|
"gremlin.partitionGraphStrategy.partition",
|
2017-11-15 15:10:25 +08:00
|
|
|
"color", "blah")
|
2017-08-21 21:01:40 +08:00
|
|
|
.useCustomizeId().ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
case AUTOMATIC:
|
2017-08-22 16:23:47 +08:00
|
|
|
schema.vertexLabel(defaultVL)
|
|
|
|
|
.properties("__id", "oid", "name", "state", "status",
|
2017-08-24 15:10:09 +08:00
|
|
|
"some", "that", "any", "this", "lang", "b",
|
|
|
|
|
"communityIndex", "test", "testing", "acl",
|
2017-08-21 21:01:40 +08:00
|
|
|
"favoriteColor", "aKey", "age", "boolean",
|
|
|
|
|
"float", "double", "string", "integer",
|
2017-08-29 20:24:42 +08:00
|
|
|
"long", "myId", "location", "x", "y", "s",
|
2017-08-31 19:47:25 +08:00
|
|
|
"n", "d", "f", "i", "l", "to-change",
|
2017-11-15 15:10:25 +08:00
|
|
|
"to-remove", "to-keep", "old", "new",
|
|
|
|
|
"gremlin.partitionGraphStrategy.partition",
|
|
|
|
|
"color", "blah")
|
2017-09-11 16:37:01 +08:00
|
|
|
.nullableKeys("__id", "oid", "name", "state", "status",
|
|
|
|
|
"some", "that", "any", "this", "lang", "b",
|
|
|
|
|
"communityIndex", "test", "testing", "acl",
|
|
|
|
|
"favoriteColor", "aKey", "age", "boolean",
|
|
|
|
|
"float", "double", "string", "integer",
|
|
|
|
|
"long", "myId", "location", "x", "y", "s",
|
|
|
|
|
"n", "d", "f", "i", "l", "to-change",
|
2017-09-15 11:45:37 +08:00
|
|
|
"to-remove", "to-keep", "old", "new",
|
2017-09-15 18:23:50 +08:00
|
|
|
"gremlin.partitionGraphStrategy.partition",
|
2017-11-15 15:10:25 +08:00
|
|
|
"color", "blah")
|
2017-08-21 21:01:40 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new AssertionError("Only customize and automatic " +
|
|
|
|
|
"is legal in tinkerpop tests");
|
|
|
|
|
}
|
2017-08-29 20:24:42 +08:00
|
|
|
|
2017-09-15 11:45:37 +08:00
|
|
|
schema.indexLabel("defaultVLBy__id").onV(defaultVL).by("__id")
|
2017-08-29 20:24:42 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("defaultVLByName").onV(defaultVL).by("name")
|
2017-09-15 11:45:37 +08:00
|
|
|
.ifNotExist().create();
|
2017-08-21 21:01:40 +08:00
|
|
|
}
|
|
|
|
|
|
2017-08-22 17:28:00 +08:00
|
|
|
private void initBasicVertexLabelAndEdgeLabelExceptV(String defaultVL) {
|
2017-08-21 21:01:40 +08:00
|
|
|
SchemaManager schema = this.graph.schema();
|
2017-08-16 19:47:38 +08:00
|
|
|
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("person")
|
|
|
|
|
.properties("name")
|
|
|
|
|
.nullableKeys("name")
|
2017-08-22 16:23:47 +08:00
|
|
|
.ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.vertexLabel("thing")
|
|
|
|
|
.properties("here")
|
|
|
|
|
.nullableKeys("here")
|
2017-08-31 19:47:25 +08:00
|
|
|
.ifNotExist().create();
|
2017-08-16 19:47:38 +08:00
|
|
|
|
2017-08-22 16:23:47 +08:00
|
|
|
schema.edgeLabel("self").link(defaultVL, defaultVL)
|
2017-08-31 19:47:25 +08:00
|
|
|
.properties("__id", "test", "name", "some", "acl", "weight",
|
|
|
|
|
"here", "to-change", "dropped", "not-dropped", "new",
|
|
|
|
|
"to-drop")
|
2017-09-11 16:37:01 +08:00
|
|
|
.nullableKeys("__id", "test", "name", "some", "acl", "weight",
|
|
|
|
|
"here", "to-change", "dropped", "not-dropped",
|
|
|
|
|
"new", "to-drop")
|
2017-08-22 16:23:47 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("aTOa").link(defaultVL, defaultVL)
|
2017-09-15 18:23:50 +08:00
|
|
|
.properties("gremlin.partitionGraphStrategy.partition")
|
|
|
|
|
.nullableKeys("gremlin.partitionGraphStrategy.partition")
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("aTOb").link(defaultVL, defaultVL)
|
|
|
|
|
.properties("gremlin.partitionGraphStrategy.partition")
|
|
|
|
|
.nullableKeys("gremlin.partitionGraphStrategy.partition")
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("bTOc").link(defaultVL, defaultVL)
|
|
|
|
|
.properties("gremlin.partitionGraphStrategy.partition")
|
|
|
|
|
.nullableKeys("gremlin.partitionGraphStrategy.partition")
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("aTOc").link(defaultVL, defaultVL)
|
|
|
|
|
.properties("gremlin.partitionGraphStrategy.partition")
|
|
|
|
|
.nullableKeys("gremlin.partitionGraphStrategy.partition")
|
2017-08-22 16:23:47 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("connectsTo").link(defaultVL, defaultVL)
|
2017-09-15 18:23:50 +08:00
|
|
|
.properties("gremlin.partitionGraphStrategy.partition", "every")
|
|
|
|
|
.nullableKeys("gremlin.partitionGraphStrategy.partition", "every")
|
2017-08-22 16:23:47 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("knows").link(defaultVL, defaultVL)
|
2017-08-16 19:47:38 +08:00
|
|
|
.properties("data", "test", "year", "boolean", "float",
|
2017-08-24 15:10:09 +08:00
|
|
|
"double", "string", "integer", "long", "weight",
|
2017-09-15 18:23:50 +08:00
|
|
|
"myEdgeId", "since", "acl", "stars", "aKey",
|
|
|
|
|
"gremlin.partitionGraphStrategy.partition")
|
2017-09-11 16:37:01 +08:00
|
|
|
.nullableKeys("data", "test", "year", "boolean", "float",
|
|
|
|
|
"double", "string", "integer", "long", "weight",
|
2017-09-15 18:23:50 +08:00
|
|
|
"myEdgeId", "since", "acl", "stars", "aKey",
|
|
|
|
|
"gremlin.partitionGraphStrategy.partition")
|
2017-08-16 19:47:38 +08:00
|
|
|
.ifNotExist().create();
|
2017-08-22 16:23:47 +08:00
|
|
|
schema.edgeLabel("test").link(defaultVL, defaultVL)
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("test", "xxx", "yyy")
|
|
|
|
|
.nullableKeys("test", "xxx", "yyy")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-22 16:23:47 +08:00
|
|
|
schema.edgeLabel("friend").link(defaultVL, defaultVL)
|
2017-11-15 15:10:25 +08:00
|
|
|
.properties("name", "location", "status", "uuid", "weight",
|
|
|
|
|
"acl", "bloop")
|
2017-09-11 16:37:01 +08:00
|
|
|
.nullableKeys("name", "location", "status", "uuid", "weight",
|
2017-11-15 15:10:25 +08:00
|
|
|
"acl", "bloop")
|
2017-08-18 20:31:26 +08:00
|
|
|
.ifNotExist().create();
|
2017-08-22 16:23:47 +08:00
|
|
|
schema.edgeLabel("pets").link(defaultVL, defaultVL).ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.edgeLabel("walks").link(defaultVL, defaultVL)
|
|
|
|
|
.properties("location")
|
|
|
|
|
.nullableKeys("location")
|
2017-08-22 16:23:47 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("livesWith").link(defaultVL, defaultVL).ifNotExist().create();
|
2017-08-24 15:10:09 +08:00
|
|
|
schema.edgeLabel("friends").link(defaultVL, defaultVL)
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("weight")
|
|
|
|
|
.nullableKeys("weight")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-22 16:23:47 +08:00
|
|
|
schema.edgeLabel("collaborator").link(defaultVL, defaultVL)
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("location")
|
|
|
|
|
.nullableKeys("location")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-22 16:23:47 +08:00
|
|
|
schema.edgeLabel("hate").link(defaultVL, defaultVL)
|
|
|
|
|
.ifNotExist().create();
|
2017-08-22 20:55:37 +08:00
|
|
|
schema.edgeLabel("hates").link(defaultVL, defaultVL)
|
|
|
|
|
.ifNotExist().create();
|
2017-08-22 16:23:47 +08:00
|
|
|
schema.edgeLabel("test1").link(defaultVL, defaultVL)
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("link").link(defaultVL, defaultVL)
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("test2").link(defaultVL, defaultVL)
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("test3").link(defaultVL, defaultVL)
|
2017-08-18 20:31:26 +08:00
|
|
|
.ifNotExist().create();
|
2017-09-11 16:37:01 +08:00
|
|
|
schema.edgeLabel("l").link(defaultVL, defaultVL)
|
|
|
|
|
.properties("name")
|
|
|
|
|
.nullableKeys("name")
|
2017-08-24 15:10:09 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("CONTROL").link(defaultVL, defaultVL)
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("SELFLOOP").link(defaultVL, defaultVL)
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.edgeLabel("edge").link(defaultVL, defaultVL)
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("weight")
|
|
|
|
|
.nullableKeys("weight")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-24 15:10:09 +08:00
|
|
|
schema.edgeLabel("created").link(defaultVL, defaultVL)
|
2017-09-11 16:37:01 +08:00
|
|
|
.properties("weight")
|
|
|
|
|
.nullableKeys("weight")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-29 20:24:42 +08:00
|
|
|
schema.edgeLabel("next").link(defaultVL, defaultVL)
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
|
2017-09-15 11:45:37 +08:00
|
|
|
schema.indexLabel("selfByName").onE("self").by("name")
|
2017-08-29 20:24:42 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("selfBy__id").onE("self").by("__id")
|
2017-09-15 11:45:37 +08:00
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("selfBySome").onE("self").by("some")
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("selfByThis").onV(defaultVL).by("this")
|
|
|
|
|
.ifNotExist().create();
|
|
|
|
|
schema.indexLabel("selfByAny").onV(defaultVL).by("any")
|
|
|
|
|
.ifNotExist().create();
|
2017-09-15 18:23:50 +08:00
|
|
|
schema.indexLabel("selfByGremlinPartition").onV(defaultVL)
|
|
|
|
|
.by("gremlin.partitionGraphStrategy.partition")
|
|
|
|
|
.ifNotExist().create();
|
2017-08-16 19:47:38 +08:00
|
|
|
}
|
2017-08-31 15:32:06 +08:00
|
|
|
}
|