iotdb-jdbc icon indicating copy to clipboard operation
iotdb-jdbc copied to clipboard

thrift中的TSDataValue类的内存浪费问题

Open jt2594838 opened this issue 7 years ago • 1 comments

在Thrift中,一个数据点的值使用下面的结构表示的:

struct TSDataValue{
  1: required bool is_empty
  2: optional bool bool_val
  3: optional i32 int_val
  4: optional i64 long_val
  5: optional double float_val
  6: optional double double_val
  7: optional binary binary_val
  8: optional string type;
}

也就是说在内存中保存一个数据点实际上用了4 + 4 + 4 + 8 + 8 + 8 + 8 + 8 = 52byte的内存。
尽管大部分字段以optional修饰,但这仅表示在序列化时该字段可能不会被序列化,不会减小其存在于内存时的大小。
需要检讨这种设计是否会造成过大的内存占用。

jt2594838 avatar Sep 12 '18 06:09 jt2594838

有道理,最好是像C语言里面的联合的概念,共享同一段内存

MyXOF avatar Oct 17 '18 06:10 MyXOF