Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.englishtown.vertx.solr.streams.impl;
 
Implementation of JsonReadStreamBase using an integer offset to paginate json Solr results
public class OffsetJsonReadStream extends JsonReadStreamBase {
    private int nextOffset;
    public OffsetJsonReadStream(SolrService solrService) {
        super(solrService);
    }
    // this method needs to be aware of pausing so that it can keep track of where it is when it resumes
    @Override
    protected OffsetJsonReadStream setQueryStart(SolrQuery query) {
        query.setStart();
        return this;
    }
    @Override
    protected void handleResults(JsonObject reply) {
        int count = reply.getJsonObject("response")
                .getJsonArray("docs")
                .size();
         += count;
        // Recall super
        super.handleResults(reply);
    }
    @Override
    protected boolean isComplete(JsonObject reply) {
        boolean complete = false;
        JsonObject response = reply.getJsonObject("response");
        int numberFound = response.getInteger("numFound");
        int count = response.getJsonArray("docs").size();
        if ( >= numberFound || count == 0) {
            complete = true;
        }
        return complete;
    }
New to GrepCode? Check out our FAQ X