Skip to content

Commit

Permalink
codestyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Siju Varghese committed Jan 9, 2025
1 parent 73a7c7f commit 7995cb1
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,7 @@ public void setResult(QueryResult result) {
final Boolean terminatedEarly = result.getTerminatedEarly();
if (terminatedEarly != null) {
rsp.getResponseHeader()
.add(
SolrQueryResponse.RESPONSE_HEADER_TERMINATED_EARLY_KEY,
terminatedEarly);
.add(SolrQueryResponse.RESPONSE_HEADER_TERMINATED_EARLY_KEY, terminatedEarly);
}
if (null != cursorMark) {
assert null != result.getNextCursorMark() : "using cursor but no next cursor set";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public class SolrQueryResponse {
public static final String RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY = "partialResultsDetails";
public static final String RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY =
"segmentTerminatedEarly";
public static final String RESPONSE_HEADER_TERMINATED_EARLY_KEY =
"terminatedEarly";
public static final String RESPONSE_HEADER_TERMINATED_EARLY_KEY = "terminatedEarly";
public static final String RESPONSE_HEADER_KEY = "responseHeader";
private static final String RESPONSE_KEY = "response";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.FilterCollector;
Expand All @@ -41,7 +40,6 @@ public class EarlyTerminatingCollector extends FilterCollector {
private final AtomicInteger pendingDocsToCollect;
private boolean terminatedEarly = false;


/**
* Wraps a {@link Collector}, throwing {@link EarlyTerminatingCollectorException} once the
* specified maximum is reached.
Expand All @@ -50,14 +48,16 @@ public class EarlyTerminatingCollector extends FilterCollector {
* @param maxDocsToCollect - the maximum number of documents to Collect
*/
public EarlyTerminatingCollector(Collector delegate, int maxDocsToCollect) {
this(delegate,maxDocsToCollect, new AtomicInteger(maxDocsToCollect));
this(delegate, maxDocsToCollect, new AtomicInteger(maxDocsToCollect));
}

public EarlyTerminatingCollector(Collector delegate, int maxDocsToCollect,AtomicInteger docsToCollect) {
public EarlyTerminatingCollector(
Collector delegate, int maxDocsToCollect, AtomicInteger docsToCollect) {
super(delegate);
this.maxDocsToCollect = maxDocsToCollect;
this.pendingDocsToCollect = docsToCollect;
}

@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
prevReaderCumulativeSize += currentReaderSize; // not current any more
Expand All @@ -74,12 +74,13 @@ public void collect(int doc) throws IOException {
terminatedEarly = pendingDocsToCollect.addAndGet(-1 * chunkSize) < 0;
}
if (terminatedEarly) {
throw new EarlyTerminatingCollectorException(maxDocsToCollect,
prevReaderCumulativeSize + (doc + 1));
throw new EarlyTerminatingCollectorException(
maxDocsToCollect, prevReaderCumulativeSize + (doc + 1));
}
}
};
}

public boolean isTerminatedEarly() {
return terminatedEarly;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ static class SearchResult {
private final Object[] result;
final boolean isTerminatedEarly;


public SearchResult(ScoreMode scoreMode, Object[] result) {
this(scoreMode, result, false);
}
public SearchResult(ScoreMode scoreMode, Object[] result,boolean isTerminatedEarly) {

public SearchResult(ScoreMode scoreMode, Object[] result, boolean isTerminatedEarly) {
this.scoreMode = scoreMode;
this.result = result;
this.isTerminatedEarly = isTerminatedEarly;
Expand Down Expand Up @@ -271,7 +271,6 @@ public Object reduce(Collection collectors) throws IOException {
next = earlyTerminatingCollector.getDelegate();
}
collector = (MaxScoreCollector) next;

}

return new MaxScoreResult(maxScore);
Expand Down Expand Up @@ -341,7 +340,8 @@ public Object reduce(Collection collectors) throws IOException {
for (Object o : collectors) {
collector = (Collector) o;
if (collector instanceof EarlyTerminatingCollector) {
EarlyTerminatingCollector earlyTerminatingCollector = (EarlyTerminatingCollector) collector;
EarlyTerminatingCollector earlyTerminatingCollector =
(EarlyTerminatingCollector) collector;
collector = earlyTerminatingCollector.getDelegate();
}
if (collector instanceof TopDocsCollector) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ public ScoreMode scoreMode() {
MultiThreadedSearcher.TopDocsResult topDocsResult = searchResult.getTopDocsResult();
totalHits = topDocsResult.totalHits;
topDocs = topDocsResult.topDocs;
if(searchResult.isTerminatedEarly){
if (searchResult.isTerminatedEarly) {
qr.setTerminatedEarly(true);
qr.setPartialResults(Boolean.TRUE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.CollectorManager;
Expand All @@ -36,18 +35,18 @@
* MultiCollector} acts for {@link Collector}.
*/
public class SolrMultiCollectorManager
implements CollectorManager<SolrMultiCollectorManager.Collectors, Object[]> {
implements CollectorManager<SolrMultiCollectorManager.Collectors, Object[]> {

private final CollectorManager<Collector, ?>[] collectorManagers;
private AtomicInteger maxHits = null;
private int maxDocsToCollect;
private final List<Collectors> reducableCollectors = new ArrayList<>();


@SafeVarargs
@SuppressWarnings({"varargs", "unchecked"})
public SolrMultiCollectorManager(QueryCommand queryCommand,
final CollectorManager<? extends Collector, ?>... collectorManagers) {
public SolrMultiCollectorManager(
QueryCommand queryCommand,
final CollectorManager<? extends Collector, ?>... collectorManagers) {
if (collectorManagers.length < 1) {
throw new IllegalArgumentException("There must be at least one collector");
}
Expand Down Expand Up @@ -91,13 +90,12 @@ public Object[] reduce(Collection<Collectors> reducableCollectors) throws IOExce
}
return results;
}

public Object[] reduce() throws IOException {
return reduce(reducableCollectors);
}

/**
* Wraps multiple collectors for processing
*/
/** Wraps multiple collectors for processing */
class Collectors implements Collector {

private final Collector[] collectors;
Expand All @@ -115,7 +113,7 @@ private Collectors() throws IOException {

@Override
public final LeafCollector getLeafCollector(final LeafReaderContext context)
throws IOException {
throws IOException {
return new LeafCollectors(context, scoreMode() == ScoreMode.TOP_SCORES);
}

Expand All @@ -135,7 +133,7 @@ private class LeafCollectors implements LeafCollector {
private final boolean skipNonCompetitiveScores;

private LeafCollectors(final LeafReaderContext context, boolean skipNonCompetitiveScores)
throws IOException {
throws IOException {
this.skipNonCompetitiveScores = skipNonCompetitiveScores;
leafCollectors = new LeafCollector[collectors.length];
for (int i = 0; i < collectors.length; i++) {
Expand All @@ -153,14 +151,14 @@ public final void setScorer(final Scorable scorer) throws IOException {
}
} else {
FilterScorable fScorer =
new FilterScorable(scorer) {
@Override
public void setMinCompetitiveScore(float minScore) throws IOException {
// Ignore calls to setMinCompetitiveScore so that if we wrap two
// collectors and one of them wants to skip low-scoring hits, then
// the other collector still sees all hits.
}
};
new FilterScorable(scorer) {
@Override
public void setMinCompetitiveScore(float minScore) throws IOException {
// Ignore calls to setMinCompetitiveScore so that if we wrap two
// collectors and one of them wants to skip low-scoring hits, then
// the other collector still sees all hits.
}
};
for (LeafCollector leafCollector : leafCollectors) {
if (leafCollector != null) {
leafCollector.setScorer(fScorer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,8 @@ public interface CommonParams {
*/
String MEM_ALLOWED = "memAllowed";


/**
* The max hits to be collected per shard
*/
String MAX_HITS_PER_SHARD="maxHitsPerShard";
/** The max hits to be collected per shard */
String MAX_HITS_PER_SHARD = "maxHitsPerShard";

/** Is the query cancellable? */
String IS_QUERY_CANCELLABLE = "canCancel";
Expand Down

0 comments on commit 7995cb1

Please sign in to comment.