On Tue, Jul 17, 2012 at 8:46 AM, Steven E. Harris <s...@panix.com> wrote:
> Per my recent posted messages here, I've been studying the data formats > for SQLite4. This question concerns the key encoding and how it is used. > > It's clear that the key encoding format is designed to allow > lexicographic ordering of compound keys comprising concatenated > attribute values, and that it's possible to do ranged searches against a > prefix of a key. The main use involves a query encoding a whole or > partial key, and then searching against the database to see if it finds > a match. > > Does SQLite ever need to /decode/ an encoded key? > It would be convenient to be able to decode the keys. But it is not possible to do so, in general. Many keys can be decoded, but for TEXT keys with application-defined collating sequences, the encoding is not reversible. Many applications will use the ucol_getSortkey() interface to ICU to get the TEXT keys, and there is no way to reverse that encoding to recover the original text. > > I can imagine a case where it might, such as using the encoded compound > keys as an index when looking only for a match against some prefix, such > as the first attribute of three attributes in the key. In that case, the > remaining values in the key may need to be decoded in order to return > them as results for the query -- unless those attribute values in the > key are already duplicated in the record value. > > The key encoding format looks like it's possible to decode, as the > beginning and end of each data type are detectable: null terminates a > binary value and a string value, and a byte with the low bit clear > terminates a number's mantissa. It's hard to tell whether this decoding > is ever necessary, though. > > -- > Steven E. Harris > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users