private IntsRef postingsEnumToIntsRef ( PostingsEnum postingsEnum , Bits liveDocs ) throws IOException { // (The cache can have empty IntsRefs) //lookup prefixBuf in a cache if ( docIdsCache != null ) { docIds = docIdsCache . get ( prefixBuf ) ; if ( docIds != null ) { return docIds ; } } //read postingsEnum docIds = new IntsRef ( termsEnum . docFreq ( ) ) ; int docId ; while ( ( docId = postingsEnum . nextDoc ( ) ) != PostingsEnum . NO_MORE_DOCS ) { if ( liveDocs != null && ! liveDocs . get ( postingsEnum . docID ( ) ) ) { continue ; } docIds . ints [ docIds . length ++ ] = docId ; } if ( docIds . length == 0 ) docIds = EMPTY_INTSREF ; //cache if ( docIdsCache != null ) { ensureBufIsACopy ( ) ; //clone is shallow; that's okay as the prefix isn't overwritten; it's just appended to docIdsCache . put ( prefixBuf . clone ( ) , docIds ) ; } return docIds ; }
Returns an IntsRef either cached or reading postingsEnum . Not null .