Skip to content

Commit

Permalink
reduce logging in LuceneDocCollector and cache Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Aug 18, 2015
1 parent 540f9e7 commit 35798b4
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public class LuceneDocCollector extends Collector implements CrateCollector, Row

private static final ESLogger LOGGER = Loggers.getLogger(LuceneDocCollector.class);

// cache exception to avoid expensive stacktrace generation
@SuppressWarnings("ThrowableInstanceNeverThrown")
private static final CollectionTerminatedException COLLECTION_TERMINATED_EXCEPTION = new CollectionTerminatedException();

public static class CollectorFieldsVisitor extends FieldsVisitor {

final HashSet<String> requiredFields;
Expand Down Expand Up @@ -170,11 +174,7 @@ public void collect(int doc) throws IOException {
protected boolean skipDoc(int doc) {
ScoreDoc after = internalCollectContext.lastCollected;
if (after != null) {
if (currentDocBase == internalCollectContext.lastDocBase && doc <= after.doc) {
// doc was already collected, skip
LOGGER.trace("skipping doc {} <= {} of docBase {}", doc, after.doc, currentDocBase);
return true;
}
return currentDocBase == internalCollectContext.lastDocBase && doc <= after.doc;
}
return false;
}
Expand All @@ -201,9 +201,7 @@ public void setNextReader(AtomicReaderContext context) throws IOException {
protected void skipSegmentReader() {
if (currentDocBase < internalCollectContext.lastDocBase) {
// skip this segment reader, all docs of this segment are already collected
LOGGER.trace("skipping segment reader with docBase {} < {}",
currentDocBase, internalCollectContext.lastDocBase);
throw new CollectionTerminatedException();
throw COLLECTION_TERMINATED_EXCEPTION;
}
}

Expand Down

0 comments on commit 35798b4

Please sign in to comment.