Skip to content

Commit

Permalink
HSEARCH-3816 Sonar: Constants should not be defined in interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Jan 27, 2020
1 parent 15910be commit 48cdd4a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Expand Up @@ -7,8 +7,6 @@
package org.hibernate.search.backend.lucene.lowlevel.collector.impl;

import org.apache.lucene.search.Collector;
import org.apache.lucene.search.TopDocsCollector;
import org.apache.lucene.search.TotalHitCountCollector;

/**
* Tagging interface for collector keys.
Expand All @@ -24,8 +22,4 @@ static <C extends Collector> CollectorKey<C> create() {
};
}

CollectorKey<TotalHitCountCollector> TOTAL_HIT_COUNT = create();

CollectorKey<TopDocsCollector> TOP_DOCS = create();

}
Expand Up @@ -13,7 +13,6 @@

import org.hibernate.search.backend.lucene.lowlevel.collector.impl.CollectorExecutionContext;
import org.hibernate.search.backend.lucene.lowlevel.collector.impl.CollectorFactory;
import org.hibernate.search.backend.lucene.lowlevel.collector.impl.CollectorKey;
import org.hibernate.search.backend.lucene.lowlevel.reader.impl.IndexReaderMetadataResolver;
import org.hibernate.search.backend.lucene.lowlevel.collector.impl.StoredFieldsCollector;
import org.hibernate.search.backend.lucene.search.timeout.impl.TimeoutManager;
Expand Down Expand Up @@ -85,11 +84,11 @@ public LuceneCollectors createCollectors(IndexSearcher indexSearcher, Query luce
Integer.MAX_VALUE
);
}
collectorsForAllMatchingDocsBuilder.add( CollectorKey.TOP_DOCS, topDocsCollector );
collectorsForAllMatchingDocsBuilder.add( LuceneCollectors.TOP_DOCS_KEY, topDocsCollector );
}

TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();
collectorsForAllMatchingDocsBuilder.add( CollectorKey.TOTAL_HIT_COUNT, totalHitCountCollector );
collectorsForAllMatchingDocsBuilder.add( LuceneCollectors.TOTAL_HIT_COUNT_KEY, totalHitCountCollector );

collectorsForAllMatchingDocsBuilder.addAll( requiredCollectorForAllMatchingDocsFactories );
CollectorSet collectorsForAllMatchingDocs = collectorsForAllMatchingDocsBuilder.build();
Expand Down
Expand Up @@ -25,9 +25,13 @@
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.TopDocsCollector;
import org.apache.lucene.search.TopFieldCollector;
import org.apache.lucene.search.TotalHitCountCollector;

public class LuceneCollectors {

static final CollectorKey<TotalHitCountCollector> TOTAL_HIT_COUNT_KEY = CollectorKey.create();
static final CollectorKey<TopDocsCollector<?>> TOP_DOCS_KEY = CollectorKey.create();

private final IndexReaderMetadataResolver metadataResolver;

private final IndexSearcher indexSearcher;
Expand Down Expand Up @@ -74,9 +78,9 @@ public void collect(int offset, Integer limit) throws IOException {
timeoutManager.forceTimedOut();
}

this.totalHitCount = collectorsForAllMatchingDocs.get( CollectorKey.TOTAL_HIT_COUNT ).getTotalHits();
this.totalHitCount = collectorsForAllMatchingDocs.get( TOTAL_HIT_COUNT_KEY ).getTotalHits();

TopDocsCollector<?> topDocsCollector = collectorsForAllMatchingDocs.get( CollectorKey.TOP_DOCS );
TopDocsCollector<?> topDocsCollector = collectorsForAllMatchingDocs.get( TOP_DOCS_KEY );
if ( topDocsCollector == null ) {
return;
}
Expand Down

0 comments on commit 48cdd4a

Please sign in to comment.