Next: , Previous: , Up: Theory   [Contents][Index]


2.5 Longer Value Fields

The 256.B length limit for value strings was a barrier to many possible applications for WB. The db:get and db:put! procedures in wbscm.c work with value strings up to 64770.B in length (see SCM Record Operations).

For a value string of length L:

0.B <= L <= 255.B

The value string is stored literally with given key.

256.B <= L <= 64770.B

The first 255 bytes of the value string is stored literally with the given key. Successive 255 byte chunks of the value string are stored as L/255-1 sequential key-value pairs. The key for each chunk is the given key with the index byte 1 <= k <= 254 appended to it.

Note that use of bt:scan is complicated by long value strings.

Proposed Extensions

The rest are proposed extensions to unlimited value string length.

256.B <= L <= bsiz - 20

The b-tree value fields points to a type datalong 1 block, which contains the value.

The bsiz argument to make_seg() or block-size argument to make-seg is the size of all WB blocks (pages) in that segment.

bsiz < L

Value points to head of a chain or tree of datalong blocks. Retrieved value assembly limits practical size. Storage efficiency is good for L >> bsiz.

An interesting variant is to have two trees, one for datalongs and the other for everything else. If the two trees are in separate segments (stored in separate files), then the datalong segment blocksize can be optimized without impacting speed for non-datalong operations.

bsiz < L

Value designates external file containing data. storage efficiency is good for L >> bsiz. Retrieved value needs no assembly; use mmap().


Footnotes

(1)

This option requires a new type of WB block having the usual 20-byte header and a 2-byte length field. Each block would hold up to bsiz-20 bytes of data.


Next: Unlimited Length Keys and Values, Previous: Error Handling, Up: Theory   [Contents][Index]