Re: [MonetDB-users] return type of 'count' in mil
Jenny, the return type of count is "legacy". You're right, in case of BATs with more than 2^31 BUNs (possible only on 64-bit systems), the default count(BAT[any,any]):int will fail (or at least return a wrong result. We hanven't changed it to count(BAT[any,any]):lng, yet, maily due to backward-compatibility and due to the fact that a grouped-count ({count}(BAT[any::1,any::2]):BAT[any::1,int/lng]) would than in all cases return a BAT[any,lng], possibly "wasting" space compared to a BAT[any,int]. Eventually, count should return a vraiable integer type that is 32-bit on 32-bit systems and 64-bit on 64-bit systems --- I've been planning to add this "word" type (together with a "proper" 1-byte integer "byte") for quite some time, but it never made it to the very top op my priority-ordered todo list... for now, in case you indeed need th count of >2^31 BUN BATs, you can use count(int):lng, where you provide the BAT's id (i.e., int(BAT)) iso. the BAT itself as argument: ======== MonetDB>help("count"); COMMAND: count(BAT[any,any], bit) : int MODULE: algebra COMPILED: by adm on Mon Aug 7 18:07:14 2006 Returns the number of elements currently in a BAT; ignores BUNs with nil-tail iff ignore_nils==TRUE. COMMAND: count(BAT[any,any]) : int MODULE: algebra COMPILED: by adm on Mon Aug 7 18:07:14 2006 Returns the number of elements currently in a BAT. COMMAND: count(BAT[void,void], lng) : lng MODULE: bat COMPILED: by adm on Mon Aug 7 18:07:14 2006 Sets the size (in number of elements) of a BAT. COMMAND: count(int) : lng MODULE: bat COMPILED: by adm on Mon Aug 7 18:07:14 2006 Returns the current size (in number of elements) of a BAT. MonetDB> ======== Stefan On Wed, Aug 09, 2006 at 04:29:33PM +0200, Ying Zhang wrote:
hi stefan,
I'm wondering if the return type 'int' of the mil command 'count' is correct. According to help("count"):
... COMMAND: count(BAT[any,any]) : int MODULE: algebra COMPILED: by adm on Mon Aug 7 15:11:12 2006 Returns the number of elements currently in a BAT. ...
what if I want to count a BAT[oid,oid] which contains a max. nr. of BUNs that a BAT with 64bits oid can have. would this be a problem, since 'oid' is of 64bits on 64bits machines, while 'int' is of 32bits? or is a mil 'int' different than a C 'int', namely the size of a mil 'int' also varias in different machines?
Thanks
Jennie
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
participants (1)
-
Stefan Manegold