Hi John,

Thanks for the hint. However, it seems that adding 
query.setSelectClause("p_devtype, count(*)") breaks something, not sure what 
exactly:

Error -- bundles::ctor "__1" is not the name of a column in table 
data_property_flat
Error -- bundles::ctor received an exception, start cleaning up
terminate called after throwing an instance of 'ibis::bad_alloc'
  what():  unknown column name

For the patch, it allows to jump from bundle to bundle instead of line by line 
when iterating over a result set (which artificially repeat same bundle to 
simulate a real query SQL result). Feel free to include it/modify it/drop it. 
Soon enough, i should also submit a patch that allows me to access long values 
from a result set in the C api.

Thanks,

-----Original Message-----
From: K. John Wu [mailto:[email protected]] 
Sent: Thursday, January 12, 2012 4:41 PM
To: FastBit Users
Cc: Dominique Prunier
Subject: Re: [FastBit-users] Recommanded way to do SELECT DISTINCT <string_col> 
programatically

Hi, Dominique,

A quick want to get what you want might be to change the select clause
to something like

query.setSelectClause("p_devtype, count(*)");

The bundle will have the unique values for p_devtype and it does not
cost extra to compute the counts.

Internally, FastBit is dealing with integer version of the strings.
You will still have to use getString to retrieve the actual string values.

By the way, would you mind give a quick explanation about what is in
the patch you've sent out?  Do you intend it to be included in FastBit
release?  I would like to have a brief description of the patch to put
in the ChangeLog if you intend to make it available to others.

Thanks.

John



On 1/12/12 1:07 PM, Dominique Prunier wrote:
> In the meantime, i did a very simple modification to be able to do
> what i wanted from the C api (see attached)
> 
>  
> 
> Thanks,
> 
>  
> 
> *From:*[email protected]
> [mailto:[email protected]] *On Behalf Of *Dominique
> Prunier
> *Sent:* Thursday, January 12, 2012 3:04 PM
> *To:* FastBit Users
> *Subject:* [FastBit-users] Recommanded way to do SELECT DISTINCT
> <string_col> programatically
> 
>  
> 
> Hi,
> 
>  
> 
> I’m trying to reproduce a SELECT DISTINCT from a previous SQL system
> migrated to FastBit and so far, i ended up with the following snippet
> of code:
> 
>  
> 
> ibis::part part("<part>", static_cast<const char*>(0));
> 
> ibis::query query;
> 
> query.setPartition(&part);
> 
> query.setWhereClause(static_cast<const char*>(0));
> 
> query.setSelectClause("p_devtype");
> 
> query.evaluate();
> 
> std::auto_ptr<ibis::bundle> bdl(ibis::bundle::create(query));
> 
> for (int ri = 0; ri < bdl->size(); ri++) {
> 
>   std::cout << bdl->getString(ri, 0) << "\n";
> 
> }
> 
>  
> 
> My questions are:
> 
> ·         Is it the recommended way of doing it ? Is there any other
> ways ? Is this something i can do trhough the C api ?
> 
> ·         The getString(ri, 0) decorates strings with a leading and
> trailing quotes, is there another method to get the undecorated string ?
> 
>  
> 
> Thanks,
> 
>  
> 
> */Dominique Prunier/**//*
> 
>  APG Lead Developper
> 
> Logo-W4N-100dpi
> 
>  4388, rue Saint-Denis
> 
>  Bureau 309
> 
>  Montreal (Quebec)  H2J 2L1
> 
>  Tel. +1 514-842-6767  x310
> 
>  Fax +1 514-842-3989
> 
>  [email protected] <mailto:[email protected]>
> 
>  www.watch4net.com <http://www.watch4net.com/>
> 
> /  /
> 
> /This message is for the designated recipient only and may contain
> privileged, proprietary, or otherwise private information. If you have
> received it in error, please notify the sender immediately and delete
> the original. Any other use of this electronic mail by you is prohibited.
> 
> //Ce message est pour le récipiendaire désigné seulement et peut
> contenir des informations privilégiées, propriétaires ou autrement
> privées. Si vous l'avez reçu par erreur, S.V.P. avisez l'expéditeur
> immédiatement et effacez l'original. Toute autre utilisation de ce
> courrier électronique par vous est prohibée.///
> 
>  
> 
> 
> 
> _______________________________________________
> FastBit-users mailing list
> [email protected]
> https://hpcrdm.lbl.gov/cgi-bin/mailman/listinfo/fastbit-users
_______________________________________________
FastBit-users mailing list
[email protected]
https://hpcrdm.lbl.gov/cgi-bin/mailman/listinfo/fastbit-users

Reply via email to