Beispiel #1
0
    def get_attr(self):
        attr_list = attr_value_pb2.NameAttrList()
        attr_list.name = "{}_{}".format(self.source_label,
                                        self.destination_label)
        attr_list.attr[types_pb2.SRC_LABEL].CopyFrom(
            utils.s_to_attr(self.source_label))
        attr_list.attr[types_pb2.DST_LABEL].CopyFrom(
            utils.s_to_attr(self.destination_label))
        attr_list.attr[types_pb2.LOAD_STRATEGY].CopyFrom(
            utils.s_to_attr(self.load_strategy))
        attr_list.attr[types_pb2.SRC_VID].CopyFrom(
            utils.s_to_attr(str(self.source_vid)))
        attr_list.attr[types_pb2.DST_VID].CopyFrom(
            utils.s_to_attr(str(self.destination_vid)))

        attr_list.attr[types_pb2.LOADER].CopyFrom(self.loader.get_attr())

        props = []
        for prop in self.properties[2:]:
            prop_attr = attr_value_pb2.NameAttrList()
            prop_attr.name = prop[0]
            prop_attr.attr[0].CopyFrom(utils.type_to_attr(prop[1]))
            props.append(prop_attr)
        attr_list.attr[types_pb2.PROPERTIES].list.func.extend(props)
        return attr_list
Beispiel #2
0
def process_edge(edge: EdgeLabel) -> attr_value_pb2.NameAttrList:
    attr_list = attr_value_pb2.NameAttrList()
    attr_list.name = "edge"

    attr_list.attr[types_pb2.LABEL].CopyFrom(utils.s_to_attr(edge.label))

    sub_label_attr = [sub_label.get_attr() for sub_label in edge.sub_labels]
    attr_list.attr[types_pb2.SUB_LABEL].list.func.extend(sub_label_attr)
    return attr_list
Beispiel #3
0
def process_vertex(vertex: VertexLabel) -> attr_value_pb2.NameAttrList:
    attr_list = attr_value_pb2.NameAttrList()
    attr_list.name = "vertex"

    attr_list.attr[types_pb2.LABEL].CopyFrom(utils.s_to_attr(vertex.label))

    attr_list.attr[types_pb2.VID].CopyFrom(utils.s_to_attr(str(vertex.vid)))

    props = []
    for prop in vertex.properties[1:]:
        prop_attr = attr_value_pb2.NameAttrList()
        prop_attr.name = prop[0]
        prop_attr.attr[0].CopyFrom(utils.type_to_attr(prop[1]))
        props.append(prop_attr)
    attr_list.attr[types_pb2.PROPERTIES].list.func.extend(props)

    attr_list.attr[types_pb2.LOADER].CopyFrom(vertex.loader.get_attr())
    return attr_list