aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2006-06-28 12:00:14 +0000
committerTeodor Sigaev <teodor@sigaev.ru>2006-06-28 12:00:14 +0000
commit1f7ef548ec2e594fa8766781c490fb5b998ea46b (patch)
treea552894bd93658d85c7136d00042c4b05e19a9a6 /src/include
parenta1dc5c60bcd4c458e160bf0e355bed083a1cab57 (diff)
downloadpostgresql-1f7ef548ec2e594fa8766781c490fb5b998ea46b.tar.gz
postgresql-1f7ef548ec2e594fa8766781c490fb5b998ea46b.zip
Changes
* new split algorithm (as proposed in http://archives.postgresql.org/pgsql-hackers/2006-06/msg00254.php) * possible call pickSplit() for second and below columns * add spl_(l|r)datum_exists to GIST_SPLITVEC - pickSplit should check its values to use already defined spl_(l|r)datum for splitting. pickSplit should set spl_(l|r)datum_exists to 'false' (if they was 'true') to signal to caller about using spl_(l|r)datum. * support for old pickSplit(): not very optimal but correct split * remove 'bytes' field from GISTENTRY: in any case size of value is defined by it's type. * split GIST_SPLITVEC to two structures: one for using in picksplit and second - for internal use. * some code refactoring * support of subsplit to rtree opclasses TODO: add support of subsplit to contrib modules
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/gist.h31
-rw-r--r--src/include/access/gist_private.h67
2 files changed, 49 insertions, 49 deletions
diff --git a/src/include/access/gist.h b/src/include/access/gist.h
index cfa07f2be52..55d7634a73d 100644
--- a/src/include/access/gist.h
+++ b/src/include/access/gist.h
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/gist.h,v 1.53 2006/06/25 01:02:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/gist.h,v 1.54 2006/06/28 12:00:14 teodor Exp $
*
*-------------------------------------------------------------------------
*/
@@ -75,37 +75,29 @@ 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...
*/
typedef struct GIST_SPLITVEC
{
OffsetNumber *spl_left; /* array of entries that go left */
int spl_nleft; /* size of this array */
Datum spl_ldatum; /* Union of keys in spl_left */
- Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in
- * spl_left */
- int spl_lattrsize[INDEX_MAX_KEYS];
- bool spl_lisnull[INDEX_MAX_KEYS];
- bool spl_leftvalid;
+ bool spl_ldatum_exists; /* true, if spl_ldatum already exists. */
OffsetNumber *spl_right; /* array of entries that go right */
int spl_nright; /* size of the array */
Datum spl_rdatum; /* Union of keys in spl_right */
- Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in
- * spl_right */
- int spl_rattrsize[INDEX_MAX_KEYS];
- bool spl_risnull[INDEX_MAX_KEYS];
- bool spl_rightvalid;
-
- int *spl_idgrp;
- int *spl_ngrp; /* number in each group */
- char *spl_grpflag; /* flags of each group */
+ bool spl_rdatum_exists; /* true, if spl_rdatum already exists. */
} GIST_SPLITVEC;
/*
* An entry on a GiST node. Contains the key, as well as its own
* location (rel,page,offset) which can supply the matching pointer.
- * The size of the key is in bytes, and leafkey is a flag to tell us
- * if the entry is in a leaf node.
+ * leafkey is a flag to tell us if the entry is in a leaf node.
*/
typedef struct GISTENTRY
{
@@ -113,7 +105,6 @@ typedef struct GISTENTRY
Relation rel;
Page page;
OffsetNumber offset;
- int bytes;
bool leafkey;
} GISTENTRY;
@@ -147,8 +138,8 @@ typedef struct
/*
* macro to initialize a GISTENTRY
*/
-#define gistentryinit(e, k, r, pg, o, b, l) \
+#define gistentryinit(e, k, r, pg, o, l) \
do { (e).key = (k); (e).rel = (r); (e).page = (pg); \
- (e).offset = (o); (e).bytes = (b); (e).leafkey = (l); } while (0)
+ (e).offset = (o); (e).leafkey = (l); } while (0)
#endif /* GIST_H */
diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h
index f75682847a6..7a55a312168 100644
--- a/src/include/access/gist_private.h
+++ b/src/include/access/gist_private.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.17 2006/05/29 12:50:06 teodor Exp $
+ * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.18 2006/06/28 12:00:14 teodor Exp $
*
*-------------------------------------------------------------------------
*/
@@ -180,6 +180,21 @@ typedef struct GISTInsertStack
struct GISTInsertStack *next;
} GISTInsertStack;
+typedef struct GistSplitVector {
+ GIST_SPLITVEC splitVector; /* to/from PickSplit method */
+
+ Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in spl_left */
+ bool spl_lisnull[INDEX_MAX_KEYS];
+ bool spl_leftvalid;
+
+ Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in spl_right */
+ bool spl_risnull[INDEX_MAX_KEYS];
+ bool spl_rightvalid;
+
+ bool *spl_equiv; /* equivalent tuples which can be freely
+ * distributed between left and right pages */
+} GistSplitVector;
+
#define XLogRecPtrIsInvalid( r ) ( (r).xlogid == 0 && (r).xrecoff == 0 )
typedef struct
@@ -206,12 +221,6 @@ typedef struct
/* root page of a gist index */
#define GIST_ROOT_BLKNO 0
-#define ATTSIZE(datum, tupdesc, i, isnull) \
- ( \
- (isnull) ? 0 : \
- att_addlength(0, (tupdesc)->attrs[(i)-1]->attlen, (datum)) \
- )
-
/*
* mark tuples on inner pages during recovery
*/
@@ -281,7 +290,7 @@ extern IndexTuple gistgetadjusted(Relation r,
IndexTuple addtup,
GISTSTATE *giststate);
extern IndexTuple gistFormTuple(GISTSTATE *giststate,
- Relation r, Datum *attdata, int *datumsize, bool *isnull);
+ Relation r, Datum *attdata, bool *isnull, bool newValues);
extern OffsetNumber gistchoose(Relation r, Page p,
IndexTuple it,
@@ -289,34 +298,34 @@ extern OffsetNumber gistchoose(Relation r, Page p,
extern void gistcentryinit(GISTSTATE *giststate, int nkey,
GISTENTRY *e, Datum k,
Relation r, Page pg,
- OffsetNumber o, int b, bool l, bool isNull);
-extern void gistDeCompressAtt(GISTSTATE *giststate, Relation r,
- IndexTuple tuple, Page p, OffsetNumber o,
- GISTENTRY *attdata, bool *isnull);
-
-typedef struct {
- int *attrsize;
- Datum *attr;
- int len;
- OffsetNumber *entries;
- bool *isnull;
- int *idgrp;
-} GistSplitVec;
-
-extern void gistunionsubkeyvec(GISTSTATE *giststate,
- IndexTuple *itvec, GistSplitVec *gsvp, int startkey);
-extern void gistunionsubkey(GISTSTATE *giststate, IndexTuple *itvec,
- GIST_SPLITVEC *spl, int attno);
+ OffsetNumber o, bool l, bool isNull);
extern void GISTInitBuffer(Buffer b, uint32 f);
extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
Datum k, Relation r, Page pg, OffsetNumber o,
- int b, bool l, bool isNull);
-bool gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GIST_SPLITVEC *v,
- IndexTuple *itup, int len, GISTSTATE *giststate);
+ bool l, bool isNull);
+
+extern float gistpenalty(GISTSTATE *giststate, int attno,
+ GISTENTRY *key1, bool isNull1,
+ GISTENTRY *key2, bool isNull2);
+extern bool gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, int startkey,
+ Datum *attr, bool *isnull );
+extern bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b);
+extern void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
+ OffsetNumber o, GISTENTRY *attdata, bool *isnull);
+
+extern void gistMakeUnionKey( GISTSTATE *giststate, int attno,
+ GISTENTRY *entry1, bool isnull1,
+ GISTENTRY *entry2, bool isnull2,
+ Datum *dst, bool *dstisnull );
/* gistvacuum.c */
extern Datum gistbulkdelete(PG_FUNCTION_ARGS);
extern Datum gistvacuumcleanup(PG_FUNCTION_ARGS);
+/* gistsplit.c */
+extern void gistSplitByKey(Relation r, Page page, IndexTuple *itup,
+ int len, GISTSTATE *giststate,
+ GistSplitVector *v, GistEntryVector *entryvec,
+ int attno);
#endif /* GIST_PRIVATE_H */