forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb840508
committed
Add functions to binaryheap for efficient key removal and update.
Previously, binaryheap didn't support updating a key and removing anode in an efficient way. For example, in order to remove a node fromthe binaryheap, the caller had to pass the node's position within thearray that the binaryheap internally has. Removing a node from thebinaryheap is done in O(log n) but searching for the key's position isdone in O(n).This commit adds a hash table to binaryheap in order to track theposition of each nodes in the binaryheap. That way, by using newlyadded functions such as binaryheap_update_up() etc., both updating akey and removing a node can be done in O(1) on an average and O(log n)in worst case. This is known as the indexed binary heap. The callercan specify to use the indexed binaryheap by passing indexed = true.The current code does not use the new indexing logic, but it will beused by an upcoming patch.Reviewed-by: Vignesh C, Peter Smith, Hayato Kuroda, Ajin Cherian,Tomas Vondra, Shubham KhannaDiscussion:https://postgr.es/m/CAD21AoDffo37RC-eUuyHJKVEr017V2YYDLyn1xF_00ofptWbkg%40mail.gmail.com1 parentbcb14f4 commitb840508
File tree
10 files changed
+232
-14
lines changed- src
- backend
- executor
- postmaster
- replication/logical
- storage/buffer
- bin/pg_dump
- common
- include/lib
- tools/pgindent
10 files changed
+232
-14
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
422 | 422 |
| |
423 | 423 |
| |
424 | 424 |
| |
| 425 | + | |
425 | 426 |
| |
426 | 427 |
| |
427 | 428 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
125 | 125 |
| |
126 | 126 |
| |
127 | 127 |
| |
128 |
| - | |
| 128 | + | |
129 | 129 |
| |
130 | 130 |
| |
131 | 131 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
254 | 254 |
| |
255 | 255 |
| |
256 | 256 |
| |
257 |
| - | |
| 257 | + | |
| 258 | + | |
258 | 259 |
| |
259 | 260 |
| |
260 | 261 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1294 | 1294 |
| |
1295 | 1295 |
| |
1296 | 1296 |
| |
| 1297 | + | |
1297 | 1298 |
| |
1298 | 1299 |
| |
1299 | 1300 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3014 | 3014 |
| |
3015 | 3015 |
| |
3016 | 3016 |
| |
| 3017 | + | |
3017 | 3018 |
| |
3018 | 3019 |
| |
3019 | 3020 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4200 | 4200 |
| |
4201 | 4201 |
| |
4202 | 4202 |
| |
| 4203 | + | |
4203 | 4204 |
| |
4204 | 4205 |
| |
4205 | 4206 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
405 | 405 |
| |
406 | 406 |
| |
407 | 407 |
| |
408 |
| - | |
| 408 | + | |
409 | 409 |
| |
410 | 410 |
| |
411 | 411 |
| |
|
Lines changed: 188 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
| 25 | + | |
25 | 26 |
| |
26 | 27 |
| |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
27 | 49 |
| |
28 | 50 |
| |
29 | 51 |
| |
| |||
34 | 56 |
| |
35 | 57 |
| |
36 | 58 |
| |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
37 | 63 |
| |
38 | 64 |
| |
39 |
| - | |
| 65 | + | |
| 66 | + | |
40 | 67 |
| |
41 | 68 |
| |
42 | 69 |
| |
| |||
48 | 75 |
| |
49 | 76 |
| |
50 | 77 |
| |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
51 | 89 |
| |
52 | 90 |
| |
53 | 91 |
| |
| |||
63 | 101 |
| |
64 | 102 |
| |
65 | 103 |
| |
| 104 | + | |
| 105 | + | |
| 106 | + | |
66 | 107 |
| |
67 | 108 |
| |
68 | 109 |
| |
| |||
73 | 114 |
| |
74 | 115 |
| |
75 | 116 |
| |
| 117 | + | |
| 118 | + | |
| 119 | + | |
76 | 120 |
| |
77 | 121 |
| |
78 | 122 |
| |
| |||
115 | 159 |
| |
116 | 160 |
| |
117 | 161 |
| |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
118 | 223 |
| |
119 | 224 |
| |
120 | 225 |
| |
| |||
131 | 236 |
| |
132 | 237 |
| |
133 | 238 |
| |
134 |
| - | |
| 239 | + | |
135 | 240 |
| |
136 | 241 |
| |
137 | 242 |
| |
| |||
164 | 269 |
| |
165 | 270 |
| |
166 | 271 |
| |
167 |
| - | |
| 272 | + | |
168 | 273 |
| |
169 | 274 |
| |
170 | 275 |
| |
| |||
205 | 310 |
| |
206 | 311 |
| |
207 | 312 |
| |
| 313 | + | |
| 314 | + | |
208 | 315 |
| |
209 | 316 |
| |
210 | 317 |
| |
211 | 318 |
| |
212 | 319 |
| |
213 | 320 |
| |
214 | 321 |
| |
215 |
| - | |
| 322 | + | |
216 | 323 |
| |
217 | 324 |
| |
218 | 325 |
| |
| |||
238 | 345 |
| |
239 | 346 |
| |
240 | 347 |
| |
241 |
| - | |
| 348 | + | |
242 | 349 |
| |
243 | 350 |
| |
244 | 351 |
| |
| |||
247 | 354 |
| |
248 | 355 |
| |
249 | 356 |
| |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
250 | 428 |
| |
251 | 429 |
| |
252 | 430 |
| |
| |||
259 | 437 |
| |
260 | 438 |
| |
261 | 439 |
| |
262 |
| - | |
| 440 | + | |
263 | 441 |
| |
264 | 442 |
| |
265 | 443 |
| |
| |||
301 | 479 |
| |
302 | 480 |
| |
303 | 481 |
| |
304 |
| - | |
| 482 | + | |
305 | 483 |
| |
306 | 484 |
| |
307 | 485 |
| |
308 |
| - | |
| 486 | + | |
309 | 487 |
| |
310 | 488 |
| |
311 | 489 |
| |
| |||
360 | 538 |
| |
361 | 539 |
| |
362 | 540 |
| |
363 |
| - | |
| 541 | + | |
364 | 542 |
| |
365 | 543 |
| |
366 | 544 |
| |
367 |
| - | |
| 545 | + | |
368 | 546 |
|
0 commit comments
Comments
(0)