Search in sources :

Example 46 with SchemaManager

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

the class RamTableTest method setup.

@Before
public void setup() {
    this.graph = HugeFactory.open(FakeObjects.newConfig());
    SchemaManager schema = this.graph.schema();
    schema.propertyKey("p3").asText().create();
    schema.vertexLabel("vl1").useCustomizeNumberId().create();
    schema.vertexLabel("vl2").useCustomizeNumberId().create();
    schema.vertexLabel("vl3").useCustomizeStringId().create();
    schema.edgeLabel("el1").sourceLabel("vl1").targetLabel("vl1").create();
    schema.edgeLabel("el2").sourceLabel("vl2").targetLabel("vl2").create();
    schema.edgeLabel("el3").sourceLabel("vl3").targetLabel("vl3").properties("p3").multiTimes().sortKeys("p3").create();
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Before(org.junit.Before)

Example 47 with SchemaManager

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

the class TestGraph method initEdgeLabelDefaultCreatedDefault.

public void initEdgeLabelDefaultCreatedDefault(String defaultVL) {
    SchemaManager schema = this.graph.schema();
    schema.edgeLabel("created").link(defaultVL, defaultVL).properties("weight", "color").nullableKeys("weight", "color").ifNotExist().create();
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager)

Example 48 with SchemaManager

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

the class TestGraph method initEdgeLabelPersonCreatedSoftware.

public void initEdgeLabelPersonCreatedSoftware() {
    SchemaManager schema = this.graph.schema();
    schema.edgeLabel("created").link("person", "software").properties("weight").nullableKeys("weight").ifNotExist().create();
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager)

Example 49 with SchemaManager

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

the class TestGraph method initEdgeLabelDefaultKnowsDefault.

public void initEdgeLabelDefaultKnowsDefault(String defaultVL) {
    SchemaManager schema = this.graph.schema();
    schema.edgeLabel("knows").link(defaultVL, defaultVL).properties("data", "test", "year", "boolean", "float", "double", "string", "integer", "long", "weight", "myEdgeId", "since", "acl", "stars", "aKey", "gremlin.partitionGraphStrategy.partition", "color").nullableKeys("data", "test", "year", "boolean", "float", "double", "string", "integer", "long", "weight", "myEdgeId", "since", "acl", "stars", "aKey", "gremlin.partitionGraphStrategy.partition", "color").ifNotExist().create();
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager)

Example 50 with SchemaManager

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

the class TestGraph method clearSchema.

@Watched
protected void clearSchema() {
    // Clear schema and graph data will be cleared at same time
    SchemaManager schema = this.graph.schema();
    schema.getIndexLabels().stream().forEach(elem -> {
        schema.indexLabel(elem.name()).remove();
    });
    schema.getEdgeLabels().stream().forEach(elem -> {
        schema.edgeLabel(elem.name()).remove();
    });
    schema.getVertexLabels().stream().forEach(elem -> {
        schema.vertexLabel(elem.name()).remove();
    });
    schema.getPropertyKeys().stream().forEach(elem -> {
        schema.propertyKey(elem.name()).remove();
    });
    TaskScheduler scheduler = this.graph.taskScheduler();
    scheduler.tasks(null, -1, null).forEachRemaining(elem -> {
        scheduler.delete(elem.id());
    });
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) TaskScheduler(com.baidu.hugegraph.task.TaskScheduler) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

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