code: private static Map<Integer, Integer> computePositions(CodecInfo mtasCodecInfo,
        LeafReader r, LeafReaderContext lrc, String field, List<Integer> docSet)
        throws IOException {
      HashMap<Integer, Integer> positionsData;
      if (mtasCodecInfo != null) {
        // for relatively small numbers, compute only what is needed
        if (docSet.size() < Math.log(r.maxDoc())) {
          positionsData = new HashMap<>();
          for (int docId : docSet) {
            positionsData.put(docId,
                mtasCodecInfo.getNumberOfPositions(field, (docId - lrc.docBase)));
          }
          // compute everything, only use what is needed
        } else {
          positionsData = mtasCodecInfo.getAllNumberOfPositions(field,
              lrc.docBase);
          for (int docId : docSet) {
            if (!positionsData.containsKey(docId)) {
              positionsData.put(docId, 0);
            }
          }
        }
      } else {
        positionsData = new HashMap<>();
        for (int docId : docSet) {
          positionsData.put(docId, 0);
        }
      }
      return positionsData;
    }
docs: Compute positions.
  
  @param mtasCodecInfo
  the mtas codec info
  @param r
  the r
  @param lrc
  the lrc
  @param field
  the field
  @param docSet
  the doc set
  @return the map
  @throws IOException
  Signals that an I/O exception has occurred.