| PostgreSQL 8.3.3 Documentation | ||||
|---|---|---|---|---|
| Prev | Fast Backward | Chapter 52. GIN Indexes | Fast Forward | Next |
The GIN interface has a high level of abstraction, requiring the access method implementer only to implement the semantics of the data type being accessed. The GIN layer itself takes care of concurrency, logging and searching the tree structure.
All it takes to get a GIN access method working is to implement four user-defined methods, which define the behavior of keys in the tree and the relationships between keys, indexed values, and indexable queries. In short, GIN combines extensibility with generality, code reuse, and a clean interface.
The four methods that an index operator class for GIN must provide are:
Compares keys (not indexed values!) and returns an integer less than zero, zero, or greater than zero, indicating whether the first key is less than, equal to, or greater than the second.
Returns an array of keys given a value to be indexed. The number of returned keys must be stored into *nkeys.
Returns an array of keys given a value to be queried; that is, query is the value on the right-hand side of an indexable operator whose left-hand side is the indexed column. n is the strategy number of the operator within the operator class (see Section 34.14.2). Often, extractQuery will need to consult n to determine the data type of query and the key values that need to be extracted. The number of returned keys must be stored into *nkeys. If number of keys is equal to zero then extractQuery should store 0 or -1 into *nkeys. 0 means that any row matches the query and sequence scan should be produced. -1 means nothing can satisfy query. Choice of value should be based on semantics meaning of operation with given strategy number.
Returns TRUE if the indexed value satisfies the query operator with strategy number n (or would satisfy, if the operator is marked RECHECK in the operator class). The check array has the same length as the number of keys previously returned by extractQuery for this query. Each element of the check array is TRUE if the indexed value contains the corresponding query key, ie, if (check[i] == TRUE) the i-th key of the extractQuery result array is present in the indexed value. The original query datum (not the extracted key array!) is passed in case the consistent method needs to consult it.
No comments could be found for this page.
Please use this form to add your own comments regarding your experience with particular features of PostgreSQL, clarifications of the documentation, or hints for other users. Please note, this is not a support forum, and your IP address will be logged. If you have a question or need help, please see the faq, try a mailing list, or join us on IRC. Note that submissions containing URLs or other keywords commonly found in 'spam' comments may be silently discarded. Please contact the webmaster if you think this is happening to you in error.
In order to submit a comment, you must have a community account.
* denotes required field