if (groupBy == null) {
resList = ListMerger.mergeLists(_offset, _count, iterList, MERGE_COMPATATOR);
} else {
int rawGroupValueType = 0; // 0: unknown, 1: normal, 2: long[]
PrimitiveLongArrayWrapper primitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);
Object rawGroupValue = null;
if (_facetAccessibleLists != null) {
_groupAccessibles = new CombinedFacetAccessible[_facetAccessibleLists.length];
for (int i = 0; i < _facetAccessibleLists.length; ++i)
_groupAccessibles[i] = new CombinedFacetAccessible(new FacetSpec(),
_facetAccessibleLists[i]);
}
resList = new ArrayList<MyScoreDoc>(_count);
Iterator<MyScoreDoc> mergedIter = ListMerger.mergeLists(iterList, MERGE_COMPATATOR);
Set<Object> groupSet = new HashSet<Object>(_offset + _count);
int offsetLeft = _offset;
while (mergedIter.hasNext()) {
MyScoreDoc scoreDoc = mergedIter.next();
Object[] vals = groupBy.getRawFieldValues(scoreDoc.reader, scoreDoc.doc);
rawGroupValue = null;
if (vals != null && vals.length > 0) rawGroupValue = vals[0];
if (rawGroupValueType == 0) {
if (rawGroupValue != null) {
if (rawGroupValue instanceof long[]) rawGroupValueType = 2;
else rawGroupValueType = 1;
}
}
if (rawGroupValueType == 2) {
primitiveLongArrayWrapperTmp.data = (long[]) rawGroupValue;
rawGroupValue = primitiveLongArrayWrapperTmp;
}
if (!groupSet.contains(rawGroupValue)) {
if (offsetLeft > 0) --offsetLeft;
else {
resList.add(scoreDoc);
if (resList.size() >= _count) break;
}
groupSet.add(new PrimitiveLongArrayWrapper(primitiveLongArrayWrapperTmp.data));
}
}
}
} else resList = Collections.emptyList();