Hey folks, I have a newbie developer question. I'm currently taking a
course called Database Systems & Implementation at Rochester Institute of
Technology and we've split up into groups and are working on extending
Postgres to get some experience with a real-world DBMS (as well as the
open-source initiative). My group is working on implementing the UNIQUE
functionality in indexes other than the b-tree (which is a TODO item on the
postgres website). We've been digging through the src/backend/access/hash/
and we're having a hard time figuring out the correct way to walk through
items in a page. Is this what the hashbeginscan() method is for? If so,
what should we provide for the keysz and scankey parameters?
backend/access/index/genam.c says these parameters are "key count" and "scan
key" respectively, but I'm still sort of lost on what these should be and
how we get them (I couldn't find any code that actually called the
hashbeginscan() function to use as reference).

Bear with me...I know it's the last thing you all want to hear but I'm more
a java developer than a C one, but I'm workin' on it :-D. Is there some
sort of reference equivalent of Javadocs that would show all the files, the
functions, the descriptions of the parameters, etc? As of now, we're just
grepping the code to find where else specific functions are used and trying
to figure it all out that way.

Thanks so much for the help (now and for the stuff in the future I'm sure
I'll be bugging you all about).


-Matt

Search Discussions

  • Tom Lane at Feb 1, 2007 at 6:22 am

    "Matthew Campbell" <mtthw.cmpbll@gmail.com> writes:
    ... We've been digging through the src/backend/access/hash/
    and we're having a hard time figuring out the correct way to walk through
    items in a page. Is this what the hashbeginscan() method is for?
    No, hashbeginscan doesn't do much at all except initialize state. The
    interesting stuff happens during successive hashgettuple calls ---
    specifically _hash_first the first time and _hash_next on later calls.

    regards, tom lane
  • Matthew Campbell at Feb 1, 2007 at 4:58 pm
    Thanks so much for the help. _hash_first, and _hash_next all take the scan
    object as a parameter. How do you create or get a scan object?
    hashbeginscan looks like it sets up a scan and returns it, but it takes the
    number of keys and the array of scan keys. Where do we get these arguments
    from?


    -Matt
    On 2/1/07, Tom Lane wrote:

    "Matthew Campbell" <mtthw.cmpbll@gmail.com> writes:
    ... We've been digging through the src/backend/access/hash/
    and we're having a hard time figuring out the correct way to walk through
    items in a page. Is this what the hashbeginscan() method is for?
    No, hashbeginscan doesn't do much at all except initialize state. The
    interesting stuff happens during successive hashgettuple calls ---
    specifically _hash_first the first time and _hash_next on later calls.

    regards, tom lane
  • Tom Lane at Feb 1, 2007 at 5:57 pm

    "Matthew Campbell" <mtthw.cmpbll@gmail.com> writes:
    hashbeginscan looks like it sets up a scan and returns it, but it takes the
    number of keys and the array of scan keys. Where do we get these arguments
    from?
    You should probably go read the btree code for awhile to see how it's
    done there. The btree insertion code manufactures some scan keys from
    the index tuple given to be inserted, which is what it uses to locate
    the correct insertion point in the index (and, hence, any potential
    conflicting entries). But actually I'm not sure that you care about
    that for hash --- all you really need is to know which bucket to look
    in, and IIRC the hash insertion code calculates that already without
    bothering with making scankeys.

    regards, tom lane

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedFeb 1, '07 at 3:38a
activeFeb 1, '07 at 5:57p
posts4
users2
websitepostgresql.org
irc#postgresql

2 users in discussion

Matthew Campbell: 2 posts Tom Lane: 2 posts

People

Translate

site design / logo © 2022 Grokbase