英文:
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格式。它将占用更多空间。
您应该考虑使用压缩来节省空间:
对于短字符串,有一些选项可用于编码:
如果字符串很大,您可以考虑分别压缩它们:
-18!
https://code.kx.com/q/basics/internal/#-18x-compress-byte.Q.gz
https://code.kx.com/q/ref/dotq/#gz-gzip
英文:
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:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论