docs: private static void createTermvectorFirstRound(
        List<ComponentTermVector> termVectorList,
        Map<Integer, Integer> positionsData, List<Integer> docSet, Terms t,
        LeafReader r, LeafReaderContext lrc) throws IOException {
      if (t != null) {
        BytesRef term;
        TermsEnum termsEnum;
        PostingsEnum postingsEnum = null;
        String segmentName = "segment" + lrc.ord;
        String[] mutableKey = new String[1];
        int segmentNumber = lrc.parent.leaves().size();
        // loop over termvectors
        for (ComponentTermVector termVector : termVectorList) {
          CompiledAutomaton compiledAutomaton;
          if ((termVector.regexp == null) || (termVector.regexp.isEmpty())) {
            RegExp re = new RegExp(
                termVector.prefix + MtasToken.DELIMITER + ".*");
            compiledAutomaton = new CompiledAutomaton(re.toAutomaton());
          } else {
            RegExp re = new RegExp(termVector.prefix + MtasToken.DELIMITER
                + termVector.regexp + "\u0000*");
            compiledAutomaton = new CompiledAutomaton(re.toAutomaton());
          }
          List<ByteRunAutomaton> ignoreByteRunAutomatonList = null;
          if ((termVector.ignoreRegexp != null)
              && (!termVector.ignoreRegexp.isEmpty())) {
            ignoreByteRunAutomatonList = new ArrayList<>();
            RegExp re = new RegExp(termVector.prefix + MtasToken.DELIMITER
                + termVector.ignoreRegexp + "\u0000*");
            ignoreByteRunAutomatonList
                .add(new ByteRunAutomaton(re.toAutomaton()));
          }
          if (termVector.ignoreList != null) {
            if (ignoreByteRunAutomatonList == null) {
              ignoreByteRunAutomatonList = new ArrayList<>();
            }
            Map<String, Automaton> list = MtasToken.createAutomatonMap(
                termVector.prefix, new ArrayList<String>(termVector.ignoreList),
                termVector.ignoreListRegexp ? false : true);
            for (Automaton automaton : list.values()) {
              ignoreByteRunAutomatonList.add(new ByteRunAutomaton(automaton));
            }
          }
          if (!termVector.full && termVector.list == null) {
            termsEnum = t.intersect(compiledAutomaton, null);
            int initSize = Math.min((int) t.size(), 1000);
            termVector.subComponentFunction.dataCollector.initNewList(initSize,
                segmentName, segmentNumber, termVector.boundary);
            if (termVector.functions != null) {
              for (SubComponentFunction function : termVector.functions) {
                function.dataCollector.initNewList(initSize);
              }
            }
            // only if documents
            if (!docSet.isEmpty()) {
              int termDocId;
              int termNumberMaximum = termVector.number;
              HashMap<BytesRef, RegisterStatus> computeFullList = new HashMap<>();
              RegisterStatus registerStatus;
              // basic, don't need full values
              if (termVector.subComponentFunction.sortType
                  .equals(CodecUtil.SORT_TERM)
                  || termVector.subComponentFunction.sortType
                      .equals(CodecUtil.STATS_TYPE_SUM)
                  || termVector.subComponentFunction.sortType
                      .equals(CodecUtil.STATS_TYPE_N)) {
                int termCounter = 0;
  
                boolean continueAfterPreliminaryCheck;
                boolean preliminaryCheck = false;
                if (r.getLiveDocs() == null && (docSet.size() != r.numDocs())) {
                  preliminaryCheck = true;
                }
                // loop over terms
                boolean acceptedTerm;
                while ((term = termsEnum.next()) != null) {
                  if (validateTermWithStartValue(term, termVector)
                      && validateTermWithDistance(term, termVector)) {
                    termDocId = -1;
                    acceptedTerm = true;
                    if (ignoreByteRunAutomatonList != null) {
                      for (ByteRunAutomaton ignoreByteRunAutomaton : ignoreByteRunAutomatonList) {
                        if (ignoreByteRunAutomaton.run(term.bytes, term.offset,
                            term.length)) {
                          acceptedTerm = false;
                          break;
                        }
                      }
                    }
                    if (acceptedTerm) {
                      continueAfterPreliminaryCheck = true;
                      mutableKey[0] = null;
                      if (preliminaryCheck) {
                        try {
                          TermvectorNumberBasic preliminaryNumberBasic = computeTermvectorNumberBasic(
                              termsEnum, r);
                          if (preliminaryNumberBasic.docNumber > 0) {
                            continueAfterPreliminaryCheck = preliminaryRegisterValue(
                                term, termVector, preliminaryNumberBasic,
                                termNumberMaximum, segmentNumber, mutableKey);
                          } else {
                            continueAfterPreliminaryCheck = false;
                          }
                        } catch (IOException e) {
                          log.debug(e);
                          continueAfterPreliminaryCheck = true;
                        }
                      }
                      if (continueAfterPreliminaryCheck) {
                        // compute numbers;
                        TermvectorNumberBasic numberBasic = computeTermvectorNumberBasic(
                            docSet, termDocId, termsEnum, r, lrc, postingsEnum);
                        // register
                        if (numberBasic.docNumber > 0) {
                          termCounter++;
                          registerStatus = registerValue(term, termVector,
                              numberBasic, termNumberMaximum, segmentNumber,
                              false, mutableKey);
                          if (registerStatus != null) {
                            computeFullList.put(BytesRef.deepCopyOf(term),
                                registerStatus);
                          }
                        }
                      } 
                      // stop after termCounterMaximum
                      if (termVector.subComponentFunction.sortType
                          .equals(CodecUtil.SORT_TERM)
                          && termVector.subComponentFunction.sortDirection
                              .equals(CodecUtil.SORT_ASC)
                          && termCounter >= termNumberMaximum) {
                        break;
                      }
                    }
                  }
                }
                // rerun for full
                if (computeFullList.size() > 0) {
                  termsEnum = t.intersect(compiledAutomaton, null);
                  while ((term = termsEnum.next()) != null) {
                    if (validateTermWithStartValue(term, termVector)
                        && validateTermWithDistance(term, termVector)) {
                      termDocId = -1;
                      mutableKey[0] = null;
                      // only if (probably) needed
                      if (computeFullList.containsKey(term)) {
                        registerStatus = computeFullList.get(term);
                        boolean doAdd;
                        doAdd = termVector.subComponentFunction.sortType
                            .equals(CodecUtil.SORT_TERM);
                        doAdd |= termVector.subComponentFunction.sortDirection
                            .equals(CodecUtil.SORT_ASC);
                        doAdd |= termVector.list != null;
                        doAdd |= termVector.boundaryRegistration;
                        doAdd |= registerStatus.force;
                        doAdd |= termVector.subComponentFunction.dataCollector
                            .validateSegmentBoundary(registerStatus.sortValue);
                        if (doAdd) {
                          TermvectorNumberFull numberFull = computeTermvectorNumberFull(
                              docSet, termDocId, termsEnum, lrc, postingsEnum,
                              positionsData);
                          if (numberFull.docNumber > 0) {
                            termCounter++;
                            registerValue(term, termVector, numberFull,
                                mutableKey);
                          }
                        }
                      }
                    }
                  }
                  computeFullList.clear();
                }
              } else {
                throw new IOException(
                    "sort '" + termVector.subComponentFunction.sortType + " "
                        + termVector.subComponentFunction.sortDirection
                        + "' not supported");
              }
              // finish if segments are used
              termVector.subComponentFunction.dataCollector
                  .closeSegmentKeyValueRegistration();
              if (termVector.functions != null) {
                for (SubComponentFunction function : termVector.functions) {
                  function.dataCollector.closeSegmentKeyValueRegistration();
                }
              }
            }
            termVector.subComponentFunction.dataCollector.closeNewList();
            if (termVector.functions != null) {
              for (SubComponentFunction function : termVector.functions) {
                function.dataCollector.closeNewList();
              }
            }
          }
        }
      }
    }