Confusion about stage jz6 RDB file example (mismatched hashtable size?)

Hi,

In JZ6, in “RDB file format overview” and specifically in the database section, there is the following example:

FE                       // Indicates the start of a database subsection.
00                       /* The index of the database (size encoded).
                            Here, the index is 0. */

FB                       // Indicates that hash table size information follows.
02                       /* The size of the hash table that stores the keys and values (size encoded).
                            Here, the key-value hash table size is 2. */
01                       /* The size of the hash table that stores the expires of the keys (size encoded).
                            Here, the expire hash table size is 1. */

00                       /* The 1-byte flag that specifies the value’s type and encoding.
                            Here, the flag is 0, which means "string." */
06 66 6F 6F 62 61 72     // The name of the key (string encoded). Here, it's "foobar".
06 62 61 7A 71 75 78     // The value (string encoded). Here, it's "bazqux".

FC                       /* Indicates that this key has an expire,
                            and that the expire timestamp is expressed in milliseconds. */
15 72 E7 07 8F 01 00 00  /* The expire timestamp, expressed in Unix time,
                            stored as an 8-byte unsigned long, in little-endian (read right-to-left).
                            Here, the expire timestamp is 1713824559637. */
00                       // Value type is string.
03 66 6F 6F              // Key name is "foo".
03 62 61 72              // Value is "bar".

FD                       /* Indicates that this key has an expire,
                            and that the expire timestamp is expressed in seconds. */
52 ED 2A 66              /* The expire timestamp, expressed in Unix time,
                            stored as an 4-byte unsigned integer, in little-endian (read right-to-left).
                            Here, the expire timestamp is 1714089298. */
00                       // Value type is string.
03 62 61 7A              // Key name is "baz".
03 71 75 78              // Value is "qux".

Here, the hashtable size is given as 2, and the expiry hash table size as 1. My understanding is that this basically tells you the total number of entries, and the total number of entires with expiries respectively. However, in this example, there are clearly three entries (foobar:bazqux, foo:bar, and baz:qux) the latter two of which have expiries.

What am I missing here?

1 Like

@RangeetC Thanks for highlighting this! Sorry, the two numbers (02 01) after FB are incorrect. @ryan-gang is fixing them via this PR.

They should have been 03 and 02 respectively, indicating that there are 3 key-value pairs, and 2 of them have expiry timestamps attached.​

Here is a correct example from our tester:

Notice fb 05 05 and there are five key-value pairs with expiry.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.