Hi, Sasini,
The logic behind the result set size is as follows:
"Select count(miles) ... Where miles>15000" returns a SQL table of
with 1 row
"Select miles ... where miles>15000" returns table with 247 rows
The content of the returned table in the first case is a single value
(i.e., count(miles)), while the content in the second case is a list
of 247 miles values.
Regarding the behavior of fastBit.get_qualified_longs, the intention
is for you to use the query handle as a mask to retrieve values from
the named column. The more general use case is for one to issue a
select query with where-clause only and then retrieve the values from
the selected rows for other computation. This is meant for users who
want to do more in-depth analysis with their own code. Clearly, this
behavior does not follow the SQL standard.
John
On 1/18/17 1:21 AM, sasini madhumali wrote:
> Hi John,
>
> Thank you for quick response and it helped me to understand what is
> happening there.
>
> I have another issue with running a COUNT query using Java Native
> Interface that FastBit has provided.
>
> If I run "FastBit.QueryHandle handle =
> fastBit.build_query("count(miles)", "truck_mileage_index",
> "miles>15000");"
> The following method returns a value(247) as the result set size which
> is greater than 1.
> int cnt = fastBit.get_result_size(handle);
> For "FastBit.QueryHandle handle = fastBit.build_query("miles",
> "truck_mileage_index", "miles>15000");" also it gives 247.
> Shouldn't that 'result size' be 1 and its value is 247 for the
> COUNT(miles) while 'result size' is 247 for the second query.
>
> Though I run "FastBit.QueryHandle handle =
> fastBit.build_query("miles", "truck_mileage_index", "miles>15000");",
> It gives the values of column "gas" from the following method.
> long[] c = fastBit.get_qualified_longs(handle,"gas");
> Shouldn't that query's result set consists only with the qualified
> 'miles' column? How does it give the qualified 'gas' values when I
> have not include the gas column anywhere in the query ? Does it
> return all columns in the table which satisfy where clause as the
> result set ?
>
> Therefore I feel like the method "fastbit.build_query" does not
> consider the select clause I provide and it takes a default value. It
> would be great if you can explain me those.
>
> Thanks,
> Sasini
>
>
> On 16 January 2017 at 23:42, John Wu <[email protected]> wrote:
>> Dear Sasini,
>>
>> Thanks for your interest in our work.
>>
>> The implementation of "COUNT(miles)" does read the values of miles. If
>> you want to avoid this use "COUNT(*)".
>>
>> In terms of execution time, I would expect the three versions to go
>> from fast to slow as follows:
>> (1) "SELECT COUNT(*) WHERE gas>1500"
>> (2) "SELECT miles WHERE gas>1500"
>> (3) "SELECT COUNT(miles) WHERE gas>1500"
>>
>> Here is a caveat, if the variable miles contains NULL values,
>> COUNT(miles) will skip those NULL values, while "COUNT(*)" would have
>> no way of knowing about the NULL values and couldn't skip them.
>>
>> John
>> _______________________________________________
>> 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