ColinLeeo commented on code in PR #214:
URL: https://github.com/apache/tsfile/pull/214#discussion_r1745461246
##########
cpp/src/common/datatype/value.h:
##########
@@ -33,16 +33,41 @@
namespace common {
struct Value {
- Value(TSDataType type) : type_(type), value_{0} {}
+ Value(TSDataType type) : type_(type) {
+ switch (type) {
+ case BOOLEAN:
+ value_.bval_ = false;
+ break;
+ case INT32:
+ value_.ival_ = 0;
+ break;
+ case INT64:
+ value_.lval_ = 0;
+ break;
+ case FLOAT:
+ value_.fval_ = 0.0f;
+ break;
+ case DOUBLE:
+ value_.dval_ = 0.0;
+ break;
+ case TEXT:
+ value_.sval_ = nullptr;
+ break;
+ case NULL_TYPE:
+ break;
+ default:
+ LOGE("unknown data type");
+ }
+ }
Review Comment:
Initializing a union by setting only a single variable to 0 may not be
sufficient, as the variable might not be long enough, causing other types to
remain non-zero.
--
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]