#168 Facet indices

brian Sun 30 Dec 2007

I finally have the basics working for facet indices. The basic idea is that any pod can declare that a specific facet should be indexed to create a mapping of facet values to types. An example would be to map URI schemes to handler Types. The surface area of this feature is pretty small:

// any build file can declare a facet to be indexed via pod level facets:
podFacets  = ["indexFacets":["uriScheme"]]

// types annotate themselves with that facet
@uriScheme="ftp" class FtpHandler {}
@uriScheme="http" class HttpHandler {}

// query by facet
handler := Type.findByFacet("uriScheme", "ftp").first

Of course under the covers is a brand new mini-framework - the type database. It scans pods to see if anything has changed, and if so rebuilds all the indexes in a binary file called "/lib/types.db". The indexes themselves are lazy loaded when needed.

This feature requires compiler changes - each pod now includes a "typedb.def" file generated to make building the overall type indexes faster. So I'll be doing a new build shortly.

brian Mon 31 Dec 2007

OK - the type database is finished (at least for now). There are lots of hooks to do future stuff like index subtypes, etc. But for now it does one thing - build facet indexes. Facet indexes are also the mechanism used to create type-to-type relationships (when facet values are type literals).

I wrote a new chapter describing this feature: docLang::TypeDatabase

Login or Signup to reply.