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 values from the vertex data
87 :return: list<ValueWrapper>
91 while index < len(self.
_row_row.values):
93 ValueWrapper(self.
_row_row.values[index], decode_type=self.
_decode_type_decode_type)
99 return str(self.
as_nodeas_node())
105 def __init__(self, row, col_names, decode_type='utf-8'):
109 |edge_name._src|edge_name._type|edge_name._rank|edge_name._dst|edge_name.prop1|edge_name.prop2|
112 if len(row.values) != len(col_names):
114 'Input row size is not equal '
115 'with the col name size, {} != {}'.format(
116 len(row.values), len(col_names)
123 for col_name
in col_names:
124 names = col_name.split(b
'.')
126 raise RuntimeError(
'Input wrong col name format of edge')
131 """get src id, if the space vid_type is int, you can use get_src_id().as_int(),
132 if the space vid_type is fixed_string, you can use get_src_id().as_string()
134 :return: ValueWrapper
136 if len(self.
_row_row.values) < 1:
138 'The row value is bad format, '
139 'get edge src id failed: len is {}'.format(len(self.
_row_row.values))
155 if len(self.
_row_row.values) < 3:
157 'The row value is bad format, '
158 'get edge ranking failed: len is {}'.format(len(self.
_row_row.values))
160 assert self.
_row_row.values[2].getType() == ttypes.Value.IVAL
161 return self.
_row_row.values[2].get_iVal()
164 """get dst id, if the space vid_type is int, you can use get_dst_id().as_int(),
165 if the space vid_type is fixed_string, you can use get_dst_id().as_string()
167 :return: ValueWrapper
169 if len(self.
_row_row.values) < 4:
171 'The row value is bad format, '
172 'get edge dst id failed: len is {}'.format(len(self.
_row_row.values))
177 """convert the edge data to structure Relationship
179 :return: Relationship
183 'The row value is bad format, '
184 'as relationship failed: len is {}'.format(len(self.
_row_row.values))
187 edge.src = self.
_row_row.values[0]
188 edge.type = self.
_row_row.values[1].get_iVal()
190 edge.ranking = self.
_row_row.values[2].get_iVal()
191 edge.dst = self.
_row_row.values[3]
195 edge.props[self.
_col_names_col_names[index]] = self.
_row_row.values[index]
198 return Relationship(edge).set_decode_type(self.
_decode_type_decode_type)
201 """get all prop values from the edge data
203 :return: list<ValueWrapper>
207 while index < len(self.
_row_row.values):
209 ValueWrapper(self.
_row_row.values[index], decode_type=self.
_decode_type_decode_type)
219 def __init__(self, data_sets: list, decode_type=
'utf-8', is_vertex=
True):
220 assert data_sets
is not None
229 self.
_size_size += len(data_set.rows)
232 """get DataSet, it's the origin values, the string type is binary
241 if len(data_set.column_names) != len(result.column_names):
242 raise RuntimeError(
'Multi DataSets are different col size')
243 result.rows.extend(data_set.rows)
248 """get DataSetWrapper, it's the wrapper for DataSet value, the string type is str
250 :return: DataSetWrapper
257 if len(data_set.column_names) != len(result.column_names):
258 raise RuntimeError(
'Multi DataSets are different col size')
259 result.rows.extend(data_set.rows)
263 return DataSetWrapper(result, self.
_decode_type_decode_type)
273 """The VertexData or EdgeData iterator
275 :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)