Class SortedIntDocSet

  • All Implemented Interfaces:
    Cloneable, org.apache.lucene.util.Accountable

    public class SortedIntDocSet
    extends DocSet
    A simple sorted int[] array implementation of DocSet, good for small sets.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int[] docs  
      static SortedIntDocSet zero  
      static int[] zeroInts  
      • Fields inherited from interface org.apache.lucene.util.Accountable

        NULL_ACCOUNTABLE
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAllTo​(org.apache.lucene.util.FixedBitSet target)
      Adds all the docs from this set to the target.
      static int andNot​(int[] a, int lena, int[] b, int lenb, int[] target)
      puts the intersection of a and not b into the target array and returns the size
      DocSet andNot​(DocSet other)
      Returns the documents in this set that are not in the other set.
      protected static int andNotBinarySearch​(int[] a, int lena, int[] b, int lenb, int[] target)  
      SortedIntDocSet clone()  
      boolean exists​(int doc)
      Returns true if a document is in the DocSet.
      org.apache.lucene.util.Bits getBits()
      A Bits that has fast random access (as is generally required of Bits).
      Collection<org.apache.lucene.util.Accountable> getChildResources()  
      int[] getDocs()  
      protected org.apache.lucene.util.FixedBitSet getFixedBitSet()  
      protected org.apache.lucene.util.FixedBitSet getFixedBitSetClone()  
      static int intersection​(int[] a, int lena, int[] b, int lenb, int[] target)
      puts the intersection of a and b into the target array and returns the size
      DocSet intersection​(DocSet other)
      Returns the intersection of this set with another set.
      protected static int intersectionBinarySearch​(int[] a, int lena, int[] b, int lenb, int[] target)
      Puts the intersection of a and b into the target array and returns the size.
      static int intersectionSize​(int[] smallerSortedList, int[] biggerSortedList)  
      int intersectionSize​(DocSet other)
      Returns the number of documents of the intersection of this set with another set.
      static boolean intersects​(int[] smallerSortedList, int[] biggerSortedList)  
      boolean intersects​(DocSet other)
      Returns true if these sets have any elements in common
      DocIterator iterator()
      Returns an ordered iterator of the documents in the set.
      org.apache.lucene.search.DocIdSetIterator iterator​(org.apache.lucene.index.LeafReaderContext context)
      Returns an ordered iterator of the documents in the set for the specified LeafReaderContext.
      org.apache.solr.search.DocSetQuery makeQuery()
      Returns a Query matching these documents with a score of 1.
      long ramBytesUsed()  
      static int[] shrink​(int[] arr, int newSize)  
      int size()
      Returns the number of documents in the set.
      String toString()  
      DocSet union​(DocSet other)
      Returns the union of this set with another set.
    • Field Detail

      • docs

        protected final int[] docs
      • zeroInts

        public static int[] zeroInts
    • Constructor Detail

      • SortedIntDocSet

        public SortedIntDocSet​(int[] docs)
        Parameters:
        docs - Sorted list of ids
      • SortedIntDocSet

        public SortedIntDocSet​(int[] docs,
                               int len)
        Parameters:
        docs - Sorted list of ids
        len - Number of ids in the list
    • Method Detail

      • getDocs

        public int[] getDocs()
      • size

        public int size()
        Description copied from class: DocSet
        Returns the number of documents in the set.
        Specified by:
        size in class DocSet
      • shrink

        public static int[] shrink​(int[] arr,
                                   int newSize)
      • intersectionSize

        public static int intersectionSize​(int[] smallerSortedList,
                                           int[] biggerSortedList)
      • intersects

        public static boolean intersects​(int[] smallerSortedList,
                                         int[] biggerSortedList)
      • intersectionSize

        public int intersectionSize​(DocSet other)
        Description copied from class: DocSet
        Returns the number of documents of the intersection of this set with another set. May be more efficient than actually creating the intersection and then getting its size.
        Specified by:
        intersectionSize in class DocSet
      • intersects

        public boolean intersects​(DocSet other)
        Description copied from class: DocSet
        Returns true if these sets have any elements in common
        Specified by:
        intersects in class DocSet
      • intersection

        public static int intersection​(int[] a,
                                       int lena,
                                       int[] b,
                                       int lenb,
                                       int[] target)
        puts the intersection of a and b into the target array and returns the size
      • intersectionBinarySearch

        protected static int intersectionBinarySearch​(int[] a,
                                                      int lena,
                                                      int[] b,
                                                      int lenb,
                                                      int[] target)
        Puts the intersection of a and b into the target array and returns the size. lena should be smaller than lenb
      • intersection

        public DocSet intersection​(DocSet other)
        Description copied from class: DocSet
        Returns the intersection of this set with another set. Neither set is modified - a new DocSet is created and returned.
        Specified by:
        intersection in class DocSet
        Returns:
        a DocSet representing the intersection
      • andNotBinarySearch

        protected static int andNotBinarySearch​(int[] a,
                                                int lena,
                                                int[] b,
                                                int lenb,
                                                int[] target)
      • andNot

        public static int andNot​(int[] a,
                                 int lena,
                                 int[] b,
                                 int lenb,
                                 int[] target)
        puts the intersection of a and not b into the target array and returns the size
      • andNot

        public DocSet andNot​(DocSet other)
        Description copied from class: DocSet
        Returns the documents in this set that are not in the other set. Neither set is modified - a new DocSet is created and returned.
        Specified by:
        andNot in class DocSet
        Returns:
        a DocSet representing this AND NOT other
      • addAllTo

        public void addAllTo​(org.apache.lucene.util.FixedBitSet target)
        Description copied from class: DocSet
        Adds all the docs from this set to the target. The target should be sized large enough to accommodate all of the documents before calling this method.
        Specified by:
        addAllTo in class DocSet
      • exists

        public boolean exists​(int doc)
        Description copied from class: DocSet
        Returns true if a document is in the DocSet. If you want to be guaranteed fast random access, use DocSet.getBits() instead.
        Specified by:
        exists in class DocSet
      • iterator

        public DocIterator iterator()
        Description copied from class: DocSet
        Returns an ordered iterator of the documents in the set. Any scoring information is meaningless.
        Specified by:
        iterator in class DocSet
      • getBits

        public org.apache.lucene.util.Bits getBits()
        Description copied from class: DocSet
        A Bits that has fast random access (as is generally required of Bits). It may be necessary to do work to build this.
        Specified by:
        getBits in class DocSet
      • getFixedBitSet

        protected org.apache.lucene.util.FixedBitSet getFixedBitSet()
        Specified by:
        getFixedBitSet in class DocSet
      • getFixedBitSetClone

        protected org.apache.lucene.util.FixedBitSet getFixedBitSetClone()
        Specified by:
        getFixedBitSetClone in class DocSet
      • union

        public DocSet union​(DocSet other)
        Description copied from class: DocSet
        Returns the union of this set with another set. Neither set is modified - a new DocSet is created and returned.
        Specified by:
        union in class DocSet
        Returns:
        a DocSet representing the union
      • iterator

        public org.apache.lucene.search.DocIdSetIterator iterator​(org.apache.lucene.index.LeafReaderContext context)
        Description copied from class: DocSet
        Returns an ordered iterator of the documents in the set for the specified LeafReaderContext. NOTE: may return null if there are no matching documents for this leaf.
        Specified by:
        iterator in class DocSet
      • makeQuery

        public org.apache.solr.search.DocSetQuery makeQuery()
        Description copied from class: DocSet
        Returns a Query matching these documents with a score of 1. Note that DocSets do not refer to deleted docs.
        Specified by:
        makeQuery in class DocSet
      • ramBytesUsed

        public long ramBytesUsed()
      • getChildResources

        public Collection<org.apache.lucene.util.Accountable> getChildResources()