Search in sources :

Example 1 with SchemaElementMapper

use of com.alibaba.maxgraph.sdkcommon.schema.mapper.SchemaElementMapper 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.maxgraph.sdkcommon.schema.mapper.DefaultGraphSchema) VertexTypeMapper(com.alibaba.maxgraph.sdkcommon.schema.mapper.VertexTypeMapper) EdgeTypeMapper(com.alibaba.maxgraph.sdkcommon.schema.mapper.EdgeTypeMapper) GraphEdge(com.alibaba.maxgraph.compiler.api.schema.GraphEdge) SchemaElementMapper(com.alibaba.maxgraph.sdkcommon.schema.mapper.SchemaElementMapper)

Aggregations

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