@@ -378,8 +378,10 @@ public Scorer get(long leadCost) throws IOException {
378378 List <DisiWrapper > wrappers = new ArrayList <>(iterators .size ());
379379 for (int i = 0 ; i < iterators .size (); i ++) {
380380 float weight = fields .get (i ).weight ;
381- wrappers .add (
382- new WeightedDisiWrapper (new TermScorer (iterators .get (i ), simWeight , null ), weight ));
381+ Scorer scorer = new TermScorer (iterators .get (i ), simWeight , null );
382+ DisiWrapper w = new DisiWrapper (scorer , false , weight );
383+ assert w .postingsEnum != null ; // needed to access term frequencies
384+ wrappers .add (w );
383385 }
384386 // Even though it is called approximation, it is accurate since none of
385387 // the sub iterators are two-phase iterators.
@@ -401,21 +403,6 @@ public boolean isCacheable(LeafReaderContext ctx) {
401403 }
402404 }
403405
404- private static class WeightedDisiWrapper extends DisiWrapper {
405- final PostingsEnum postingsEnum ;
406- final float weight ;
407-
408- WeightedDisiWrapper (Scorer scorer , float weight ) {
409- super (scorer , false );
410- this .weight = weight ;
411- this .postingsEnum = (PostingsEnum ) scorer .iterator ();
412- }
413-
414- float freq () throws IOException {
415- return weight * postingsEnum .freq ();
416- }
417- }
418-
419406 private static class CombinedFieldScorer extends Scorer {
420407 private final DisjunctionDISIApproximation iterator ;
421408 private final MultiNormsLeafSimScorer simScorer ;
@@ -434,9 +421,9 @@ public int docID() {
434421
435422 float freq () throws IOException {
436423 DisiWrapper w = iterator .topList ();
437- float freq = (( WeightedDisiWrapper ) w ). freq ();
424+ float freq = w . postingsEnum . freq () * w . weight ;
438425 for (w = w .next ; w != null ; w = w .next ) {
439- freq += (( WeightedDisiWrapper ) w ). freq ();
426+ freq += w . postingsEnum . freq () * w . weight ;
440427 if (freq < 0 ) { // overflow
441428 return Integer .MAX_VALUE ;
442429 }
0 commit comments