| From: | Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | [Patch] RBTree iteration interface improvement |
| Date: | 2016-07-27 14:26:45 |
| Message-ID: | 20160727172645.3180b2e0@fujitsu |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello
While working on some new feature for PostgreSQL (which is still in
development and is irrelevant in this context) I noticed that current
RBTree implementation interface is following:
```
extern void rb_begin_iterate(RBTree *rb, RBOrderControl ctrl);
extern RBNode *rb_iterate(RBTree *rb);
```
As you see it doesn't allow to do multiple iterations over a single
tree. I believe it's a major flaw for a general-purpose container.
Proposed patch introduces a new iteration interface that doesn't has
such a flaw. Naturally I wrote some unit tests, but I was not sure where
exactly to place them in PostgreSQL source code. For now I've just
uploaded them to GitHub:
https://github.com/afiskon/c-algorithms-examples/blob/master/rbtree_example.c
According to these tests new implementation works as fast as current
implementation and produces exactly same results.
I didn't dare to remove current interface since in theory some
extensions can use it. Still I believe such a move is worth considering.
--
Best regards,
Aleksander Alekseev
| Attachment | Content-Type | Size |
|---|---|---|
| rbtree-iteration-improvement.patch | text/x-patch | 8.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2016-07-27 14:49:51 | Re: Curing plpgsql's memory leaks for statement-lifespan values |
| Previous Message | Robert Haas | 2016-07-27 14:21:19 | Re: copyParamList |