Class FilteredDocIdSet

  • All Implemented Interfaces:
    Direct Known Subclasses:

    public abstract class FilteredDocIdSet
    extends DocIdSet
    Abstract decorator class for a DocIdSet implementation that provides on-demand filtering/validation mechanism on a given DocIdSet.

    Technically, this same functionality could be achieved with ChainedFilter (under queries/), however the benefit of this class is it never materializes the full bitset for the filter. Instead, the match(int) method is invoked on-demand, per docID visited during searching. If you know few docIDs will be visited, and the logic behind match(int) is relatively costly, this may be a better way to filter than ChainedFilter.

    See Also:
    • Constructor Detail

    • Method Detail

      • ramBytesUsed

        public long ramBytesUsed()
        Description copied from interface: Accountable
        Return the memory usage of this object in bytes. Negative values are illegal.
      • bits

        public Bits bits()
                  throws IOException
        Description copied from class: DocIdSet
        Optionally provides a Bits interface for random access to matching documents.
        bits in class DocIdSet
        null, if this DocIdSet does not support random access. In contrast to DocIdSet.iterator(), a return value of null does not imply that no documents match the filter! The default implementation does not provide random access, so you only need to implement this method if your DocIdSet can guarantee random access to every docid in O(1) time without external disk access (as Bits interface cannot throw IOException). This is generally true for bit sets like FixedBitSet, which return itself if they are used as DocIdSet.
      • match

        protected abstract boolean match(int docid)
        Validation method to determine whether a docid should be in the result set.
        docid - docid to be tested
        true if input docid should be in the result set, false otherwise.