Exemple #1
0
 def get_vertex_value(self, vid):
     vertex = ttypes.Vertex()
     vertex.vid = vid
     vertex.tags = list()
     for i in range(0, 3):
         tag = ttypes.Tag()
         tag.name = 'tag{}'.format(i)
         tag.props = dict()
         for j in range(0, 5):
             tag.props['prop{}'.format(j)] = j
         vertex.tags.append(tag)
     return vertex
 def check_path_result_without_prop(self, rows, expect):
     msg = 'len(rows)[%d] != len(expect)[%d]' % (len(rows), len(expect))
     assert len(rows) == len(expect), msg
     for exp in expect:
         path = CommonTtypes.Path()
         path.steps = []
         for col, j in zip(exp, range(len(exp))):
             if j == 0:
                 src = CommonTtypes.Vertex()
                 src.vid = bytes(col, encoding='utf-8')
                 src.tags = []
                 path.src = src
             else:
                 assert len(col) == 3, \
                     "{} invalid values size in expect result".format(exp.__repr__())
                 step = CommonTtypes.Step()
                 step.name = bytes(col[0], encoding='utf-8')
                 step.ranking = col[1]
                 step.type = 1
                 dst = CommonTtypes.Vertex()
                 dst.vid = bytes(col[2], encoding='utf-8')
                 dst.tags = []
                 step.dst = dst
                 step.props = {}
                 path.steps.append(step)
         find = False
         for row in rows:
             assert len(row.values) == 1, \
                 "invalid values size in rows: {}".format(row)
             assert row.values[0].getType() == CommonTtypes.Value.PVAL, \
                 "invalid column path type: {}".format(row.values[0].getType()())
             if row.values[0].get_pVal() == path:
                 find = True
                 break
         msg = self.check_format_str.format(row.values[0].get_pVal(), path)
         assert find, msg
         rows.remove(row)
     assert len(rows) == 0
Exemple #3
0
 def get_vertex_value(self, vid):
     vertex = ttypes.Vertex()
     vertex.vid = vid
     vertex.tags = list()
     for i in range(0, 3):
         tag = ttypes.Tag()
         tag.name = ('tag{}'.format(i)).encode('utf-8')
         tag.props = dict()
         for j in range(0, 5):
             value = ttypes.Value()
             value.set_iVal(j)
             tag.props[('prop{}'.format(j)).encode('utf-8')] = value
         vertex.tags.append(tag)
     return vertex
Exemple #4
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
Exemple #5
0
    def create_vertex_team(self, line):
        if len(line) != 2:
            assert False
        vertex = CommonTtypes.Vertex()
        vertex.vid = bytes(line[0], encoding='utf-8')
        tags = []
        tag = CommonTtypes.Tag()
        tag.name = bytes('team', encoding='utf-8')

        props = dict()
        name = CommonTtypes.Value()
        name.set_sVal(bytes(line[1], encoding='utf-8'))
        props[bytes('name', encoding='utf-8')] = name
        tag.props = props
        tags.append(tag)
        vertex.tags = tags
        return vertex
Exemple #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
Exemple #7
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
Exemple #8
0
    def create_vertex_bachelor(self, line):
        if len(line) != 3:
            assert False

        vertex = CommonTtypes.Vertex()
        vertex.vid = bytes(line[0], encoding='utf-8')
        tags = []
        tag = CommonTtypes.Tag()
        tag.name = bytes('bachelor', encoding='utf-8')

        props = dict()
        name = CommonTtypes.Value()
        name.set_sVal(bytes(line[1], encoding='utf-8'))
        props[bytes('name', encoding='utf-8')] = name
        speciality = CommonTtypes.Value()
        speciality.set_sVal(bytes(line[2], encoding='utf-8'))
        props[bytes('speciality', encoding='utf-8')] = speciality
        tag.props = props
        tags.append(tag)
        vertex.tags = tags
        return vertex
Exemple #9
0
    def create_vertex_player(self, line):
        if len(line) != 3:
            assert False

        vertex = CommonTtypes.Vertex()
        vertex.vid = bytes(line[0], encoding='utf-8')
        tags = []
        tag = CommonTtypes.Tag()
        tag.name = bytes('player', encoding='utf-8')

        props = dict()
        name = CommonTtypes.Value()
        name.set_sVal(bytes(line[1], encoding='utf-8'))
        props[bytes('name', encoding='utf-8')] = name
        age = CommonTtypes.Value()
        age.set_iVal(int(line[2]))
        props[bytes('age', encoding='utf-8')] = age
        tag.props = props
        tags.append(tag)
        vertex.tags = tags
        return vertex
Exemple #10
0
 def gen_vertex(cls, vid, tags):
     vertex = ttypes.Vertex()
     vertex.vid = vid
     vertex.tags = tags
     return vertex