1 /*-------------------------------------------------------------------------
2  *
3  * sharedtuplestore.h
4  *	  Simple mechanism for sharing tuples between backends.
5  *
6  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/utils/sharedtuplestore.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef SHAREDTUPLESTORE_H
14 #define SHAREDTUPLESTORE_H
15 
16 #include "access/htup.h"
17 #include "storage/fd.h"
18 #include "storage/sharedfileset.h"
19 
20 struct SharedTuplestore;
21 typedef struct SharedTuplestore SharedTuplestore;
22 
23 struct SharedTuplestoreAccessor;
24 typedef struct SharedTuplestoreAccessor SharedTuplestoreAccessor;
25 
26 /*
27  * A flag indicating that the tuplestore will only be scanned once, so backing
28  * files can be unlinked early.
29  */
30 #define SHARED_TUPLESTORE_SINGLE_PASS 0x01
31 
32 extern size_t sts_estimate(int participants);
33 
34 extern SharedTuplestoreAccessor *sts_initialize(SharedTuplestore *sts,
35 												int participants,
36 												int my_participant_number,
37 												size_t meta_data_size,
38 												int flags,
39 												SharedFileSet *fileset,
40 												const char *name);
41 
42 extern SharedTuplestoreAccessor *sts_attach(SharedTuplestore *sts,
43 											int my_participant_number,
44 											SharedFileSet *fileset);
45 
46 extern void sts_end_write(SharedTuplestoreAccessor *accessor);
47 
48 extern void sts_reinitialize(SharedTuplestoreAccessor *accessor);
49 
50 extern void sts_begin_parallel_scan(SharedTuplestoreAccessor *accessor);
51 
52 extern void sts_end_parallel_scan(SharedTuplestoreAccessor *accessor);
53 
54 extern void sts_puttuple(SharedTuplestoreAccessor *accessor,
55 						 void *meta_data,
56 						 MinimalTuple tuple);
57 
58 extern MinimalTuple sts_parallel_scan_next(SharedTuplestoreAccessor *accessor,
59 										   void *meta_data);
60 
61 #endif							/* SHAREDTUPLESTORE_H */
62