Re: Block-level CRC checks

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <greg(dot)stark(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Block-level CRC checks
Date: 2008-11-12 07:18:57
Message-ID: 20081112071857.GA28467@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 10, 2008 at 11:31:33PM +0000, Gregory Stark wrote:
> No, I just meant that you could calculate the CRC by scanning the whole buffer
> efficiently using one of the good word-wise CRC algorithms, then look at the
> line pointers to find the hint bits and subtract them out of the CRC. The
> result should be zero after adjusting for the hint bits.

If you're going to look at the line pointers anyway, couldn't you just
do it in one pass, like:

n = 0
next = &tuple[n].hintbits
pos = 0
while pos < BLOCK_SIZE:
if pos == next:
CRC_ADD( block[pos] & mask )
n++
next = &tuple[n].hintbits # If n == numtups, next = BLOCK_SIZE
else:
CRC_ADD( block[pos]
pos++

This only handles one byte of hintbits but can easily be extended. No
need to actually *store* the hintbit free version anywhere...

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hitoshi Harada 2008-11-12 09:46:31 Re: Windowing Function Patch Review -> NTH_VALUE
Previous Message Charlie Savage 2008-11-12 06:20:56 Re: 8.3 .4 + Vista + MingW + initdb = ACCESS_DENIED