private void walkSolrDocs() throws SolrServerException, IOException {
if (!checkForDeletes) return;
if ((okIds == null) || (okIds.size() == 0)) return;
TaskContext context = this.getContext();
TaskStats stats = context.getStats();
String tn = context.getTaskName()+".walkSolrDocs";
stats.setString(tn,"...");
String fl = FieldConstants.Id;
String q = FieldConstants.Id_Table+":"+FieldConstants.Val_Id_Table_DocIndex;
q += " AND "+FieldConstants.Sync_Type+":"+this.syncType;
q += " AND "+FieldConstants.Sync_Foreign_InstanceId+":"+this.foreignInstanceId;
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("q",q);
params.set("fl",fl);
stats.setString(tn+".q",q);
boolean bContinue = true;
long nDeepTotal = 0;
long nFetched = 0;
long nHits = 0;
int nDocs = 0;
long nStart = 0;
int nRows = 1000;
long nNextStart = 0;
while (bContinue) {
bContinue = false;
params.set("start",""+nStart);
params.set("rows",""+nRows);
QueryResponse response = queryServer.query(params);
SolrDocumentList docs = response.getResults();
if (docs != null) {
nHits = docs.getNumFound();
nDocs = docs.size();
nNextStart = nStart+nDocs;
if ((nDocs > 0) && (nNextStart < nHits)) {
bContinue = true;
}
for (int i=0;i<nDocs;i++) {
SolrDocument doc = docs.get(i);
String id = (String)doc.getFieldValue(FieldConstants.Id);
nFetched++;
stats.incrementCount(tn+".fetched");
if (okIds.get(id) != null) {
stats.incrementCount(tn+".idOk");
} else {
stats.incrementCount(tn+".idRequiresDelete");
if ((delIds != null) && (delIds.size() <= this.maxIdsInMap)) {
delIds.add(id);
} else if (delIds != null) {
delIds = null;
bContinue = false;
break;
}
}
if ((nDeepTotal > 0) && (nFetched >= nDeepTotal)) {
bContinue = false;
break;
}
}
nStart = nNextStart;
}
}
if ((delIds != null) && (delIds.size() > 0)) {
stats.incrementCount(context.getTaskName()+".solr.sentForDelete",delIds.size());
this.docPublisher.getUpdateServer().deleteById(delIds);
}
}