public inbox for [email protected]
help / color / mirror / Atom feedFrom: Greg Burd <[email protected]>
To: David Rowley <[email protected]>
To: Tom Lane <[email protected]>
Cc: Chao Li <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Add bms_offset_members() function for bitshifting Bitmapsets
Date: Sun, 19 Apr 2026 15:21:41 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAApHDvrp6JwOVH3VwMB=YL3p97F5_0hKJc7J8zHRKuyhKru1dA@mail.gmail.com>
References: <CAApHDvq=eEdw2Qp+aSzSOtTSe+h0fnVQ55CcTNqBkLDYiRZmxw@mail.gmail.com>
<[email protected]>
<CAApHDvoALVPgVSCuGdAfNUbxx_NacnAd0nuj8Hi=_-61AEqzaQ@mail.gmail.com>
<[email protected]>
<CAApHDvq4_WDfTaWX6nHU8TV+no+aD1zjLphza685Ek7=xgGzew@mail.gmail.com>
<[email protected]>
<CAApHDvp=fhr8ksuGyXkwYPXQpYvJ38YMhHvx6JmdD39cAvNRhw@mail.gmail.com>
<CAApHDvrp6JwOVH3VwMB=YL3p97F5_0hKJc7J8zHRKuyhKru1dA@mail.gmail.com>
On Sat, Apr 18, 2026, at 3:49 AM, David Rowley wrote:
> On Wed, 15 Apr 2026 at 14:33, David Rowley <[email protected]> wrote:
>>
>> On Wed, 15 Apr 2026 at 14:30, Tom Lane <[email protected]> wrote:
>> >
>> > David Rowley <[email protected]> writes:
>> > > I'd not considered surprise-prone as an aspect. I understand we have
>> > > bms_join and bms_union, which do the same thing if you only care about
>> > > the value of the result and not what happens to the inputs.
>> >
>> > Sure, but bms_join is an optional optimization of the far safer
>> > bms_union operation. It bothers me to create the optimized case
>> > but not the base case.
>>
>> Hmm, yeah. That seems like a good argument for making a new set. I'll
>> go make it so.
>
> Patch attached for the version that creates a new set rather than
> modifying the input set in-place.
>
> David
Hey David,
> Attachments:
> * v2-0001-Introduce-bms_offset_members-function.patch
I applied, tested, and reviewed these changes. Thanks for doing this, only a few small things jumped out.
nit: in bitmapset.c there is a new line added above bms_add_range()
+ * Arguments:
+ * arg1: optional random seed, or < 0 to use a random seed.
+ * arg2: the number of operations to perform.
+ * arg3: the maximum bitmapset member number to use in the random set.
+ * arg4: the minimum bitmapset member number to use in the random set.
nit: whitespace ahead of arg1, also should be "NULL" not "< 0"
in test_bitmapset.sql
+-- perform some random test on bms_offset_members()
nit: "tests"
Also, I think the random testing will likely cover these, but here are a few more explicit tests for odd corner cases.
-- shift that shrinks nwords
SELECT test_bms_offset_members('(b 64 65 66)', -64); -- drops into word 0
-- shift that drops some low members and keeps others
SELECT test_bms_offset_members('(b 0 1 2 10)', -2); -- expect (b 0 8)
-- entire set shifts below zero -> empty
SELECT test_bms_offset_members('(b 1 2 3)', -10); -- expect empty
-- word-aligned positive and negative shifts
SELECT test_bms_offset_members('(b 1 2 3)', 64);
SELECT test_bms_offset_members('(b 65 66 67)', -64);
-- INT_MIN boundary
SELECT test_bms_offset_members('(b 1)', -2147483648);
I like the functionality and the reduction of repeated code that you've identified and fixed.
best.
-greg
view thread (15+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Add bms_offset_members() function for bitshifting Bitmapsets
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox