diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-02-10 11:58:28 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-02-10 11:58:28 -0500 |
commit | a0698406f4c8b4944c6e248c7e8672c4f54db01a (patch) | |
tree | 47582307aa268e5e220e3cf49970ceb57965c2b2 /src/include/access/gist.h | |
parent | 4d4c00850dedb4395138d825cfa3c69545c17f0b (diff) | |
download | postgresql-a0698406f4c8b4944c6e248c7e8672c4f54db01a.tar.gz postgresql-a0698406f4c8b4944c6e248c7e8672c4f54db01a.zip |
Document and clean up gistsplit.c.
Improve comments, rename some variables and functions, slightly simplify
a couple of APIs, in an attempt to make this code readable by people other
than its original author.
Even though this is essentially just cosmetic, back-patch to all active
branches, because otherwise it's going to make back-patching future fixes
in this file very painful.
Diffstat (limited to 'src/include/access/gist.h')
-rw-r--r-- | src/include/access/gist.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/include/access/gist.h b/src/include/access/gist.h index df9f39c7b89..22a440cf0f9 100644 --- a/src/include/access/gist.h +++ b/src/include/access/gist.h @@ -85,11 +85,30 @@ typedef GISTPageOpaqueData *GISTPageOpaque; /* * This is the Split Vector to be returned by the PickSplit method. - * PickSplit should check spl_(r|l)datum_exists. If it is 'true', - * that corresponding spl_(r|l)datum already defined and - * PickSplit should use that value. PickSplit should always set - * spl_(r|l)datum_exists to false: GiST will check value to - * control supportng this feature by PickSplit... + * PickSplit should fill the indexes of tuples to go to the left side into + * spl_left[], and those to go to the right into spl_right[] (note the method + * is responsible for palloc'ing both of these arrays!). The tuple counts + * go into spl_nleft/spl_nright, and spl_ldatum/spl_rdatum must be set to + * the union keys for each side. + * + * If spl_ldatum_exists and spl_rdatum_exists are true, then we are performing + * a "secondary split" using a non-first index column. In this case some + * decisions have already been made about a page split, and the set of tuples + * being passed to PickSplit is just the tuples about which we are undecided. + * spl_ldatum/spl_rdatum then contain the union keys for the tuples already + * chosen to go left or right. Ideally the PickSplit method should take those + * keys into account while deciding what to do with the remaining tuples, ie + * it should try to "build out" from those unions so as to minimally expand + * them. If it does so, it should union the given tuples' keys into the + * existing spl_ldatum/spl_rdatum values rather than just setting those values + * from scratch, and then set spl_ldatum_exists/spl_rdatum_exists to false to + * show it has done this. + * + * If the PickSplit method fails to clear spl_ldatum_exists/spl_rdatum_exists, + * the core GiST code will make its own decision about how to merge the + * secondary-split results with the previously-chosen tuples, and will then + * recompute the union keys from scratch. This is a workable though often not + * optimal approach. */ typedef struct GIST_SPLITVEC { |