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);
}
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;
}
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;
}
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);
}
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);
}
Aggregations