It is a dirty trick, but it seems to work! :)

Thanks,
Valeria


2010/3/30 K. John Wu <[email protected]>

> Hi, Valeria,
>
> Please give the following two lines a try:
> selected = table ->  select ("SRC_PORT, DST_PORT, count(*)",
> "SRC_PORT>20");
> selected ->  dump (cout);
>
> Adding the aggregation function 'count(*)' causes the select clause to
> go through a group-by operation, which then returns distinct pairs of
> SRC_PORT and DST_PORT.
>
> Good luck.
>
> John
>
>
> On 3/29/2010 3:53 PM, Valeria Lorenzetti wrote:
> > Hi John,
> > thanks for your reply!
> >
> > I'm trying to rewrite my code with ibis::table, as you suggested, but
> > I still have some doubts. Below there is a minimal example that I have
> > tried to write:
> >
> > int main (int argc, char * argv [])
> > {
> >   const char * dir = "database/";
> >   ibis::table * table = ibis::table::create (dir);
> >
> > ibis::table * selected = 0;
> > selected = table ->  select ("SRC_PORT, DST_PORT", "SRC_PORT>20");
> > selected ->  orderby ("SRC_PORT, DST_PORT");
> >
> > /* Print the results */
> > selected ->  dump (cout);
> >
> > delete selected;
> > delete table;
> > return 0;
> > }
> >
> > How can I use the DISTINCT statment in this example? What functions
> > should I use? Is there a function that returns a table with only
> > distinct rows?
> >
> > I need to access only the distinct rows and iterate over them.
> >
> > Any tips is appreciated,
> > thanks,
> > Valeria Lorenzetti
> >
> >
> >
> > 2010/3/29 K. John Wu<[email protected]>
> >>
> >> Hi, Valeria,
> >>
> >> The second way (in thula.cpp) might be better in general.  The
> >> ibis::query object has some trouble with "count(*)".  If you use
> >> ibis::query directly, it is best to leave out "count(*)".  You can get
> >> the same information from the function ibis::query::getNumHits.
> >>
> >> John
> >>
> >>
> >> On 3/29/2010 1:19 AM, Valeria Lorenzetti wrote:
> >>> Hi John,
> >>> I saw that there are many ways to access Fastbit-data and run a query.
> >>>
> >>>   From ibis.cpp:
> >>>     ibis::query aQuery(uid, tbl);
> >>>     aQuery.setWhereClause(wstr);
> >>>     aQuery.setSelectClause(sstr);
> >>>     aQuery.evaluate();
> >>>     num1 = aQuery.getNumHits();
> >>>
> >>>   From thula.cpp
> >>>     ibis::table *sel = 0;
> >>>     sel = tbl.select(sstr, wstr);
> >>>     n1 = tbl.nRows();
> >>>
> >>>
> >>> I'd like to know what is the best way (faster and more flexible) to
> >>> manage the results. I need to apply efficiently some functions on
> >>> these, like DISTINCT, ORDERBY, LIMIT, etc. Moreover, I need to access
> >>> the rows individually to print them in a customized way (e.g. with an
> >>> XML format).
> >>>
> >>> At this time, to run a query, I'm using the first method:
> >>>
> >>> ibis::part part (directory, static_cast<const char*>(0));
> >>> ibis::query q (name,&part);
> >>> q.setSelectClause (select_clause);
> >>> q.setWhereClause (where_clause);
> >>> q.evaluate();
> >>>
> >>> To access and manage every single row, I'm using:
> >>> ibis::bundle * b = ibis::bundle::create (q);
> >>>
> >>> and to access every single value (i,j) of the row, to build a
> >>> customized output, I'm using:
> >>> b.getUInt (row-id, col-id);
> >>>
> >>>
> >>> However, I'm pretty sure that this is not the best way to manage the
> results.
> >>> Can you give me some advice on the functions to use?
> >>>
> >>> Thanks in advance,
> >>> Valeria Lorenzetti
> >>> _______________________________________________
> >>> 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
> > _______________________________________________
> > 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
>
_______________________________________________
FastBit-users mailing list
[email protected]
https://hpcrdm.lbl.gov/cgi-bin/mailman/listinfo/fastbit-users

Reply via email to