@Override
 public BytesRef next() throws IOException {
   if (++curPos < entries.size()) {
     entries.get(spare, curPos);
     return spare;
   }
   return null;
 }
 /** Creates a new iterator, buffering entries from the specified iterator */
 public BufferingTermFreqIteratorWrapper(TermFreqIterator source) throws IOException {
   this.comp = source.getComparator();
   BytesRef spare;
   int freqIndex = 0;
   while ((spare = source.next()) != null) {
     entries.append(spare);
     if (freqIndex >= freqs.length) {
       freqs = ArrayUtil.grow(freqs, freqs.length + 1);
     }
     freqs[freqIndex++] = source.weight();
   }
 }