Should XWikiStoreInterface#countDocuments distinct by fullname ?

5 messages Options
Embed this post
Permalink
Jerome Velociter-2

Should XWikiStoreInterface#countDocuments distinct by fullname ?

Reply Threaded More More options
Print post
Permalink
Hi Sergiu, all

I see in the XWikiHibernateStore that #countDocuments do distinct
documents by language while #searchDocuments does not.

I would have expect both to have the same behavior, so that we can use
them safely using the same query as input (for example for pagination).

Is there a reason for originally doing "select count(*)" versus select
"count(distinct doc.fullName)" ?

I think in any case we should have this API that does not distinct by
language. Should it replace the current behavior ? or should we add a
new API #countDocuments(String wheresql, boolean distinctFullname,
XWikiContext context) ?

Thanks,
Jerome.
_______________________________________________
devs mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/devs
tmortagne

Re: Should XWikiStoreInterface#countDocuments distinct by fullname ?

Reply Threaded More More options
Print post
Permalink
On Wed, Nov 4, 2009 at 12:04, Jerome Velociter <[hidden email]> wrote:

> Hi Sergiu, all
>
> I see in the XWikiHibernateStore that #countDocuments do distinct
> documents by language while #searchDocuments does not.
>
> I would have expect both to have the same behavior, so that we can use
> them safely using the same query as input (for example for pagination).
>
> Is there a reason for originally doing "select count(*)" versus select
> "count(distinct doc.fullName)" ?

It looks like a bug to me.

According to javadoc ("API allowing to count the total number of
documents that would be returned by a query.") countDocuments is
supposed to return the same thing that searchDocuments().size().

If the javadoc say it it's fine to fix it IMO, it's not like old
undocumented methods.

>
> I think in any case we should have this API that does not distinct by
> language. Should it replace the current behavior ? or should we add a
> new API #countDocuments(String wheresql, boolean distinctFullname,
> XWikiContext context) ?
>
> Thanks,
> Jerome.
> _______________________________________________
> devs mailing list
> [hidden email]
> http://lists.xwiki.org/mailman/listinfo/devs
>



--
Thomas Mortagne
_______________________________________________
devs mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/devs
Sergiu Dumitriu-2

Re: Should XWikiStoreInterface#countDocuments distinct by fullname ?

Reply Threaded More More options
Print post
Permalink
On 11/04/2009 12:46 PM, Thomas Mortagne wrote:

> On Wed, Nov 4, 2009 at 12:04, Jerome Velociter<[hidden email]>  wrote:
>> Hi Sergiu, all
>>
>> I see in the XWikiHibernateStore that #countDocuments do distinct
>> documents by language while #searchDocuments does not.
>>
>> I would have expect both to have the same behavior, so that we can use
>> them safely using the same query as input (for example for pagination).
>>
>> Is there a reason for originally doing "select count(*)" versus select
>> "count(distinct doc.fullName)" ?
>
> It looks like a bug to me.

Yes, it's a bug. Should be fixed.

> According to javadoc ("API allowing to count the total number of
> documents that would be returned by a query.") countDocuments is
> supposed to return the same thing that searchDocuments().size().
>
> If the javadoc say it it's fine to fix it IMO, it's not like old
> undocumented methods.
>
>>
>> I think in any case we should have this API that does not distinct by
>> language. Should it replace the current behavior ? or should we add a
>> new API #countDocuments(String wheresql, boolean distinctFullname,
>> XWikiContext context) ?
>>
>> Thanks,
>> Jerome.
>> _______________________________________________
>> devs mailing list
>> [hidden email]
>> http://lists.xwiki.org/mailman/listinfo/devs
>>
>
>
>


--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/devs
Jerome Velociter-2

Re: Should XWikiStoreInterface#countDocuments distinct by fullname ?

Reply Threaded More More options
Print post
Permalink
On 11/5/09 12:40 PM, Sergiu Dumitriu wrote:

