Class MultiBits

  • All Implemented Interfaces:
    Bits

    public final class MultiBits
    extends java.lang.Object
    implements Bits
    Concatenates multiple Bits together, on every lookup.

    NOTE: This is very costly, as every lookup must do a binary search to locate the right sub-reader.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private MultiBits​(Bits[] subs, int[] starts, boolean defaultValue)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private boolean checkLength​(int reader, int doc)  
      boolean get​(int doc)
      Returns the value of the bit with the specified index.
      static Bits getLiveDocs​(IndexReader reader)
      Returns a single Bits instance for this reader, merging live Documents on the fly.
      int length()
      Returns the number of bits in this set
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • subs

        private final Bits[] subs
      • starts

        private final int[] starts
      • defaultValue

        private final boolean defaultValue
    • Constructor Detail

      • MultiBits

        private MultiBits​(Bits[] subs,
                          int[] starts,
                          boolean defaultValue)
    • Method Detail

      • getLiveDocs

        public static Bits getLiveDocs​(IndexReader reader)
        Returns a single Bits instance for this reader, merging live Documents on the fly. This method will return null if the reader has no deletions.

        NOTE: this is a very slow way to access live docs. For example, each Bits access will require a binary search. It's better to get the sub-readers and iterate through them yourself.

      • checkLength

        private boolean checkLength​(int reader,
                                    int doc)
      • get

        public boolean get​(int doc)
        Description copied from interface: Bits
        Returns the value of the bit with the specified index.
        Specified by:
        get in interface Bits
        Parameters:
        doc - index, should be non-negative and < Bits.length(). The result of passing negative or out of bounds values is undefined by this interface, just don't do it!
        Returns:
        true if the bit is set, false otherwise.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • length

        public int length()
        Description copied from interface: Bits
        Returns the number of bits in this set
        Specified by:
        length in interface Bits