public override int Freq() { return(subQueryScorer.Freq()); }
public override int Freq() { return(scorer.Freq()); }
public override int NextDoc() { //System.out.println("Q.nextDoc() parentDoc=" + parentDoc + " childDoc=" + childDoc); // Loop until we hit a childDoc that's accepted while (true) { if (_childDoc + 1 == _parentDoc) { // OK, we are done iterating through all children // matching this one parent doc, so we now nextDoc() // the parent. Use a while loop because we may have // to skip over some number of parents w/ no // children: while (true) { _parentDoc = _parentScorer.NextDoc(); ValidateParentDoc(); if (_parentDoc == 0) { // Degenerate but allowed: first parent doc has no children // TODO: would be nice to pull initial parent // into ctor so we can skip this if... but it's // tricky because scorer must return -1 for // .doc() on init... _parentDoc = _parentScorer.NextDoc(); ValidateParentDoc(); } if (_parentDoc == NO_MORE_DOCS) { _childDoc = NO_MORE_DOCS; //System.out.println(" END"); return(_childDoc); } // Go to first child for this next parentDoc: _childDoc = 1 + _parentBits.PrevSetBit(_parentDoc - 1); if (_childDoc == _parentDoc) { // This parent has no children; continue // parent loop so we move to next parent continue; } if (_acceptDocs != null && !_acceptDocs.Get(_childDoc)) { goto nextChildDocContinue; } if (_childDoc < _parentDoc) { if (_doScores) { _parentScore = _parentScorer.Score(); _parentFreq = _parentScorer.Freq(); } //System.out.println(" " + childDoc); return(_childDoc); } else { // Degenerate but allowed: parent has no children } } } Debug.Assert(_childDoc < _parentDoc, "childDoc=" + _childDoc + " parentDoc=" + _parentDoc); _childDoc++; if (_acceptDocs != null && !_acceptDocs.Get(_childDoc)) { continue; } //System.out.println(" " + childDoc); return(_childDoc); nextChildDocContinue :; } }
public override int NextDoc() { //System.out.println("Q.nextDoc() nextChildDoc=" + nextChildDoc); // Loop until we hit a parentDoc that's accepted while (true) { if (_nextChildDoc == NO_MORE_DOCS) { //System.out.println(" end"); return(_parentDocRenamed = NO_MORE_DOCS); } // Gather all children sharing the same parent as // nextChildDoc _parentDocRenamed = _parentBits.NextSetBit(_nextChildDoc); // Parent & child docs are supposed to be // orthogonal: if (_nextChildDoc == _parentDocRenamed) { throw new InvalidOperationException("child query must only match non-parent docs, but parent docID=" + _nextChildDoc + " matched childScorer=" + _childScorer.GetType()); } //System.out.println(" parentDoc=" + parentDoc); Debug.Assert(_parentDocRenamed != -1); //System.out.println(" nextChildDoc=" + nextChildDoc); if (_acceptDocs != null && !_acceptDocs.Get(_parentDocRenamed)) { // Parent doc not accepted; skip child docs until // we hit a new parent doc: do { _nextChildDoc = _childScorer.NextDoc(); } while (_nextChildDoc < _parentDocRenamed); // Parent & child docs are supposed to be // orthogonal: if (_nextChildDoc == _parentDocRenamed) { throw new InvalidOperationException("child query must only match non-parent docs, but parent docID=" + _nextChildDoc + " matched childScorer=" + _childScorer.GetType()); } continue; } float totalScore = 0; float maxScore = float.NegativeInfinity; _childDocUpto = 0; _parentFreq = 0; do { //System.out.println(" c=" + nextChildDoc); if (_pendingChildDocs != null && _pendingChildDocs.Length == _childDocUpto) { _pendingChildDocs = ArrayUtil.Grow(_pendingChildDocs); } if (_pendingChildScores != null && _scoreMode != ScoreMode.None && _pendingChildScores.Length == _childDocUpto) { _pendingChildScores = ArrayUtil.Grow(_pendingChildScores); } if (_pendingChildDocs != null) { _pendingChildDocs[_childDocUpto] = _nextChildDoc; } if (_scoreMode != ScoreMode.None) { // TODO: specialize this into dedicated classes per-scoreMode float childScore = _childScorer.Score(); int childFreq = _childScorer.Freq(); if (_pendingChildScores != null) { _pendingChildScores[_childDocUpto] = childScore; } maxScore = Math.Max(childScore, maxScore); totalScore += childScore; _parentFreq += childFreq; } _childDocUpto++; _nextChildDoc = _childScorer.NextDoc(); } while (_nextChildDoc < _parentDocRenamed); // Parent & child docs are supposed to be // orthogonal: if (_nextChildDoc == _parentDocRenamed) { throw new InvalidOperationException("child query must only match non-parent docs, but parent docID=" + _nextChildDoc + " matched childScorer=" + _childScorer.GetType()); } switch (_scoreMode) { case ScoreMode.Avg: _parentScore = totalScore / _childDocUpto; break; case ScoreMode.Max: _parentScore = maxScore; break; case ScoreMode.Total: _parentScore = totalScore; break; case ScoreMode.None: break; } //System.out.println(" return parentDoc=" + parentDoc + " childDocUpto=" + childDocUpto); return(_parentDocRenamed); } }