Christoph Kiehl wrote:
while fixing a little bug in rev 566778 I became aware that there is no
possibility to retrieve the total result size of a query anymore if
setLimit() is used. But I need that information and I think I'm not
alone. The question is how to implement this? Should this maybe even be
covered by jsr 283? The method could be either implemented on the
LazyScoreNodeIterator (RangeIterator) but may be it is more appropriate
for LazyQueryResultImpl/QueryResultImpl (QueryResult) because limits are
specific to querying. WDYT?
The public review version of JSR 283 only contains little information about the
two methods setLimit(long) and setOffset(long). They even contain TODO remarks
whether the methods should be removed again.
How they are specified currently they don't seem to be very useful to me. I
think the spec (and of course also jackrabbit) should be changed the following way:
void setOffset(long offset)
Sets the start offset of the query result to _offset_. Setting an offset does
not modify the size of the NodeIterator or RowIterator returned by the
QueryResult. The following two code fragments behave equivalent from a client
perspective (if there are 10 or more matching nodes):
Query q = ...
q.setOffset(10);
NodeIterator it = q.execute().getNodes();
is equivalent to:
Query q = ...
NodeIterator it = q.execute().getNodes();
it.skip(10);
The first code is considered more efficient because it allows an implementation
to optimize access to the range of nodes in the query result a client is
actually interested.
and as a replacement for setLimit():
void setFetchSize(long size)
Gives the QueryManager a hint as to the number of rows/nodes that should be
fetched from the workspace when more rows/nodes are needed. The number of
rows/nodes specified affects only QueryResults created using this Query. If the
value specified is zero, then the hint is ignored. The default value is zero.
WDYT?
regards
marcel