Hi<o:p></o:p>
<o:p> </o:p>
There?s a slight problem with your thinking here. You can?t save an unenumerated symbol list. Even when in memory, a list of symbols is actually enumerated. As you add symbols, these are added to an internal symbol list and stored as a pointer to the entry in this list. (You can see the number of entries in this list and the memory occupied by this list as the last two entries in the return dictionary of .Q.w).
<o:p> </o:p>
This means that regardless of the length of a sym, the sym will be stored once, and on repeated use it will occupy the memory for the pointer, not the actual sym (i.e. 5 syms of length 3 will not take up 15 bytes)
<o:p> </o:p>
When saving a database to disk, symbols must be enumerated also.
<o:p> </o:p>
The other option (for unenumerated storage) would be to save as strings ? this will result in saving two files, one a list of pointers (so number of elements * length of pointer), the other containing the actual data (which will increase as string size increases).
<o:p> </o:p>
Assuming the vector is repetitive, it is a good candidate for being of type sym, and this is how it should be stored. However, you should note that compression is not the purpose of enumeration. It can be a by-product in some cases, but it?s not designed for that. However, kdb does have built in compression support ? see here for more details:http://code.kx.com/wiki/Cookbook/FileCompression
<o:p> </o:p>
Hope that helps
Jonathon<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
From: analyst
Sent: 25 November 2016 15:43
To: Kdb+ Personal Developers
Subject: [personal kdb+] storage savings by using enum
<o:p> </o:p>
I want to calculate the storage savings by using enums. Using the example below. Some assumptions on storage of datatypes
list:abc
defghi
abc`def / 5 elements * 3 char/ element * 1byte / char = 15 bytes
uniql:(?)list / 3 elements * 3 chars /element * 1 byte / chars = 9bytes
enum:`uniql?list / 5 elements * 1 short / element * 1byte / short = 5 bytes
Total saving : 15 bytes - 9 bytes - 5 bytes = 1 byte
Question:
How many bytes to store a symbol ?
How many bytes to store a short / int / long ?
Is the calculation right ?
–
Submitted via Google Groups