Re: Patch for SortSupport implementation on inet/cdir

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Brandur Leach <brandur(at)mutelight(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch for SortSupport implementation on inet/cdir
Date: 2019-07-27 02:25:26
Message-ID: CAH2-Wzn94t7H8fwp6vYA+N3mm-4PhJEXJ6TvPVL032Z2u3GQ+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 26, 2019 at 6:58 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> I found this part of your approach confusing:
>
> > + /*
> > + * Number of bits in subnet. e.g. An IPv4 that's /24 is 32 - 24 = 8.
> > + *
> > + * However, only some of the bits may have made it into the fixed sized
> > + * datum, so take the smallest number between bits in the subnet and bits
> > + * in the datum which are not part of the network.
> > + */
> > + datum_subnet_size = Min(ip_maxbits(authoritative) - ip_bits(authoritative),
> > + SIZEOF_DATUM * BITS_PER_BYTE - ip_bits(authoritative));
>
> The way that you put a Min() on the subnet size potentially constrains
> the size of the bitmask used for the network component of the
> abbreviated key (the component that comes immediately after the
> ipfamily status bit). Why not just let the bitmask be a bitmask,
> without bringing SIZEOF_DATUM into it? Doing it that way allowed for a
> more streamlined approach, with significantly fewer special cases. I'm
> not sure whether or not your approach had bugs, but I didn't like the
> way you sometimes did a straight "network = ipaddr_datum" assignment
> without masking.

I guess that the idea here was to prevent masking on ipv6 addresses,
though not on ipv4 addresses. Obviously we're only dealing with a
prefix with ipv6 addresses, whereas we usually have the whole raw
ipaddr with ipv4. Not sure if I'm doing the right thing there in v3,
even though the tests pass. In any case, this will need to be a lot
clearer in the final version.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-07-27 02:27:40 Re: POC: Cleaning up orphaned files using undo logs
Previous Message Peter Geoghegan 2019-07-27 01:58:41 Re: Patch for SortSupport implementation on inet/cdir