def p_set(p): ''' set : '{' list_items '}' ''' s = NSet() s.values = set(p[2]) p[0] = Value(uVal=s)
def test_as_set(self): value = ttypes.Value() str_val1 = ttypes.Value() str_val1.set_sVal(b"word") str_val2 = ttypes.Value() str_val2.set_sVal(b"car") set_val = NSet() set_val.values = set() set_val.values.add(str_val1) set_val.values.add(str_val2) value.set_uVal(set_val) value_wrapper = ValueWrapper(value) assert value_wrapper.is_set() set_val = value_wrapper.as_set() assert isinstance(set_val, set) expect_result = set() expect_result.add(ValueWrapper(ttypes.Value(sVal=b"word"))) expect_result.add(ValueWrapper(ttypes.Value(sVal=b"car"))) assert set_val == expect_result
def get_data_set(cls): data_set = ttypes.DataSet() data_set.column_names = [ b"col1_empty", b"col2_null", b"col3_bool", b"col4_int", b"col5_double", b"col6_string", b"col7_list", b"col8_set", b"col9_map", b"col10_time", b"col11_date", b"col12_datetime", b"col13_vertex", b"col14_edge", b"col15_path" ] row = ttypes.Row() row.values = [] value1 = ttypes.Value() row.values.append(value1) value2 = ttypes.Value() value2.set_nVal(NullType.BAD_DATA) row.values.append(value2) value3 = ttypes.Value() value3.set_bVal(False) row.values.append(value3) value4 = ttypes.Value() value4.set_iVal(100) row.values.append(value4) value5 = ttypes.Value() value5.set_fVal(10.01) row.values.append(value5) value6 = ttypes.Value() value6.set_sVal(b"hello world") row.values.append(value6) value7 = ttypes.Value() str_val1 = ttypes.Value() str_val1.set_sVal(b"word") str_val2 = ttypes.Value() str_val2.set_sVal(b"car") list_val = NList() list_val.values = [str_val1, str_val2] value7.set_lVal(list_val) row.values.append(value7) value8 = ttypes.Value() set_val = NSet() set_val.values = set() set_val.values.add(str_val1) set_val.values.add(str_val2) value8.set_uVal(set_val) row.values.append(value8) value9 = ttypes.Value() map = NMap() map.kvs = {b"a": str_val1, b"b": str_val2} value9.set_mVal(map) row.values.append(value9) value10 = ttypes.Value() value10.set_tVal(Time(10, 10, 10, 10000)) row.values.append(value10) value11 = ttypes.Value() value11.set_dVal(date(2020, 10, 1)) row.values.append(value11) value12 = ttypes.Value() value12.set_dtVal(DateTime(2020, 10, 1, 10, 10, 10, 10000)) row.values.append(value12) value13 = ttypes.Value() value13.set_vVal(cls.get_vertex_value(b"Tom")) row.values.append(value13) value14 = ttypes.Value() value14.set_eVal(cls.get_edge_value(b"Tom", b"Lily")) row.values.append(value14) value15 = ttypes.Value() value15.set_pVal(cls.get_path_value(b"Tom", 3)) row.values.append(value15) data_set.rows = [] data_set.rows.append(row) data_set.rows.append(row) return data_set
def get_result_set(self): resp = graphTtype.ExecutionResponse() resp.error_code = graphTtype.ErrorCode.E_BAD_PERMISSION resp.error_msg = b"Permission" resp.comment = b"Permission" resp.space_name = b"test" resp.latency_in_us = 100 data_set = ttypes.DataSet() data_set.column_names = [ b"col1_empty", b"col2_null", b"col3_bool", b"col4_int", b"col5_double", b"col6_string", b"col7_list", b"col8_set", b"col9_map", b"col10_time", b"col11_date", b"col12_datetime", b"col13_vertex", b"col14_edge", b"col15_path" ] row = ttypes.Row() row.values = [] value1 = ttypes.Value() row.values.append(value1) value2 = ttypes.Value() value2.set_nVal(NullType.BAD_DATA) row.values.append(value2) value3 = ttypes.Value() value3.set_bVal(False) row.values.append(value3) value4 = ttypes.Value() value4.set_iVal(100) row.values.append(value4) value5 = ttypes.Value() value5.set_fVal(10.01) row.values.append(value5) value6 = ttypes.Value() value6.set_sVal(b"hello world") row.values.append(value6) value7 = ttypes.Value() str_val1 = ttypes.Value() str_val1.set_sVal(b"word") str_val2 = ttypes.Value() str_val2.set_sVal(b"car") list_val = NList() list_val.values = [str_val1, str_val2] value7.set_lVal(list_val) row.values.append(value7) value8 = ttypes.Value() set_val = NSet() set_val.values = set() set_val.values.add(str_val1) set_val.values.add(str_val2) value8.set_uVal(set_val) row.values.append(value8) value9 = ttypes.Value() map = NMap() map.kvs = {b"a": str_val1, b"b": str_val2} value9.set_mVal(map) row.values.append(value9) value10 = ttypes.Value() value10.set_tVal(Time(10, 10, 10, 10000)) row.values.append(value10) value11 = ttypes.Value() value11.set_dVal(date(2020, 10, 1)) row.values.append(value11) value12 = ttypes.Value() value12.set_dtVal(DateTime(2020, 10, 1, 10, 10, 10, 10000)) row.values.append(value12) value13 = ttypes.Value() value13.set_vVal(self.get_vertex_value(b"Tom")) row.values.append(value13) value14 = ttypes.Value() value14.set_eVal(self.get_edge_value(b"Tom", b"Lily")) row.values.append(value14) value15 = ttypes.Value() value15.set_pVal(self.get_path_value(b"Tom", 3)) row.values.append(value15) data_set.rows = [] data_set.rows.append(row) resp.data = data_set return ResultSet(resp)