[xwiki-devs] Should XWikiStoreInterface#countDocuments distinct by fullname ?
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.
On Wed, Nov 4, 2009 at 12:04, Jerome Velociter <[email protected]> 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 [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On 11/04/2009 12:46 PM, Thomas Mortagne wrote:
On Wed, Nov 4, 2009 at 12:04, Jerome Velociter<[email protected]> 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 [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Sergiu Dumitriu http://purl.org/net/sergiu/
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<[email protected]> 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 [email protected] http://lists.xwiki.org/mailman/listinfo/devs
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<[email protected]> 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 [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (4)
-
Anca Luca -
Jerome Velociter -
Sergiu Dumitriu -
Thomas Mortagne