1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* hashjoin.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* internal structures for hash table and buckets
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
1999-05-09 02:53:22 +02:00
|
|
|
* $Id: hashjoin.h,v 1.10 1999/05/09 00:53:18 tgl Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef HASHJOIN_H
|
1996-07-09 08:22:35 +02:00
|
|
|
#define HASHJOIN_H
|
|
|
|
|
1996-11-04 09:53:07 +01:00
|
|
|
#include <storage/ipc.h>
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* -----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* have to use relative address as pointers in the hashtable
|
1999-05-06 02:30:47 +02:00
|
|
|
* because the hashtable may reallocate in different processes
|
|
|
|
*
|
|
|
|
* XXX: this relative-address stuff is useless on all supported platforms
|
|
|
|
* and is a ever-dangerous source of bugs. Really ought to rip it out.
|
1996-07-09 08:22:35 +02:00
|
|
|
* -----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
typedef int RelativeAddr;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* ------------------
|
1999-05-06 02:30:47 +02:00
|
|
|
* The relative addresses are always relative to the head of the
|
|
|
|
* hashtable, the following macros convert them to/from absolute address.
|
|
|
|
* NULL is represented as -1 (CAUTION: RELADDR() doesn't handle that!).
|
|
|
|
* CAUTION: ABSADDR evaluates its arg twice!!
|
1996-07-09 08:22:35 +02:00
|
|
|
* ------------------
|
|
|
|
*/
|
1999-05-06 02:30:47 +02:00
|
|
|
#define ABSADDR(X) ((X) < 0 ? (char*) NULL : (char*)hashtable + (X))
|
|
|
|
#define RELADDR(X) ((RelativeAddr)((char*)(X) - (char*)hashtable))
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
typedef char **charPP;
|
|
|
|
typedef int *intP;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* hash-join hash table structures
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct HashTableData
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int nbuckets;
|
|
|
|
int totalbuckets;
|
|
|
|
int bucketsize;
|
|
|
|
IpcMemoryId shmid;
|
|
|
|
RelativeAddr top; /* char* */
|
|
|
|
RelativeAddr bottom; /* char* */
|
|
|
|
RelativeAddr overflownext; /* char* */
|
|
|
|
RelativeAddr batch; /* char* */
|
|
|
|
RelativeAddr readbuf; /* char* */
|
|
|
|
int nbatch;
|
|
|
|
RelativeAddr outerbatchPos; /* RelativeAddr* */
|
|
|
|
RelativeAddr innerbatchPos; /* RelativeAddr* */
|
|
|
|
RelativeAddr innerbatchSizes; /* int* */
|
|
|
|
int curbatch;
|
|
|
|
int nprocess;
|
|
|
|
int pcount;
|
1997-09-08 23:56:23 +02:00
|
|
|
} HashTableData; /* real hash table follows here */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef HashTableData *HashJoinTable;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct OverflowTupleData
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
RelativeAddr tuple; /* HeapTuple */
|
|
|
|
RelativeAddr next; /* struct OverflowTupleData * */
|
1997-09-08 23:56:23 +02:00
|
|
|
} OverflowTupleData; /* real tuple follows here */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
typedef OverflowTupleData *OverflowTuple;
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct HashBucketData
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
RelativeAddr top; /* HeapTuple */
|
|
|
|
RelativeAddr bottom; /* HeapTuple */
|
|
|
|
RelativeAddr firstotuple; /* OverflowTuple */
|
|
|
|
RelativeAddr lastotuple; /* OverflowTuple */
|
1997-09-08 23:56:23 +02:00
|
|
|
} HashBucketData; /* real bucket follows here */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef HashBucketData *HashBucket;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* HASHJOIN_H */
|