Search in sources :

Example 1 with DefaultGraphSchema

use of com.alibaba.graphscope.groot.schema.mapper.DefaultGraphSchema in project GraphScope by alibaba.

the class GraphSchemaMapper method toGraphSchema.

public GraphSchema toGraphSchema() {
    DefaultGraphSchema graphSchema = new DefaultGraphSchema();
    Map<String, GraphVertex> vertexTypeMap = Maps.newHashMap();
    for (SchemaElementMapper elementMapper : this.types) {
        if (elementMapper instanceof VertexTypeMapper) {
            GraphVertex graphVertex = ((VertexTypeMapper) elementMapper).toVertexType();
            graphSchema.createVertexType(graphVertex);
            vertexTypeMap.put(graphVertex.getLabel(), graphVertex);
        }
    }
    for (SchemaElementMapper elementMapper : this.types) {
        if (elementMapper instanceof EdgeTypeMapper) {
            GraphEdge graphEdge = ((EdgeTypeMapper) elementMapper).toEdgeType(vertexTypeMap);
            graphSchema.createEdgeType(graphEdge);
        }
    }
    return graphSchema;
}
Also used : GraphVertex(com.alibaba.maxgraph.compiler.api.schema.GraphVertex) DefaultGraphSchema(com.alibaba.graphscope.groot.schema.mapper.DefaultGraphSchema) VertexTypeMapper(com.alibaba.graphscope.groot.schema.mapper.VertexTypeMapper) EdgeTypeMapper(com.alibaba.graphscope.groot.schema.mapper.EdgeTypeMapper) GraphEdge(com.alibaba.maxgraph.compiler.api.schema.GraphEdge) SchemaElementMapper(com.alibaba.graphscope.groot.schema.mapper.SchemaElementMapper)

Aggregations

DefaultGraphSchema (com.alibaba.graphscope.groot.schema.mapper.DefaultGraphSchema)1 EdgeTypeMapper (com.alibaba.graphscope.groot.schema.mapper.EdgeTypeMapper)1 SchemaElementMapper (com.alibaba.graphscope.groot.schema.mapper.SchemaElementMapper)1 VertexTypeMapper (com.alibaba.graphscope.groot.schema.mapper.VertexTypeMapper)1 GraphEdge (com.alibaba.maxgraph.compiler.api.schema.GraphEdge)1 GraphVertex (com.alibaba.maxgraph.compiler.api.schema.GraphVertex)1