Ejemplo n.º 1
0
        public override DocIdSet getDocIdSet(IndexReader indexReader)
        {
            var locationFields = FieldCache.__Fields.DEFAULT.getInts(indexReader, _locationFieldName, FieldCache.__Fields.NUMERIC_UTILS_INT_PARSER);

            string[] relocationFields = null;
            if (_includeRelocating)
            {
                relocationFields = FieldCache.__Fields.DEFAULT.getStrings(indexReader, _relocationsFieldName);
            }

            int numDocs  = indexReader.maxDoc();
            var docIdSet = new OpenBitSet(numDocs);

            for (int i = 0; i < numDocs; i++)
            {
                // Check for exact location match.

                int location = locationFields[i] - 1;
                if (location >= 0 && _matchingLocations[location])
                {
                    docIdSet.fastSet(i);
                    continue;
                }

                // Filter out international candidates.

                if (!_includeInternational)
                {
                    if (location < 0 || !_homeLocations[location])
                    {
                        continue;
                    }
                }

                // Check relocation preferences.

                if (_includeRelocating)
                {
                    var field = relocationFields[i];
                    if (field != null)
                    {
                        for (int pos = 0; pos < field.Length; pos += NumericUtils.BUF_SIZE_INT)
                        {
                            string prefixCoded = field.Substring(pos, NumericUtils.BUF_SIZE_INT);
                            int    relocation  = NumericUtils.prefixCodedToInt(prefixCoded);

                            if (_matchingRelocations[relocation])
                            {
                                docIdSet.fastSet(i);
                                break;
                            }
                        }
                    }
                }
            }

            return(docIdSet);
        }
Ejemplo n.º 2
0
        public override DocIdSet getDocIdSet(IndexReader reader)
        {
            var bitCount = reader.maxDoc();
            var bits     = new OpenBitSet(bitCount);

            if (_exclude)
            {
                bits.set(0, bitCount);
            }

            var docs         = new int[1];
            var freqs        = new int[1];
            var termTemplate = new Term(_fieldName);

            foreach (string special in _specials)
            {
                TermDocs termDocs = reader.termDocs(termTemplate.createTerm(special));
                int      count    = termDocs.read(docs, freqs);
                if (count == 1)
                {
                    if (_exclude)
                    {
                        bits.fastClear(docs[0]);
                    }
                    else
                    {
                        bits.fastSet(docs[0]);
                    }
                }
            }

            return(bits);
        }
Ejemplo n.º 3
0
        public override DocComparator getComparator(IndexReader reader, int docBase)
        {
            var bitCount  = reader.maxDoc();
            var docValues = new OpenBitSet(bitCount);

            if (_exclude)
            {
                docValues.set(0, bitCount);
            }

            var docs         = new int[1];
            var freqs        = new int[1];
            var termTemplate = new Term(_fieldName);

            foreach (string special in _specials)
            {
                TermDocs termDocs = reader.termDocs(termTemplate.createTerm(special));
                int      count    = termDocs.read(docs, freqs);
                if (count == 1)
                {
                    if (_exclude)
                    {
                        docValues.fastClear(docs[0]);
                    }
                    else
                    {
                        docValues.fastSet(docs[0]);
                    }
                }
            }

            return(new SpecialsComparator(docValues));
        }
Ejemplo n.º 4
0
 public void Add(int point)
 {
     _points.fastSet(point);
     _cardinality++;
 }