// of candidates looking for something applicable. However,
// we cannot do this indefinitely or we will run afoul of the
// Connector Manager's thread timeout.
TraversalTimer timer = new TraversalTimer(traversalContext);
while (timer.isTicking()) {
ClientValue candidates = getCandidates(checkpoint, batchsz);
ClientValue deletes = getDeletes(checkpoint, batchsz);
ClientValue results = null;
int numInserts = (candidates == null) ? 0 : candidates.size();
int numDeletes = (deletes == null) ? 0 : deletes.size();
if ((numInserts + numDeletes) == 0) {
if (checkpoint.hasChanged()) {
break; // Force a new checkpoint.
} else {
LOGGER.fine("RESULTSET: no rows.");
return null; // No new documents available.
}
}
// Apply the inclusion, exclusions, and permissions to the
// candidates.
if (numInserts > 0) {
if (LOGGER.isLoggable(Level.FINE))
LOGGER.fine("CANDIDATES SET: " + numInserts + " rows.");
// Check for bad results from the candidates query.
checkCandidatesTimeWarp(candidates, checkpoint);
// Remember the last insert candidate, so we may advance
// past all the candidates for the next batch.
Date highestModifyDate =
candidates.toDate(numInserts - 1, "ModifyDate");
checkpoint.setAdvanceCheckpoint(highestModifyDate,
candidates.toInteger(numInserts - 1, "DataID"));
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < numInserts; i++) {
buffer.append(candidates.toInteger(i, "DataID"));
buffer.append(',');
}
buffer.deleteCharAt(buffer.length() - 1);
results = getResults(buffer.toString(), highestModifyDate);
numInserts = (results == null) ? 0 : results.size();
}
if ((numInserts + numDeletes) > 0) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("RESULTSET: " + numInserts + " rows. " +