_tmpScoreDoc.doc = doc;
_tmpScoreDoc.score = score;
if (!_queueFull || _currentComparator.compare(_bottom, _tmpScoreDoc) > 0) {
final int order = ((FacetDataCache<?>) groupBy.getFacetData(_currentReader)).orderArray
.get(doc);
ScoreDoc pre = _currentValueDocMaps.get(order);
if (pre != null) {
if (_currentComparator.compare(pre, _tmpScoreDoc) > 0) {
ScoreDoc tmp = pre;
_bottom = _currentQueue.replace(_tmpScoreDoc, pre);
_currentValueDocMaps.put(order, _tmpScoreDoc);
_tmpScoreDoc = tmp;
}
} else {
if (_queueFull) {
MyScoreDoc tmp = (MyScoreDoc) _bottom;
_currentValueDocMaps
.remove(((FacetDataCache<?>) groupBy.getFacetData(tmp.reader)).orderArray
.get(tmp.doc));
_bottom = _currentQueue.replace(_tmpScoreDoc);
_currentValueDocMaps.put(order, _tmpScoreDoc);
_tmpScoreDoc = tmp;
} else {
ScoreDoc tmp = new MyScoreDoc(doc, score, _currentQueue, _currentReader);
_bottom = _currentQueue.add(tmp);
_currentValueDocMaps.put(order, tmp);
_queueFull = (_currentQueue.size >= _numHits);
}
}
}
}
}
} else {
if (_count > 0) {
final float score = (_doScoring ? _scorer.score() : 0.0f);
if (_queueFull) {
_tmpScoreDoc.doc = doc;
_tmpScoreDoc.score = score;
if (_currentComparator.compare(_bottom, _tmpScoreDoc) > 0) {
ScoreDoc tmp = _bottom;
_bottom = _currentQueue.replace(_tmpScoreDoc);
_tmpScoreDoc = tmp;
}
} else {
_bottom = _currentQueue.add(new MyScoreDoc(doc, score, _currentQueue, _currentReader));