Re: Block-level CRC checks - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Block-level CRC checks
Date
Msg-id 20081112071857.GA28467@svana.org
Whole thread Raw
In response to Re: Block-level CRC checks  (Gregory Stark <stark@enterprisedb.com>)
Responses Re: Block-level CRC checks  (Alvaro Herrera <alvherre@commandprompt.com>)
List 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@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

pgsql-hackers by date:

Previous
From: Charlie Savage
Date:
Subject: Re: 8.3 .4 + Vista + MingW + initdb = ACCESS_DENIED
Next
From: "Hitoshi Harada"
Date:
Subject: Re: Windowing Function Patch Review -> NTH_VALUE