Example #1
0
 def get_path_value(self, start_id, steps=5):
     path = ttypes.Path()
     path.src = self.get_vertex_value(start_id)
     path.steps = list()
     for i in range(0, steps):
         step = ttypes.Step()
         step.dst = self.get_vertex_value('vertex{}'.format(i))
         step.type = 1 if i % 2 == 0 else -1
         step.name = 'classmate'
         step.ranking = 100
         step.props = dict()
         for i in range(0, 5):
             step.props['prop{}'.format(i)] = i
         path.steps.append(step)
     return path
 def get_path_value(self, start_id, steps=5):
     path = ttypes.Path()
     path.src = self.get_vertex_value(start_id)
     path.steps = list()
     for i in range(0, steps):
         step = ttypes.Step()
         step.dst = self.get_vertex_value(('vertex{}'.format(i)).encode('utf-8'))
         step.type = 1 if i % 2 == 0 else -1
         step.name = b'classmate'
         step.ranking = 100
         step.props = dict()
         for i in range(0, 5):
             value = ttypes.Value()
             value.set_iVal(i)
             step.props[('prop{}'.format(i)).encode('utf-8')] = value
         path.steps.append(step)
     return path
Example #3
0
 def to_value(self):
     path = CommonTtypes.Path()
     path.steps = []
     for j, col in enumerate(self.items):
         if j == 0:
             path.src = col.get_vVal()
         elif (j % 2) == 1:
             edge = col[0].get_eVal()
             step = CommonTtypes.Step()
             step.name = edge.name
             step.ranking = edge.ranking
             step.type = col[1]
             step.props = edge.props
             path.steps.append(step)
         else:
             print("step: %d", len(path.steps))
             path.steps[-1].dst = col.get_vVal()
     return path
 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