Esempio n. 1
0
 /// <summary>
 /// (non-Javadoc)
 /// see com.browseengine.bobo.util.BigSegmentedArray#findValues(org.apache.lucene.util.OpenBitSet, int, int)
 /// </summary>
 /// <param name="bitset"></param>
 /// <param name="id"></param>
 /// <param name="maxId"></param>
 /// <returns></returns>
 public override int FindValues(OpenBitSet bitset, int id, int maxId)
 {
     while (id <= maxId)
     {
         int i = id >> SHIFT_SIZE;
         if (_array[i] == null)
         {
             if (bitset.FastGet(_fillValue))
             {
                 return(id);
             }
             else
             {
                 id = (i + 1) << SHIFT_SIZE; // jump to next segment
             }
         }
         else
         {
             if (bitset.FastGet(_array[i][id & MASK]))
             {
                 return(id);
             }
             else
             {
                 id++;
             }
         }
     }
     return(DocIdSetIterator.NO_MORE_DOCS);
 }
Esempio n. 2
0
        public int FindValues(OpenBitSet values, int id, int maxID, bool withMissing)
        {
            // NOTE: Added Get() extension method call because
            // the default .NET behavior throws an exception if the
            // index is out of bounds, rather than returning null.
            int[] page = m_list.Get(id >> PAGEID_SHIFT);
            if (page == null)
            {
                page = MISSING_PAGE;
            }

            while (true)
            {
                int val = page[id & SLOTID_MASK];
                if (val >= 0)
                {
                    if (values.FastGet(val))
                    {
                        return(id);
                    }
                }
                else if (val != MISSING)
                {
                    int idx = -(val >> VALIDX_SHIFT);// signed shift, remember this is a negative number
                    int end = idx + (val & COUNT_MASK);
                    while (idx < end)
                    {
                        if (values.FastGet(page[idx++]))
                        {
                            return(id);
                        }
                    }
                }
                else if (withMissing)
                {
                    if (values.FastGet(0))
                    {
                        return(id);
                    }
                }
                if (id >= maxID)
                {
                    break;
                }

                if ((++id & SLOTID_MASK) == 0)
                {
                    // NOTE: Added Get() extension method call because
                    // the default .NET behavior throws an exception if the
                    // index is out of bounds, rather than returning null.
                    page = m_list.Get(id >> PAGEID_SHIFT);
                    if (page == null)
                    {
                        page = MISSING_PAGE;
                    }
                }
            }

            return(DocIdSetIterator.NO_MORE_DOCS);
        }
Esempio n. 3
0
        public bool Contains(int id, OpenBitSet values)
        {
            // NOTE: Added Get() extension method call because
            // the default .NET behavior throws an exception if the
            // index is out of bounds, rather than returning null.
            int[] page = m_list.Get(id >> PAGEID_SHIFT);
            if (page == null)
            {
                return(false);
            }

            int val = page[id & SLOTID_MASK];

            if (val >= 0)
            {
                return(values.FastGet(val));
            }
            else if (val != MISSING)
            {
                int idx = -(val >> VALIDX_SHIFT); // signed shift, remember this is a negative number
                int end = idx + (val & COUNT_MASK);
                while (idx < end)
                {
                    if (values.FastGet(page[idx++]))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 4
0
            public FacetOrDocIdSetIterator(FacetDataCache dataCache, OpenBitSet bitset)
            {
                _dataCache  = dataCache;
                _orderArray = dataCache.OrderArray;
                _bitset     = bitset;

                _doc   = int.MaxValue;
                _maxID = -1;
                int size = _dataCache.ValArray.Count;

                for (int i = 0; i < size; ++i)
                {
                    if (!bitset.FastGet(i))
                    {
                        continue;
                    }
                    if (_doc > _dataCache.MinIDs[i])
                    {
                        _doc = _dataCache.MinIDs[i];
                    }
                    if (_maxID < _dataCache.MaxIDs[i])
                    {
                        _maxID = _dataCache.MaxIDs[i];
                    }
                }
                _doc--;
                if (_doc < 0)
                {
                    _doc = -1;
                }
            }
 public override bool Get(int docId)
 {
     if (m_multi)
     {
         return(m_multiCache.NestedArray.Contains(docId, m_openBitSet));
     }
     else
     {
         return(m_openBitSet.FastGet(m_dataCache.OrderArray.Get(docId)));
     }
 }
Esempio n. 6
0
        public void CountNoReturnWithFilter(int id, int[] count, OpenBitSet filter)
        {
            // NOTE: Added Get() extension method call because
            // the default .NET behavior throws an exception if the
            // index is out of bounds, rather than returning null.
            int[] page = m_list.Get(id >> PAGEID_SHIFT);
            if (page == null)
            {
                count[0]++;
                return;
            }

            int val = page[id & SLOTID_MASK];

            if (val >= 0)
            {
                if (filter.FastGet(val))
                {
                    count[val]++;
                }
                return;
            }
            else if (val != MISSING)
            {
                int idx = -(val >> VALIDX_SHIFT); // signed shift, remember val is a negative number
                int cnt = (val & COUNT_MASK);
                int end = idx + cnt;
                while (idx < end)
                {
                    int value = page[idx++];
                    if (filter.FastGet(value))
                    {
                        count[value]++;
                    }
                }
                return;
            }
            count[0]++;
            return;
        }
Esempio n. 7
0
        public void CountNoReturnWithFilter(int id, BigSegmentedArray count, OpenBitSet filter)
        {
            int[] page = m_list[id >> PAGEID_SHIFT];
            if (page == null)
            {
                count.Add(0, count.Get(0) + 1);
                return;
            }

            int val = page[id & SLOTID_MASK];

            if (val >= 0)
            {
                if (filter.FastGet(val))
                {
                    count.Add(val, count.Get(val) + 1);
                }
                return;
            }
            else if (val != MISSING)
            {
                int idx = -(val >> VALIDX_SHIFT); // signed shift, remember val is a negative number
                int cnt = (val & COUNT_MASK);
                int end = idx + cnt;
                while (idx < end)
                {
                    int value = page[idx++];
                    if (filter.FastGet(value))
                    {
                        count.Add(value, count.Get(value) + 1);
                    }
                }
                return;
            }
            count.Add(0, count.Get(0) + 1);
            return;
        }
Esempio n. 8
0
 public override sealed int FindValues(OpenBitSet bitset, int docId, int maxId)
 {
     while (true)
     {
         if (bitset.FastGet(_array[docId >> SHIFT_SIZE][docId & MASK]))
         {
             return(docId);
         }
         if (docId++ >= maxId)
         {
             break;
         }
     }
     return(DocIdSetIterator.NO_MORE_DOCS);
 }
Esempio n. 9
0
 public override bool Get(int docId)
 {
     return(_bitset.FastGet(_orderArray.Get(docId)));
 }