On 22/10/13 18:21, Wang Dongsheng wrote:
By the way, I want to ask you two questions accordingly,

For 1), Can I get the total number first? cause it's better to
calculate how much pages there are in advance.

ResultsSets are an iterator (and streaming whereever possible). The count is not known until the end.

So to get the count, somethgin needs to have seen the whole result set. The ResultSetFactory has functions to create a rewindable result set (which is taking a copy) or operations to convert to a list.

For 2), If the resultSet is very Large, will the transferring to List
being broken up easily?

How large is "very large"?

You'll have to do that in your code if you want, for example, spill-to-disk structures.

Jena has code that that may help you doing that - see DataBag in org.apache.jena.atlas.data - or you can simply write the ResultSet to disk in one of the SPARQL Results formats, which are themselves streaming. TSV is the fastest. (CSV is loses information - do not use for this situation.)

You then know the size of the results, and have stabilized the results against updates or against execution to give a different order (rather unlikely in Jena, but you haven't said if your executing against a jena endpoint or some remote, other system endpoint).

        Andy



On Tue, Oct 22, 2013 at 6:31 PM, Wang Dongsheng <[email protected]> wrote:
Hi Samuel,
  Thanks a lot, It's very cool~ :)

Sincere~
Wang



On Tue, Oct 22, 2013 at 4:22 PM, Samuel Croset <[email protected]> wrote:
Hi,

For 1) you can use the OFFSET and LIMIT constructs
For 2) You can use:  ResultSetFormatter.toList()

See this answer
http://answers.semanticweb.com/questions/9456/jena-pagination-for-sparql for
more details.

Cheers,

Samuel


On Tue, Oct 22, 2013 at 8:24 AM, Wang Dongsheng <[email protected]>wrote:

Hi, all
I want to implement pagination for ResultSet of Sparql.
I guess there are generally two ways:

1, Through a specified SPARQL format, but I dont know how to write the
query,
2. Get the size of ResultSet. but there are no way to get the total
number that ResultSet contains.

I prefer to implement the second way, But Doc of API seems unavailable.

Any one tried this kind of effort? Or it was not suitable to paginate
the result?

Thank in advance~


Reply via email to