X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4D2359FA3A3 for ; Fri, 5 May 2006 18:48:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 18574-06 for ; Fri, 5 May 2006 18:48:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fep07.ttnet.net.tr (mail.ttnet.net.tr [212.175.13.129]) by postgresql.org (Postfix) with ESMTP id 3D35E9FA4DE for ; Fri, 5 May 2006 18:48:26 -0300 (ADT) Received: from alamut ([85.102.236.143]) by fep07.ttnet.net.tr with ESMTP id <20060505214824.JRTA25116.fep07.ttnet.net.tr@alamut> for ; Sat, 6 May 2006 00:48:24 +0300 Date: Sat, 6 May 2006 00:46:01 +0300 From: Volkan YAZICI To: pgsql-general@postgresql.org Subject: intarray internals Message-ID: <20060505214601.GA208@alamut> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-NAI-Spam-Rules: 1 Rules triggered BAYES_01=-1.2 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/234 X-Sequence-Number: 95026 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.