intarray internals

From: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
To: pgsql-general(at)postgresql(dot)org
Subject: intarray internals
Date: 2006-05-05 21:46:01
Message-ID: 20060505214601.GA208@alamut
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hi,

I'm reading through the source code of intarray contrib module. Despite
being at the beginning, I've some questions to ask. I'd be so
appreciated if anybody can help.

[1]
What's the function of execute() in _int_bool.c? As far as I can
understand, some other functions (eg. execconsistent()) calling
execute() with specific check methods (like checkcondition_bit()) but
I still couldn't figure out which functionality execute() stands for.

[2]
In g_int_decompress(), shouldn't

if (ARRISVOID(in))
PG_RETURN_POINTER(entry);

part be replaced with

if (ARRISVOID(in))
{
if (in != (ArrayType *) DatumGetPointer(entry->key))
pfree(in);
PG_RETURN_POINTER(entry)
}

[3]
Again, in g_int_decompress(), I couldn't figure out the functionality of
below lines:

din = ARRPTR(in);
lenr = internal_size(din, lenin);

for (i = 0; i < lenin; i += 2)
for (j = din[i]; j <= din[i + 1]; j++)
if ((!i) || *(dr - 1) != j)
*dr++ = j;

If I understand right, above loop, tries to reconstruct array with more
smaller intervals - to be able to make more accurate predicates while
digging into nodes. If so, AFAICS, g_int_compress() and
g_int_decompress() methods can be (quite?) improved.

Furthermore, I've tested above functions with some random input and
couldn't create any cases hold for a[i] == a[i - 1] (which is used
in internal_size() method's loop.) Did I miss something obvious?

Regards.

P.S. Instead of an explanation to questions, pointings to right files to
read (at least for the beginning) would be appreciated too.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hogan, James F. Jr. 2006-05-05 21:50:35 Re: Rules on Select
Previous Message Douglas McNaught 2006-05-05 21:23:15 Re: Function query plan

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2006-05-05 22:11:32 Re: [pgsql-hackers-win32] Build with Visual Studio &
Previous Message Darcy Buskermolen 2006-05-05 21:13:35 Re: 8.1.3 and unused files