public void countPostingListsPerDocument(List<PostingList> postingLists, byte[] nPostingListsForDocument) {
        Arrays.fill(nPostingListsForDocument, (byte) 0);
        List<int[]> nonCachedPostingLists = new ArrayList<>(postingLists.size());
        List<int[]> cachedPostingLists = new ArrayList<>(postingLists.size());
        long nDocumentsCachedPostingLists = 0;
        int postingListBitmap = 0;
        for (PostingList postingList : postingLists) {
            int[] docIds = postingList.getDocIds();
            int index = postingListMapping.getIfAbsent(docIds, -1);
            if (index >= 0) {
                cachedPostingLists.add(docIds);
                postingListBitmap |= (1 << index);
                nDocumentsCachedPostingLists += docIds.length;
            } else {
                nonCachedPostingLists.add(docIds);
            }
        }
        if (postingListBitmap != 0) {
            if (nDocumentsCachedPostingLists > nDocuments * THRESHOLD_USE_BIT_VECTOR) {
                countUsingBitVector(nPostingListsForDocument, postingListBitmap);
            } else {
                nonCachedPostingLists.addAll(cachedPostingLists);
            }
        }
        if (!nonCachedPostingLists.isEmpty()) {
            countUsingDocIdIteration(nPostingListsForDocument, nonCachedPostingLists);
        }
    }
Counts the number of posting lists per document id.
Caches the most expensive posting list in a bit vector.

@author bjorncs
predicate-search/src/main/java/com/yahoo/search/predicate/index/CachedPostingListCounter.java