Re: Sparse bit set data structure

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Sparse bit set data structure
Дата
Msg-id e7fa288d-46fa-ca0f-4b2d-a86ace86b9b7@iki.fi
обсуждение исходный текст
Ответ на Re: Sparse bit set data structure  (Julien Rouhaud <rjuju123@gmail.com>)
Ответы Re: Sparse bit set data structure
Список pgsql-hackers
Committed, thanks for the review!

I made one last-minute change: Instead of allocating a memory context in 
intset_create(), it is left to the caller. The GiST vacuum code created 
two integer sets, and it made more sense for it to use the same context 
for both. Also, the VACUUM tid list patch would like to use a memory 
context with very large defaults, so that malloc() will decide to 
mmap() it, so that the memory can be returned to the OS. Because the 
desired memory allocation varies between callers, so it's best to leave 
it to the caller.

On 20/03/2019 19:50, Julien Rouhaud wrote:
> I forgot to mention a minor gripe about the intset_binsrch_uint64 /
> intset_binsrch_leaf function, which are 99% duplicates.  But I don't
> know if fixing that (something like passing the array as a void * and
> passing a getter function?) is worth the trouble.

Yeah. I felt that it's simpler to have two almost-identical functions, 
even though it's a bit repetitive, than try to have one function serve 
both uses. The 'nextkey' argument is always passed as false to 
intset_binsrch_leaf() function, but I kept it anyway, to keep the 
functions identical. The compiler will surely optimize it away, so it 
makes no difference to performance.

On 20/03/2019 04:48, Andrey Borodin wrote:
> 1. I'm not sure it is the best interface for iteration
>
> uint64
> intset_iterate_next(IntegerSet *intset, bool *found)
> 
> we will use it like
> 
> while
> {
>      bool found;
>      BlockNumber x = (BlockNumber) intset_iterate_next(is, &found);
>      if (!found)
>          break;
>      // do stuff
> }
> 
> we could use it like
> 
> BlockNumber x;
> while(intset_iterate_next(is, &x))
> {
>      // do stuff
> }
> 
> But that's not a big difference.

Agreed, I changed it that way.

- Heikki


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Ramanarayana
Дата:
Сообщение: Re: Contribution to Perldoc for TestLib module in Postgres
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: GiST VACUUM