pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
OffsetNumber, picksplit, and GiST
2+ messages / 1 participants
[nested] [flat]

* OffsetNumber, picksplit, and GiST
@ 2003-02-26 03:29  Itai Zukerman <zukerman@math-hat.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Itai Zukerman @ 2003-02-26 03:29 UTC (permalink / raw)
  To: pgsql-sql

Is the GiST examples I've looked through, in the picksplit functions,
I see code that looks roughly like this:

  bytea *entryvec = (bytea *) PG_GETARG_POINTER(0);
  OffsetNumber i, maxoff;

  maxoff = ((VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY)) - 1;

  for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
    {
      ... DatumGetPointer((((GISTENTRY *) (VARDATA(entryvec)))[i].key)) ...
    }

I'm wondering, since FirstOffsetNumber is 1, what about the 0'th index
in entryvec?  Is it just not set?

Also, is there some rationalle for using OffsetNumber in
GIST_SPLITVEC?  I see in off.h:

  /*
   * OffsetNumber:
   *
   * this is a 1-based index into the linp (ItemIdData) array in the
   * header of each disk page.
   */

and I don't get the connection with what picksplit is doing (keeping
in mind that I don't know what "linp", "ItemIdData" or "disk page"
mean).

I have a very tenuous understanding of all this, so please bear with me.

-- 
Itai Zukerman  <http://www.math-hat.com/~zukerman/;



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: OffsetNumber, picksplit, and GiST
@ 2003-02-26 15:54  Itai Zukerman <zukerman@math-hat.com>
  parent: Itai Zukerman <zukerman@math-hat.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Itai Zukerman @ 2003-02-26 15:54 UTC (permalink / raw)
  To: pgsql-sql

> Is the GiST examples I've looked through, in the picksplit functions,
> I see code that looks roughly like this:
>
>   bytea *entryvec = (bytea *) PG_GETARG_POINTER(0);
>   OffsetNumber i, maxoff;
>
>   maxoff = ((VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY)) - 1;
>
>   for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
>     {
>       ... DatumGetPointer((((GISTENTRY *) (VARDATA(entryvec)))[i].key)) ...
>     }
>
> I'm wondering, since FirstOffsetNumber is 1, what about the 0'th index
> in entryvec?  Is it just not set?

In backend/access/gist/gist.c I see how entryvec is built:

   storage = palloc(MAXALIGN(VARHDRSZ) + (*len + 1) * sizeof(GISTENTRY));
   entryvec = (bytea *) (storage + MAXALIGN(VARHDRSZ) - VARHDRSZ);
   decompvec = (bool *) palloc((*len + 1) * sizeof(bool));
   VARATT_SIZEP(entryvec) = (*len + 1) * sizeof(GISTENTRY) + VARHDRSZ;
   for (i = 1; i <= *len; i++)
   {
     [...] gistdentryinit(giststate, 0, &((GISTENTRY *) VARDATA(entryvec))[i], [...]
   }

So it looks like the 0'th entry indeed is empty.  Why?

Also, in gist.c the index "i" has type "int".  No mention of
OffsetNumber anywhere.  Any reason for that?

Finally, should I be asking this on pgsql-hackers?

-- 
Itai Zukerman  <http://www.math-hat.com/~zukerman/;



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-02-26 15:54 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-02-26 03:29 OffsetNumber, picksplit, and GiST Itai Zukerman <zukerman@math-hat.com>
2003-02-26 15:54 ` Itai Zukerman <zukerman@math-hat.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox