Apache Arrow String Vector Memory Layout优化总结

https://docs.google.com/document/d/12aZi8Inez9L_JCtZ6gi2XDbQpCsHICNy9_EUxj4ILeE​docs.google.com/document/d/12aZi8Inez9L_JCtZ6gi2XDbQpCsHICNy9_EUxj4ILeE/

这篇文章提出了一种新的string vector memory layout,如下:string vector中每一行由StringView组成,size_表示数组长度,prefix_表示字符串前4-byte, value_表示字符串剩下的部分,如果剩下部分长度不超过8,则使用remainder_inclined表示,否则由complete_string_data指向另一个buffer, buffer中存储着完整的字符串。

DuckDB中的表示比较相似

优化动机

  • StringView构成了String Vector的每一行。因为StringView是定长的,每一行的StringView都可预先分配,并行构造,随机读写而没有任何copy代价。
  • StringView中包含了4-byte前缀,可用于字符串的快速过滤,也可加快join/aggregation/sort算子性能
  • 减小了dict-encoded string column物化的代价
  • 可加快特性算法(prefix of string or suffix of string)的性能