Source:
public void run() { try { LuceneDocumentGenerator generator = (LuceneDocumentGenerator) generatorClass.getDeclaredConstructor(Args.class, Counters.class).newInstance(args, counters); BaseFileSegment<SourceDocument> iter = (BaseFileSegment) ((SegmentProvider) collection).createFileSegment(input); int cnt = 0; while (iter.hasNext()) { SourceDocument sourceDocument; try { sourceDocument = iter.next(); } catch (RuntimeException e) { counters.skipped.incrementAndGet(); continue; } if (!sourceDocument.indexable()) { counters.unindexable.incrementAndGet(); continue; } Document document = generator.createDocument(sourceDocument); if (document == null) { counters.unindexed.incrementAndGet(); continue; } if (whitelistDocids != null && !whitelistDocids.contains(sourceDocument.id())) { counters.skipped.incrementAndGet(); continue; } SolrInputDocument solrDocument = new SolrInputDocument(); for (IndexableField field : document.getFields()) { if (field.fieldType().stored()) { solrDocument.addField(field.name(), field.stringValue()); } } if (args.solrCloud) { buffer.add(solrDocument); if (buffer.size() == args.solrBatch) { flush(); } } else { this.solrClient.add(args.solrIndex, solrDocument); } cnt++; } if (args.solrCloud && !buffer.isEmpty()) { flush(); } solrClient.commit(args.solrIndex); solrClient.close(); if (iter.getNextRecordStatus() == BaseFileSegment.Status.ERROR) { counters.errors.incrementAndGet(); } iter.close(); LOG.info(input.getParent().getFileName().toString() + File.separator + input.getFileName().toString() + ": " + cnt + " docs added."); counters.indexed.addAndGet(cnt); } catch (Exception e) { LOG.error(Thread.currentThread().getName() + ": Unexpected Exception:", e); } }

Target:
public void run() { try { LuceneDocumentGenerator generator = (LuceneDocumentGenerator) generatorClass.getDeclaredConstructor(Args.class, Counters.class).newInstance(args, counters); BaseFileSegment<SourceDocument> iter = (BaseFileSegment) ((SegmentProvider) collection).createFileSegment(input); int cnt = 0; while (iter.hasNext()) { SourceDocument sourceDocument; try { sourceDocument = iter.next(); } catch (RuntimeException e) { counters.skipped.incrementAndGet(); continue; } if (!sourceDocument.indexable()) { counters.unindexable.incrementAndGet(); continue; } Document document = generator.createDocument(sourceDocument); if (document == null) { counters.unindexed.incrementAndGet(); continue; } if (whitelistDocids != null && !whitelistDocids.contains(sourceDocument.id())) { counters.skipped.incrementAndGet(); continue; } SolrInputDocument solrDocument = new SolrInputDocument(); for (IndexableField field : document.getFields()) { if (field.fieldType().stored()) { solrDocument.addField(field.name(), field.stringValue()); } } if (args.solrCloud) { buffer.add(solrDocument); if (buffer.size() == args.solrBatch) { flush(); } } else { solrClient.add(args.solrIndex, solrDocument); } cnt++; } if (args.solrCloud && !buffer.isEmpty()) { flush(); } solrClient.commit(args.solrIndex); if (iter.getNextRecordStatus() == BaseFileSegment.Status.ERROR) { counters.errors.incrementAndGet(); } iter.close(); LOG.info(input.getParent().getFileName().toString() + File.separator + input.getFileName().toString() + ": " + cnt + " docs added."); counters.indexed.addAndGet(cnt); } catch (Exception e) { LOG.error(Thread.currentThread().getName() + ": Unexpected Exception:", e); } }