hongzhi-gao commented on code in PR #767:
URL: https://github.com/apache/tsfile/pull/767#discussion_r3042976599


##########
python/tsfile/tsfile_py_cpp.pyx:
##########
@@ -922,3 +927,164 @@ cdef object get_all_timeseries_schema(TsFileReader 
reader):
         device_schemas.update([(schema_py.get_device_name(), schema_py)])
     free(schemas)
     return device_schemas
+
+cdef object _c_str_to_py_utf8_or_none(char* p):
+    if p == NULL:
+        return None
+    return p.decode('utf-8')
+
+cdef object timeseries_metadata_c_to_py(TimeseriesMetadata* m):
+    cdef str name_py
+    if m == NULL or m.measurement_name == NULL:
+        name_py = ""
+    else:
+        name_py = m.measurement_name.decode('utf-8')
+    cdef object stat = TimeseriesStatisticPy(
+        bool(m.statistic.has_statistic),
+        int(m.statistic.row_count),
+        int(m.statistic.start_time),
+        int(m.statistic.end_time),
+        bool(m.statistic.sum_valid),
+        float(m.statistic.sum),
+        bool(m.statistic.int_range_valid),
+        int(m.statistic.min_int64),
+        int(m.statistic.max_int64),
+        int(m.statistic.first_int64),
+        int(m.statistic.last_int64),
+        bool(m.statistic.float_range_valid),
+        float(m.statistic.min_float64),
+        float(m.statistic.max_float64),
+        float(m.statistic.first_float64),
+        float(m.statistic.last_float64),
+        bool(m.statistic.bool_ext_valid),
+        bool(m.statistic.first_bool),
+        bool(m.statistic.last_bool),
+        bool(m.statistic.str_ext_valid),
+        _c_str_to_py_utf8_or_none(m.statistic.str_min),
+        _c_str_to_py_utf8_or_none(m.statistic.str_max),
+        _c_str_to_py_utf8_or_none(m.statistic.str_first),
+        _c_str_to_py_utf8_or_none(m.statistic.str_last),
+    )
+    return TimeseriesMetadataPy(
+        name_py,
+        TSDataTypePy(m.data_type),
+        int(m.chunk_meta_count),
+        stat,
+    )
+
+cdef tuple c_device_segments_to_tuple(char** segs, uint32_t n):
+    cdef uint32_t i
+    cdef list out = []
+    for i in range(n):
+        if segs[i] == NULL:
+            out.append("")

Review Comment:
   fixed



-- 
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]

Reply via email to