9 from nebula3.common
import ttypes
10 from nebula3.common.ttypes
import Vertex, Tag, Edge
11 from nebula3.data.DataObject
import DataSetWrapper, Node, ValueWrapper, Relationship
16 PROP_START_INDEX_with_vid = 2
19 def __init__(self, row, col_names, decode_type='utf-8'):
23 |tag_name._vid|tag_name.prop1|tag_name.prop2|
26 if len(row.values) != len(col_names):
28 'Input row size is not equal with the col name size, {} != {}'.format(
36 for col_name
in col_names:
37 names = col_name.split(b
'.')
39 if len(names) == 1
and names[0] == b
'_vid':
42 raise RuntimeError(
'Input wrong col name format of tag')
47 """get vertex id, if the space vid_type is int, you can use get_id().as_int(),
48 if the space vid_type is fixed_string, you can use get_id().as_string()
52 if len(self.
_row_row.values) < 1:
54 'The row value is bad format, '
55 'get vertex id failed: len is {}'.format(len(self.
_row_row.values))
60 """convert the vertex data to structure Node
66 'The row value is bad format, '
67 'as node failed: len is {}'.format(len(self.
_row_row.values))
72 vertex.vid = self.
_row_row.values[0]
78 tag.props[self.
_col_names_col_names[index]] = self.
_row_row.values[index + 1]
80 vertex.tags.append(tag)
82 return Node(vertex).set_decode_type(self.
_decode_type_decode_type)
85 """get all prop names from the vertex data
92 """get all prop values from the vertex data
94 :return: list<ValueWrapper>
98 while index < len(self.
_row_row.values):
100 ValueWrapper(self.
_row_row.values[index], decode_type=self.
_decode_type_decode_type)
106 return str(self.
as_nodeas_node())
112 def __init__(self, row, col_names, decode_type='utf-8'):
116 |edge_name._src|edge_name._type|edge_name._rank|edge_name._dst|edge_name.prop1|edge_name.prop2|
119 if len(row.values) != len(col_names):
121 'Input row size is not equal '
122 'with the col name size, {} != {}'.format(
123 len(row.values), len(col_names)
130 for col_name
in col_names:
131 names = col_name.split(b
'.')
133 raise RuntimeError(
'Input wrong col name format of edge')
138 """get src id, if the space vid_type is int, you can use get_src_id().as_int(),
139 if the space vid_type is fixed_string, you can use get_src_id().as_string()
141 :return: ValueWrapper
143 if len(self.
_row_row.values) < 1:
145 'The row value is bad format, '
146 'get edge src id failed: len is {}'.format(len(self.
_row_row.values))
162 if len(self.
_row_row.values) < 3:
164 'The row value is bad format, '
165 'get edge ranking failed: len is {}'.format(len(self.
_row_row.values))
167 assert self.
_row_row.values[2].getType() == ttypes.Value.IVAL
168 return self.
_row_row.values[2].get_iVal()
171 """get dst id, if the space vid_type is int, you can use get_dst_id().as_int(),
172 if the space vid_type is fixed_string, you can use get_dst_id().as_string()
174 :return: ValueWrapper
176 if len(self.
_row_row.values) < 4:
178 'The row value is bad format, '
179 'get edge dst id failed: len is {}'.format(len(self.
_row_row.values))
184 """convert the edge data to structure Relationship
186 :return: Relationship
190 'The row value is bad format, '
191 'as relationship failed: len is {}'.format(len(self.
_row_row.values))
194 edge.src = self.
_row_row.values[0]
195 edge.type = self.
_row_row.values[1].get_iVal()
197 edge.ranking = self.
_row_row.values[2].get_iVal()
198 edge.dst = self.
_row_row.values[3]
202 edge.props[self.
_col_names_col_names[index]] = self.
_row_row.values[index]
205 return Relationship(edge).set_decode_type(self.
_decode_type_decode_type)
208 """get all prop names from the edge data
210 :return: list<string>
215 """get all prop values from the edge data
217 :return: list<ValueWrapper>
221 while index < len(self.
_row_row.values):
223 ValueWrapper(self.
_row_row.values[index], decode_type=self.
_decode_type_decode_type)
233 def __init__(self, data_sets: list, decode_type=
'utf-8', is_vertex=
True):
234 assert data_sets
is not None
243 self.
_size_size += len(data_set.rows)
246 """get DataSet, it's the origin values, the string type is binary
255 if len(data_set.column_names) != len(result.column_names):
256 raise RuntimeError(
'Multi DataSets are different col size')
257 result.rows.extend(data_set.rows)
262 """get DataSetWrapper, it's the wrapper for DataSet value, the string type is str
264 :return: DataSetWrapper
271 if len(data_set.column_names) != len(result.column_names):
272 raise RuntimeError(
'Multi DataSets are different col size')
273 result.rows.extend(data_set.rows)
277 return DataSetWrapper(result, self.
_decode_type_decode_type)
287 """The VertexData or EdgeData iterator
289 :return: VertexData or EdgeData Iterator
def get_data_set_wrapper(self)
def __init__(self, row, col_names, decode_type='utf-8')
def as_relationship(self)
def get_prop_values(self)
def __init__(self, row, col_names, decode_type='utf-8')
int PROP_START_INDEX_with_vid
def get_prop_values(self)