jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mueller <muel...@adobe.com>
Subject Re: The infamous getSize() == -1 (Was: [jira] [Created] (OAK-300) Query: QueryResult.getRows().getSize())
Date Thu, 13 Sep 2012 08:13:01 GMT
Hi,

>>(and getSize() would still return -1 I guess?)
>
>For backward compatibility I'd leave the behaviour "as unchanged as
>possible". That is, return -1 if the size is not quickly available.

Yes, that what I had in mind. The question is now, what exactly *is*
quickly available. I suggest that the implementation (by default) tries to
prefetch 20 rows, so it can give an accurate result for up to that many
rows. If there are more than 20 rows, getSize() will return -1. We need to
document that the constant '20' may change in the future. Internally,
getSize() would call getSize(20).

About a new method getSize(int max): I guess we would need to add at least
one new interface, OakRangeIterator extends RangeIterator, and probably
also OakNodeIterator and OakRowIterator. The application would then call
getSize(int max) as follows:

Session session = ..

QueryManager qm = session.getWorkspace().getQueryManager();
Query q = qm.createQuery("select ..", Query.JCR_SQL2);
QueryResult r = q.execute();
RowIterator it = (OakRowIterator) r.getRows();
int size = it.getSize(100);





So there is a cast needed. I personally think that adding a new interface,
and then casting to this interface in the application isn't very nice, but
well what can you do.

Regards,
Thomas




Mime
View raw message