ColinLeeo commented on code in PR #418:
URL: https://github.com/apache/tsfile/pull/418#discussion_r1973070639


##########
cpp/src/cwrapper/tsfile_cwrapper.cc:
##########
@@ -314,22 +381,40 @@ TSFILE_RESULT_SET_GET_VALUE_BY_INDEX_DEF(float);
 TSFILE_RESULT_SET_GET_VALUE_BY_INDEX_DEF(double);
 TSFILE_RESULT_SET_GET_VALUE_BY_INDEX_DEF(bool);
 
+char *tsfile_result_set_get_value_by_index_string(ResultSet result_set,
+                                                  uint32_t column_index) {
+    auto *r = static_cast<storage::TableResultSet *>(result_set);
+    common::String *ret = r->get_value<common::String *>(column_index);
+    // Caller should free return's char* 's space.
+    char* dup = (char*) malloc(ret->len_ + 1);
+    if (dup) {
+        memcpy(dup, ret->buf_, ret->len_);
+        dup[ret->len_] = '\0';
+    }
+    return dup;
+}
+
 bool tsfile_result_set_is_null_by_name(ResultSet result_set,
                                        const char *column_name) {
-    auto *r = static_cast<storage::ResultSet *>(result_set);
+    auto *r = static_cast<storage::TableResultSet *>(result_set);
     return r->is_null(column_name);
 }
 
 bool tsfile_result_set_is_null_by_index(const ResultSet result_set,
                                         const uint32_t column_index) {
-    auto *r = static_cast<storage::ResultSet *>(result_set);
+    auto *r = static_cast<storage::TableResultSet *>(result_set);
     return r->is_null(column_index);
 }
 
 ResultSetMetaData tsfile_result_set_get_metadata(ResultSet result_set) {
-    auto *r = static_cast<storage::QDSWithoutTimeGenerator *>(result_set);
+    auto *r = static_cast<storage::TableResultSet *>(result_set);
+    if (result_set == NULL) {
+        return ResultSetMetaData();
+    }

Review Comment:
   before call this  func, caller should check if result_set is null, which 
means query is not correctly.



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