org.apache.lucene.index

## Class PerThreadPKLookup

- java.lang.Object
- - org.apache.lucene.index.PerThreadPKLookup

-     public class PerThreadPKLookup
      extends Object

  Utility class to do efficient primary-key (only 1 doc contains the given term) lookups by segment, re-using the enums. This class is not thread safe, so it is the caller's job to create and use one instance of this per thread. Do not use this if a term may appear in more than one document! It will only return the first one it finds.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int[]` | `docBases`
    `protected boolean` | `hasDeletions`
    `protected Bits[]` | `liveDocs`
    `protected int` | `numSegs`
    `protected PostingsEnum[]` | `postingsEnums`
    `protected TermsEnum[]` | `termsEnums`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PerThreadPKLookup(IndexReader r, String idFieldName)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `lookup(BytesRef id)` Returns docID if found, else -1.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### termsEnums

          protected final TermsEnum[] termsEnums

    - #### postingsEnums

          protected final PostingsEnum[] postingsEnums

    - #### liveDocs

          protected final Bits[] liveDocs

    - #### docBases

          protected final int[] docBases

    - #### numSegs

          protected final int numSegs

    - #### hasDeletions

          protected final boolean hasDeletions

  - ### Constructor Detail

    - #### PerThreadPKLookup

          public PerThreadPKLookup(IndexReader r,
                                   String idFieldName)
                            throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### lookup

          public int lookup(BytesRef id)
                     throws IOException

      Returns docID if found, else -1.
      Throws:
        `IOException`

Copyright © 2000-2024 Apache Software Foundation. All Rights Reserved.