Search in sources :

Example 1 with GraphVertex

use of com.alibaba.maxgraph.compiler.api.schema.GraphVertex in project GraphScope by alibaba.

the class EdgeRelationMapper method toEdgeRelation.

public EdgeRelation toEdgeRelation(Map<String, GraphVertex> vertexTypeMap) {
    GraphVertex sourceGraphVertex = vertexTypeMap.get(this.srcVertexLabel);
    GraphVertex targetGraphVertex = vertexTypeMap.get(this.dstVertexLabel);
    return new DefaultEdgeRelation(sourceGraphVertex, targetGraphVertex, this.tableId);
}
Also used : GraphVertex(com.alibaba.maxgraph.compiler.api.schema.GraphVertex)

Example 2 with GraphVertex

use of com.alibaba.maxgraph.compiler.api.schema.GraphVertex 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)

Example 3 with GraphVertex

use of com.alibaba.maxgraph.compiler.api.schema.GraphVertex in project GraphScope by alibaba.

the class GraphSchemaMapper method parseFromSchema.

public static GraphSchemaMapper parseFromSchema(GraphSchema schema) {
    GraphSchemaMapper schemaMapper = new GraphSchemaMapper();
    schemaMapper.version = schema.getVersion();
    schemaMapper.types = Lists.newArrayList();
    for (GraphVertex graphVertex : schema.getVertexList()) {
        schemaMapper.types.add(VertexTypeMapper.parseFromVertexType(graphVertex));
    }
    for (GraphEdge graphEdge : schema.getEdgeList()) {
        schemaMapper.types.add(EdgeTypeMapper.parseFromEdgeType(graphEdge));
    }
    return schemaMapper;
}
Also used : GraphVertex(com.alibaba.maxgraph.compiler.api.schema.GraphVertex) GraphEdge(com.alibaba.maxgraph.compiler.api.schema.GraphEdge)

Example 4 with GraphVertex

use of com.alibaba.maxgraph.compiler.api.schema.GraphVertex in project GraphScope by alibaba.

the class MxVertexProperty method remove.

@Override
public void remove() {
    TinkerMaxGraph tinkerMaxGraph = (TinkerMaxGraph) vertex.graph();
    GraphVertex graphVertex = (GraphVertex) tinkerMaxGraph.schema().getElement(vertex.label());
    Set<String> propNameList = graphVertex.getPrimaryKeyList().stream().map(GraphProperty::getName).collect(Collectors.toSet());
    if (propNameList.contains(this.key)) {
        return;
    }
    Iterator<VertexProperty<Object>> propItor = vertex.properties();
    Map<String, Object> kvs = Maps.newHashMap();
    while (propItor.hasNext()) {
        VertexProperty<Object> prop = propItor.next();
        kvs.put(prop.key(), prop.value());
    }
    kvs.remove(this.key);
    tinkerMaxGraph.getBaseGraph().addVertex(vertex.label(), kvs);
}
Also used : GraphVertex(com.alibaba.maxgraph.compiler.api.schema.GraphVertex) TinkerMaxGraph(com.alibaba.maxgraph.structure.graph.TinkerMaxGraph) VertexProperty(org.apache.tinkerpop.gremlin.structure.VertexProperty)

Example 5 with GraphVertex

use of com.alibaba.maxgraph.compiler.api.schema.GraphVertex in project GraphScope by alibaba.

the class EdgeRelationMapper method toEdgeRelation.

public EdgeRelation toEdgeRelation(Map<String, GraphVertex> vertexTypeMap) {
    GraphVertex sourceGraphVertex = vertexTypeMap.get(this.srcVertexLabel);
    GraphVertex targetGraphVertex = vertexTypeMap.get(this.dstVertexLabel);
    return new DefaultEdgeRelation(sourceGraphVertex, targetGraphVertex, this.tableId);
}
Also used : GraphVertex(com.alibaba.maxgraph.compiler.api.schema.GraphVertex)

Aggregations

GraphVertex (com.alibaba.maxgraph.compiler.api.schema.GraphVertex)10 GraphEdge (com.alibaba.maxgraph.compiler.api.schema.GraphEdge)5 GraphProperty (com.alibaba.maxgraph.compiler.api.schema.GraphProperty)3 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 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 EdgeRelation (com.alibaba.maxgraph.compiler.api.schema.EdgeRelation)1 GraphElement (com.alibaba.maxgraph.compiler.api.schema.GraphElement)1 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)1 LogicalSourceVertex (com.alibaba.maxgraph.compiler.logical.LogicalSourceVertex)1 LogicalSubQueryPlan (com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)1 VertexIdManager (com.alibaba.maxgraph.compiler.logical.VertexIdManager)1 ProcessorSourceFunction (com.alibaba.maxgraph.compiler.logical.function.ProcessorSourceFunction)1 TreeNodeLabelManager (com.alibaba.maxgraph.compiler.tree.TreeNodeLabelManager)1 MaxGraphException (com.alibaba.maxgraph.sdkcommon.exception.MaxGraphException)1 DefaultGraphSchema (com.alibaba.maxgraph.sdkcommon.schema.mapper.DefaultGraphSchema)1 EdgeTypeMapper (com.alibaba.maxgraph.sdkcommon.schema.mapper.EdgeTypeMapper)1