Hi, Petr,

The return values for most functions follow the convention that a
negative value indicates error, zero or a positive value indicates
success.  A positive value is often used to carry additional
information as well.  In this particular case, a positive number is
the number of rows retrieved.  It is somewhat redundant in this
particular case since it will retrieve one value only.  However, it is
done to be consistent with another set of functions named
getColumnAsBytes and so forth.

Looks like we have neglected to document this feature.  This
information will be added to the doxygen document now.

Thanks for the note.

John




On 8/2/12 10:40 PM, Petr Velan wrote:
> Hi John,
> 
> I just found out a curious thing. I'm using table::cursor to iterate
> over result set and retrieving values using getColumnAs___ functions.
> I'm actually checking for return value of the function to see, whether
> there was anything wrong. The assumption is that any non-zero value
> means an error. Right now, I have one query that is valid, but the
> function returns 1, which seems to be quite impossible from the look
> of the actual library code.
> 
> Should I only assume that negative value are errors?
> 
> Here is the code that gives the described result:
> ------------------------------------------------------------------------------------------------------------------------------
> #include <fastbit/ibis.h>
> #include <iostream>
> 
> 
> int main(int argc, char *argv[]) {
> 
>       if (argc <=1) return 1;
> 
>       ibis::table *table = ibis::table::create(argv[1]);
> 
>       ibis::table *result = table->select("count(*)", "1==1");
>       delete table;
> 
>       ibis::table::cursor *cursor = result->createCursor();
>       cursor->fetch();
> 
>       uint64_t count, ret;
>       ret = cursor->getColumnAsULong((uint32_t) 0,count);
> 
>       std::cout << "Count is: " << count << ", return value is: " << ret <<
> std::endl;
> 
>       return 0;
> }
> ------------------------------------------------------------------------------------------------------------------------------
> 
> When anything else is added to the "count(*)" in select clause, the
> return value is 0, as expected.
> 
> Regards,
> Petr
> _______________________________________________
> 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