Forum OpenACS Development: Re: tree_sortkey varbit limitations

Collapse
Posted by Don Baccus on
Yes, that's it exactly, Tom - at the 7 bit limit I add a leading 1 and 31 bits of key data.

This ensures that 128 > 127 when compared as bitstrings:

127 = 01111111
128 = 10000000000000000000000010000000

PG bitstrings are compared just like bytestrings, in other words they're matched bit-by-bit until there's a mismatch, then the larger bit wins.

A little thought should convince you that this works for sortkeys attached to nodes at any level in the tree, of any number.