PostgreSQL Source Code: src/backend/access/gin/ginbulk.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
16
17#include <limits.h>
18
22
23
24#define DEF_NENTRY 2048
25#define DEF_NPTR 5
26
27
28
29static void
31{
35
36
37
38
39 if (eo->count >= eo->maxcount)
40 {
44 errmsg("posting list is too long"),
45 errhint("Reduce \"maintenance_work_mem\".")));
46
48 eo->maxcount *= 2;
52 }
53
54
55 if (eo->shouldSort == false)
56 {
57 int res;
58
61
62 if (res > 0)
63 eo->shouldSort = true;
64 }
65
66 eo->list[eo->count] = en->list[0];
67 eo->count++;
68}
69
70
71static int
73{
77
79 ea->attnum, ea->key, ea->category,
80 eb->attnum, eb->key, eb->category);
81}
82
83
86{
89
90
91
92
93
95 {
99 }
100
101
104
106}
107
108void
110{
111
119 NULL,
120 accum);
121}
122
123
124
125
126
129{
132
134 if (att->attbyval)
136 else
137 {
140 }
141 return res;
142}
143
144
145
146
147static void
151{
154 bool isNew;
155
156
157
158
159
162 eatmp.category = category;
163
165
167 &isNew);
168
169 if (isNew)
170 {
171
172
173
174
178 ea->count = 1;
179 ea->shouldSort = false;
183 }
184 else
185 {
186
187
188
189 }
190}
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208void
213{
214 uint32 step = nentries;
215
216 if (nentries <= 0)
217 return;
218
220
221
222
223
224 step |= (step >> 1);
225 step |= (step >> 2);
226 step |= (step >> 4);
227 step |= (step >> 8);
228 step |= (step >> 16);
229 step >>= 1;
230 step++;
231
232 while (step > 0)
233 {
234 int i;
235
238 entries[i], categories[i]);
239
240 step >>= 1;
241 }
242}
243
244static int
246{
248
249
251 return res;
252}
253
254
255void
260
261
262
263
264
265
270{
273
275
276 if (entry == NULL)
277 return NULL;
278
280 *key = entry->key;
282 list = entry->list;
283 *n = entry->count;
284
286
290
291 return list;
292}
#define Assert(condition)
Datum datumCopy(Datum value, bool typByVal, int typLen)
int errcode(int sqlerrcode)
int errhint(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
#define palloc_array(type, count)
static int ginCompareItemPointers(const ItemPointerData *a, const ItemPointerData *b)
static int ginCompareAttEntries(GinState *ginstate, OffsetNumber attnuma, Datum a, GinNullCategory categorya, OffsetNumber attnumb, Datum b, GinNullCategory categoryb)
signed char GinNullCategory
static int qsortCompareItemPointers(const void *a, const void *b)
void ginBeginBAScan(BuildAccumulator *accum)
ItemPointerData * ginGetBAEntry(BuildAccumulator *accum, OffsetNumber *attnum, Datum *key, GinNullCategory *category, uint32 *n)
static void ginCombineData(RBTNode *existing, const RBTNode *newdata, void *arg)
static RBTNode * ginAllocEntryAccumulator(void *arg)
void ginInsertBAEntries(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum, Datum *entries, GinNullCategory *categories, int32 nentries)
static int cmpEntryAccumulator(const RBTNode *a, const RBTNode *b, void *arg)
void ginInitBA(BuildAccumulator *accum)
static Datum getDatumCopy(BuildAccumulator *accum, OffsetNumber attnum, Datum value)
static void ginInsertBAEntry(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum, Datum key, GinNullCategory category)
static bool ItemPointerIsValid(const ItemPointerData *pointer)
Size GetMemoryChunkSpace(void *pointer)
void * repalloc_huge(void *pointer, Size size)
#define FirstOffsetNumber
#define qsort(a, b, c, d)
static Pointer DatumGetPointer(Datum X)
RBTNode * rbt_iterate(RBTreeIterator *iter)
RBTNode * rbt_insert(RBTree *rbt, const RBTNode *data, bool *isNew)
void rbt_begin_iterate(RBTree *rbt, RBTOrderControl ctrl, RBTreeIterator *iter)
RBTree * rbt_create(Size node_size, rbt_comparator comparator, rbt_combiner combiner, rbt_allocfunc allocfunc, rbt_freefunc freefunc, void *arg)
GinEntryAccumulator * entryallocator
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)