Exemplo n.º 1
0
def create_edge_like(line):
    assert len(line) == 3
    edge = ttypes.Edge()

    edge.src = utf8b(line[0])
    edge.dst = utf8b(line[1])
    edge.type = 1
    edge.ranking = 0
    edge.name = utf8b('like')
    props = dict()
    likeness = ttypes.Value()
    likeness.set_iVal(int(line[2]))
    props[utf8b('likeness')] = likeness
    edge.props = props
    return edge
Exemplo n.º 2
0
def create_vertex_team(line):
    assert len(line) == 2
    vertex = ttypes.Vertex()
    vertex.vid = utf8b(line[0])
    tags = []
    tag = ttypes.Tag()
    tag.name = utf8b('team')

    props = dict()
    name = ttypes.Value()
    name.set_sVal(utf8b(line[1]))
    props[utf8b('name')] = name
    tag.props = props
    tags.append(tag)
    vertex.tags = tags
    return vertex
Exemplo n.º 3
0
def create_edge_teammate(line):
    assert len(line) == 4
    edge = ttypes.Edge()
    edge.src = utf8b(line[0])
    edge.dst = utf8b(line[1])
    edge.type = 1
    edge.ranking = 0
    edge.name = utf8b('teammate')
    props = dict()
    start_year = ttypes.Value()
    start_year.set_iVal(int(line[2]))
    end_year = ttypes.Value()
    end_year.set_iVal(int(line[3]))
    props[utf8b('start_year')] = start_year
    props[utf8b('end_year')] = end_year
    edge.props = props
    return edge
Exemplo n.º 4
0
def create_vertex_player(line):
    assert len(line) == 3
    vertex = ttypes.Vertex()
    vertex.vid = utf8b(line[0])
    tags = []
    tag = ttypes.Tag()
    tag.name = utf8b('player')

    props = dict()
    name = ttypes.Value()
    name.set_sVal(utf8b(line[1]))
    props[utf8b('name')] = name
    age = ttypes.Value()
    age.set_iVal(int(line[2]))
    props[utf8b('age')] = age
    tag.props = props
    tags.append(tag)
    vertex.tags = tags
    return vertex
Exemplo n.º 5
0
def create_edge_serve(line):
    assert len(line) == 4
    edge = ttypes.Edge()
    src = ttypes.Value()
    src.set_sVal(utf8b(line[0]))
    edge.src = src
    dst = ttypes.Value()
    if '@' in line[1]:
        temp = list(map(lambda i: i.strip('"'), re.split('@', line[1])))
        dst.set_sVal(utf8b(temp[0]))
        edge.dst = dst
        edge.ranking = int(temp[1])
    else:
        dst.set_sVal(utf8b(line[1]))
        edge.dst = dst
        edge.ranking = 0
    edge.type = 1
    edge.name = utf8b('serve')
    props = dict()
    start_year = ttypes.Value()
    start_year.set_iVal(int(line[2]))
    end_year = ttypes.Value()
    end_year.set_iVal(int(line[3]))
    props[utf8b('start_year')] = start_year
    props[utf8b('end_year')] = end_year
    edge.props = props
    return edge
Exemplo n.º 6
0
def create_vertex_bachelor(line):
    assert len(line) == 3
    vertex = ttypes.Vertex()
    vertex.vid = utf8b(line[0])
    tags = []
    tag = ttypes.Tag()
    tag.name = utf8b('bachelor')

    props = dict()
    name = ttypes.Value()
    name.set_sVal(utf8b(line[1]))
    props[utf8b('name')] = name
    speciality = ttypes.Value()
    speciality.set_sVal(utf8b(line[2]))
    props[utf8b('speciality')] = speciality
    tag.props = props
    tags.append(tag)
    vertex.tags = tags
    return vertex