ycycse commented on code in PR #11231:
URL: https://github.com/apache/iotdb/pull/11231#discussion_r1355963722
##########
iotdb-client/client-py/iotdb/utils/Field.py:
##########
@@ -61,71 +58,73 @@ def get_data_type(self):
def is_null(self):
return self.__data_type is None
- def set_bool_value(self, value):
- self.__bool_value = value
+ def set_bool_value(self, value: bool):
+ self.value = value
def get_bool_value(self):
if self.__data_type is None:
raise Exception("Null Field Exception!")
- return self.__bool_value
+ if self.__data_type != TSDataType.BOOLEAN:
+ return None
+ return self.value
- def set_int_value(self, value):
- self.__int_value = value
+ def set_int_value(self, value: int):
+ self.value = value
def get_int_value(self):
if self.__data_type is None:
raise Exception("Null Field Exception!")
- return self.__int_value
+ if self.__data_type != TSDataType.INT32:
+ return None
+ return np.int32(self.value)
Review Comment:
Should we check if `self.value` is None and raise Exception (or return None,
`np.int32(None)` would cause unexpected TypeError)?
##########
iotdb-client/client-py/iotdb/utils/Field.py:
##########
@@ -61,71 +58,73 @@ def get_data_type(self):
def is_null(self):
return self.__data_type is None
- def set_bool_value(self, value):
- self.__bool_value = value
+ def set_bool_value(self, value: bool):
+ self.value = value
def get_bool_value(self):
if self.__data_type is None:
raise Exception("Null Field Exception!")
- return self.__bool_value
+ if self.__data_type != TSDataType.BOOLEAN:
+ return None
+ return self.value
- def set_int_value(self, value):
- self.__int_value = value
+ def set_int_value(self, value: int):
+ self.value = value
def get_int_value(self):
if self.__data_type is None:
raise Exception("Null Field Exception!")
- return self.__int_value
+ if self.__data_type != TSDataType.INT32:
+ return None
+ return np.int32(self.value)
- def set_long_value(self, value):
- self.__long_value = value
+ def set_long_value(self, value: int):
+ self.value = value
def get_long_value(self):
if self.__data_type is None:
raise Exception("Null Field Exception!")
- return self.__long_value
+ if self.__data_type != TSDataType.INT64:
+ return None
+ return np.int64(self.value)
- def set_float_value(self, value):
- self.__float_value = value
+ def set_float_value(self, value: float):
+ self.value = value
def get_float_value(self):
if self.__data_type is None:
raise Exception("Null Field Exception!")
- return self.__float_value
+ if self.__data_type != TSDataType.FLOAT:
+ return None
+ return np.float32(self.value)
Review Comment:
`np.float32` would return `np.nan`. Is this an expected result?
##########
iotdb-client/client-py/iotdb/utils/Field.py:
##########
@@ -134,22 +133,19 @@ def get_object_value(self, data_type):
"""
:param data_type: TSDataType
"""
- if self.__data_type is None:
+ if self.__data_type is None or self.value is None or self.value is
pd.NA:
Review Comment:
Do you mean `np.NaN`? I don't found the calculation about pandas in this
file.
```suggestion
if self.__data_type is None or self.value is None or self.value is
np.NaN:
```
##########
iotdb-client/client-py/iotdb/utils/IoTDBRpcDataSet.py:
##########
@@ -142,30 +137,141 @@ def close(self):
self.__is_closed = True
self.__client = None
- if isinstance(self.__query_data_set.time, memoryview):
- self.__query_data_set.time.release()
- for value in self.__query_data_set.valueList:
- if isinstance(value, memoryview):
- value.release()
- for bitmap in self.__query_data_set.bitmapList:
- if isinstance(bitmap, memoryview):
- bitmap.release()
def next(self):
- if self.has_cached_result():
- self.construct_one_row()
+ if not self.has_cached_data_frame:
+ self.construct_one_data_frame()
+ if self.has_cached_data_frame:
return True
if self.__empty_resultSet:
return False
if self.fetch_results():
- self.construct_one_row()
+ self.construct_one_data_frame()
return True
return False
- def has_cached_result(self):
- return (self.__query_data_set is not None) and (
- len(self.__query_data_set.time) != 0
Review Comment:
Should we keep len(self.__query_data_set.time) != 0? Maybe the resultSet is
already an emptySet.
##########
iotdb-client/client-py/iotdb/utils/Field.py:
##########
@@ -61,71 +58,73 @@ def get_data_type(self):
def is_null(self):
return self.__data_type is None
- def set_bool_value(self, value):
- self.__bool_value = value
+ def set_bool_value(self, value: bool):
+ self.value = value
def get_bool_value(self):
if self.__data_type is None:
raise Exception("Null Field Exception!")
- return self.__bool_value
+ if self.__data_type != TSDataType.BOOLEAN:
+ return None
+ return self.value
- def set_int_value(self, value):
- self.__int_value = value
+ def set_int_value(self, value: int):
+ self.value = value
def get_int_value(self):
if self.__data_type is None:
raise Exception("Null Field Exception!")
- return self.__int_value
+ if self.__data_type != TSDataType.INT32:
+ return None
+ return np.int32(self.value)
- def set_long_value(self, value):
- self.__long_value = value
+ def set_long_value(self, value: int):
+ self.value = value
def get_long_value(self):
if self.__data_type is None:
raise Exception("Null Field Exception!")
- return self.__long_value
+ if self.__data_type != TSDataType.INT64:
+ return None
+ return np.int64(self.value)
Review Comment:
The same as `np.int32`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]