Make a Bitset which is resetable

From: Andy Fan <zhihuifan1213(at)163(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>
Subject: Make a Bitset which is resetable
Date: 2024-01-18 12:07:34
Message-ID: 87sf2uygpp.fsf@163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hi,

In [1], David and I talked about a requirement that a user just want
to unset the all bits in a Bitmapset but keep the allocated memory
un-deallocated for later use. It is impossible for the current
Bitmapset. So David suggested a Bitset struct for this purpose. I start
this new thread so that the original thread can focus on its own
purpose.

commit 0ee7e4789e58d6820e4c1ff62979910c0b01cdbb (HEAD -> s_stuck_v2)
Author: yizhi.fzh <yizhi(dot)fzh(at)alibaba-inc(dot)com>
Date: Thu Jan 18 16:52:30 2024 +0800

Introduce a Bitset data struct.

While Bitmapset is designed for variable-length of bits, Bitset is
designed for fixed-length of bits, the fixed length must be specified at
the bitset_init stage and keep unchanged at the whole lifespan. Because
of this, some operations on Bitset is simpler than Bitmapset.

The bitset_clear unsets all the bits but kept the allocated memory, this
capacity is impossible for bit Bitmapset for some solid reasons.

Also for performance aspect, the functions for Bitset removed some
unlikely checks, instead with some Asserts.

[1]
https://www.postgresql.org/message-id/CAApHDvpdp9LyAoMXvS7iCX-t3VonQM3fTWCmhconEvORrQ%2BZYA%40mail.gmail.com

Any feedback is welcome.

--
Best Regards
Andy Fan

Attachment Content-Type Size
v1-0001-Introduce-a-Bitset-data-struct.patch text/x-diff 7.0 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2024-01-18 12:09:13 Re: POC PATCH: copy from ... exceptions to: (was Re: VLDB Features)
Previous Message Andy Fan 2024-01-18 12:00:54 Re: Strange Bitmapset manipulation in DiscreteKnapsack()