summaryrefslogtreecommitdiff
path: root/src/include/utils/lselect.h
blob: d5498df779a5fdd1e97bd68a78a8aa9a77e20892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*-------------------------------------------------------------------------
 *
 * lselect.h--
 *	  definitions for the replacement selection algorithm.
 *
 *
 * Copyright (c) 1994, Regents of the University of California
 *
 * $Id: lselect.h,v 1.5 1997/09/07 05:02:38 momjian Exp $
 *
 *-------------------------------------------------------------------------
 */
#ifndef LSELECT_H
#define LSELECT_H

#include <stdio.h>
#include "access/htup.h"

struct leftist
{
	short			lt_dist;	/* distance to leaf/empty node */
	short			lt_devnum;	/* device number of tuple */
	HeapTuple		lt_tuple;
	struct leftist *lt_left;
	struct leftist *lt_right;
};

/* replaces global variables in lselect.c to make it reentrant */
typedef struct
{
	TupleDesc		tupDesc;
	int				nKeys;
	ScanKey			scanKeys;
	int				sortMem;	/* needed for psort */
}				LeftistContextData;
typedef LeftistContextData *LeftistContext;

extern struct leftist *
lmerge(struct leftist * pt, struct leftist * qt,
	   LeftistContext context);
extern HeapTuple
gettuple(struct leftist ** treep, short *devnum,
		 LeftistContext context);
extern void
puttuple(struct leftist ** treep, HeapTuple newtuple, short devnum,
		 LeftistContext context);
extern int		tuplecmp(HeapTuple ltup, HeapTuple rtup, LeftistContext context);

#ifdef EBUG
extern void		checktree(struct leftist * tree, LeftistContext context);
extern int		checktreer(struct leftist * tree, int level, LeftistContext context);

#endif							/* EBUG */

#endif							/* LSELECT_H */