> On 11/04/2009 12:46 PM, Thomas Mortagne wrote:
>> On Wed, Nov 4, 2009 at 12:04, Jerome Velociter<[hidden email]>   wrote:
>>> Hi Sergiu, all
>>>
>>> I see in the XWikiHibernateStore that #countDocuments do distinct
>>> documents by language while #searchDocuments does not.
>>>
>>> I would have expect both to have the same behavior, so that we can use
>>> them safely using the same query as input (for example for pagination).
>>>
>>> Is there a reason for originally doing "select count(*)" versus select
>>> "count(distinct doc.fullName)" ?
>>
>> It looks like a bug to me.
>
> Yes, it's a bug. Should be fixed.

OK. I've created http://jira.xwiki.org/jira/browse/XWIKI-4555

Do you think it's safe to just replace by

count (distinct doc.fullName)

Any potential issues ?

Thanks for the feedback,
Jerome.

>
>> According to javadoc ("API allowing to count the total number of
>> documents that would be returned by a query.") countDocuments is
>> supposed to return the same thing that searchDocuments().size().
>>
>> If the javadoc say it it's fine to fix it IMO, it's not like old
>> undocumented methods.
>>
>>>
>>> I think in any case we should have this API that does not distinct by
>>> language. Should it replace the current behavior ? or should we add a
>>> new API #countDocuments(String wheresql, boolean distinctFullname,
>>> XWikiContext context) ?
>>>
>>> Thanks,
>>> Jerome.
>>> _______________________________________________
>>> devs mailing list
>>> [hidden email]
>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>
>>
>>
>>
>
>

_______________________________________________
devs mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/devs
Anca Luca

Re: Should XWikiStoreInterface#countDocuments distinct by fullname ?

Reply Threaded More More options
Print post
Permalink
Hi Jérôme,

see below

On 11/05/2009 02:01 PM, Jerome Velociter wrote:

> On 11/5/09 12:40 PM, Sergiu Dumitriu wrote:
>> On 11/04/2009 12:46 PM, Thomas Mortagne wrote:
>>> On Wed, Nov 4, 2009 at 12:04, Jerome Velociter<[hidden email]>    wrote:
>>>> Hi Sergiu, all
>>>>
>>>> I see in the XWikiHibernateStore that #countDocuments do distinct
>>>> documents by language while #searchDocuments does not.
>>>>
>>>> I would have expect both to have the same behavior, so that we can use
>>>> them safely using the same query as input (for example for pagination).
>>>>
>>>> Is there a reason for originally doing "select count(*)" versus select
>>>> "count(distinct doc.fullName)" ?
>>>
>>> It looks like a bug to me.
>>
>> Yes, it's a bug. Should be fixed.
>
> OK. I've created http://jira.xwiki.org/jira/browse/XWIKI-4555
>
> Do you think it's safe to just replace by
>
> count (distinct doc.fullName)
>
> Any potential issues ?

Other than that it can take longer (since distinct might require a second pass
through the results depending on indexes and which of them are used in the where
expresison), I don't see another. But this problem also exists for the
searchDocuments(), and also, if one knows exactly what he's doing and wants to
optimize stuff, it could use protected API (select count without the distinct).

Happy hacking,
Anca

>
> Thanks for the feedback,
> Jerome.
>
>>
>>> According to javadoc ("API allowing to count the total number of
>>> documents that would be returned by a query.") countDocuments is
>>> supposed to return the same thing that searchDocuments().size().
>>>
>>> If the javadoc say it it's fine to fix it IMO, it's not like old
>>> undocumented methods.
>>>
>>>>
>>>> I think in any case we should have this API that does not distinct by
>>>> language. Should it replace the current behavior ? or should we add a
>>>> new API #countDocuments(String wheresql, boolean distinctFullname,
>>>> XWikiContext context) ?
>>>>
>>>> Thanks,
>>>> Jerome.
>>>> _______________________________________________
>>>> devs mailing list
>>>> [hidden email]
>>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>>
>>>
>>>
>>>
>>
>>
>
> _______________________________________________
> devs mailing list
> [hidden email]
> http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/devs