Class QueryResult<T extends ResultType>
- All Implemented Interfaces:
Iterable<QueryResult.Entry<T>>
It is created trough successful invocation of
Maapi.queryStart(int,String,String,int,int,List,Class)
method. Its purpose is to iterate, stop or reset a XPath Query
specified from parameters in queryStart
.
The Iterator
that returns from the iterator()
method
fetches result in chunks from server for local processing as needed and
is specified by the chunksize
in queryStart
method when iterating over the result set.
Iterating trough the result multiple times could be done trough
a call to reset()
and retrieval of a new iterator()
is required.
When iteration is done a call to stop()
will free up
resources from the server it is good practice to do so when
done processing on this object.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
QueryResult.Entry<E extends ResultType>
Represent result entry in a XPath query. -
Method Summary
Modifier and TypeMethodDescriptioniterator()
Retrieves an iterator from which one could iterate over the result.void
reset()
Reset/Rewind a running query so that it starts from the beginning again.void
reset
(int offset) Reset/Rewind a running query to a specific offset.long
Get number of elements in the result.void
stop()
Stops the running query and makes the server end free up any internal resources associated with the query.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
reset
Reset/Rewind a running query so that it starts from the beginning again. Next call toiterator()
will then return the first chunk of results.The method can be called at any time (i.e. both after all results have been returned to essentially run the same query again, as well as after fetching just one or a couple of results).
- Throws:
ConfException
IOException
-
reset
Reset/Rewind a running query to a specific offset. First element has offset 1. Next call toiterator()
will then reinitialize with first chunk starting with element at offset.The method can be called at any time.
- Throws:
ConfException
IOException
-
resultCount
Get number of elements in the result. Note, internally to get this information the expression must be evaluated and the result counted and afterwards the query reset. From a performance point of view this is the same as using the iterator and count the number of hits. Note also, that there is no guarantee that the elements addressed by the expression will not change between this call and the actual iteration, which then will lead to a difference in count.- Returns:
- long number of elements in the result
- Throws:
ConfException
IOException
-
stop
Stops the running query and makes the server end free up any internal resources associated with the query.
- Throws:
ConfException
IOException
-
iterator
Retrieves an iterator from which one could iterate over the result.- Specified by:
iterator
in interfaceIterable<T extends ResultType>
- Returns:
- a query result iterator
-