All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.graphscope.groot.sdk.schema.Vertex Maven / Gradle / Ivy

There is a newer version: 0.28.1
Show newest version
package com.alibaba.graphscope.groot.sdk.schema;

import com.alibaba.graphscope.proto.groot.DataRecordPb;
import com.alibaba.graphscope.proto.groot.VertexRecordKeyPb;
import com.alibaba.graphscope.proto.groot.WriteRequestPb;
import com.alibaba.graphscope.proto.groot.WriteTypePb;

import java.util.Map;

public class Vertex {
    public String label;
    public Map properties;

    public Vertex(String label) {
        this(label, null);
    }

    public Vertex(String label, Map properties) {
        this.label = label;
        this.properties = properties;
    }

    public String getLabel() {
        return label;
    }

    public Map getProperties() {
        return properties;
    }

    public VertexRecordKeyPb toVertexRecordKey(String label) {
        VertexRecordKeyPb.Builder builder = VertexRecordKeyPb.newBuilder().setLabel(label);
        //        builder.putAllPkProperties(properties);
        return builder.build();
    }

    public DataRecordPb toDataRecord() {
        DataRecordPb.Builder builder =
                DataRecordPb.newBuilder().setVertexRecordKey(toVertexRecordKey(label));
        if (properties != null) {
            builder.putAllProperties(properties);
        }
        return builder.build();
    }

    public WriteRequestPb toWriteRequest(WriteTypePb writeType) {
        return WriteRequestPb.newBuilder()
                .setWriteType(writeType)
                .setDataRecord(toDataRecord())
                .build();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy