Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-2208 Use a Query wrapper instead of a Filter in FreshReadersP…
…rovidedTest Because the Filter type is deprecated and will be removed. Upon execution, Filters are wrapped in Queries anyway, and their input comes from Weight.createScorer, so this should make no difference as far as recording is concerned.
- Loading branch information
Showing
2 changed files
with
124 additions
and
47 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
engine/src/test/java/org/hibernate/search/test/filters/ForwardingWeight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.test.filters; | ||
|
||
import java.io.IOException; | ||
import java.util.Set; | ||
|
||
import org.apache.lucene.index.LeafReaderContext; | ||
import org.apache.lucene.index.Term; | ||
import org.apache.lucene.search.BulkScorer; | ||
import org.apache.lucene.search.Explanation; | ||
import org.apache.lucene.search.Query; | ||
import org.apache.lucene.search.Scorer; | ||
import org.apache.lucene.search.Weight; | ||
|
||
/** | ||
* @author Yoann Rodiere | ||
*/ | ||
class ForwardingWeight extends Weight { | ||
|
||
private final Weight delegate; | ||
|
||
public ForwardingWeight(Query query, Weight delegate) { | ||
super( query ); | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringBuilder() | ||
.append( getClass().getSimpleName() ) | ||
.append( "(" ).append( delegate ).append( ")" ) | ||
.toString(); | ||
} | ||
|
||
@Override | ||
public void extractTerms(Set<Term> terms) { | ||
delegate.extractTerms( terms ); | ||
} | ||
|
||
@Override | ||
public Explanation explain(LeafReaderContext context, int doc) throws IOException { | ||
return delegate.explain( context, doc ); | ||
} | ||
|
||
@Override | ||
public float getValueForNormalization() throws IOException { | ||
return delegate.getValueForNormalization(); | ||
} | ||
|
||
@Override | ||
public void normalize(float norm, float boost) { | ||
delegate.normalize( norm, boost ); | ||
} | ||
|
||
@Override | ||
public Scorer scorer(LeafReaderContext context) throws IOException { | ||
return delegate.scorer( context ); | ||
} | ||
|
||
@Override | ||
public BulkScorer bulkScorer(LeafReaderContext context) throws IOException { | ||
return delegate.bulkScorer( context ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters