将字符串保存为二进制以节省内存

huangapple go评论93阅读模式
英文:

Saving strings as binary to save memory

问题

我有一个占用大量空间的字符串列。如果我将其保存为二进制而不是字符串,是否会节省空间?

我将字符串列表保存到磁盘,以及等效二进制列表的方法如下:
{-8!x} each strList

在磁盘上,文件无论如何都以二进制形式保存,但似乎二进制文件比字符串列表大。

而且,如果对其运行 -22!,二进制列表也比字符串列表大。我知道 -22! 是未压缩大小,所以有没有办法测量实际大小?

英文:

I have a large string column that takes up a lot of space. If I save it in the table as a binary instead of a string will that save space?

I saved a list of strings to disk, and a list of equivalent binaries through:
{-8!x} each strList

On disk files are saved in binary anyways, but it seems the binary file is larger than the string list.

Also the binary list is larger than the string list if I run -22! on it. I know -22! Is uncompressed size, so is there anyway to measure the actual size?

答案1

得分: 1

运行-8!会得到IPC格式。它将占用更多空间。

您应该考虑使用压缩来节省空间:

对于短字符串,有一些选项可用于编码:

如果字符串很大,您可以考虑分别压缩它们:

英文:

Running -8! is giving you the IPC format. It will take up more space.

You should look in to compression to save space:

For short strings some options are available to encode:

If the strings are large you could look in to compressing them individually:

huangapple
  • 本文由 发表于 2023年6月29日 21:07:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76581368.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定