public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs)
            {
                SortedSetDocValues docTermOrds = FieldCache.DEFAULT.GetDocTermOrds(context.AtomicReader, field);
                long lowerPoint = lowerVal == null ? -1 : docTermOrds.LookupTerm(lowerVal);
                long upperPoint = upperVal == null ? -1 : docTermOrds.LookupTerm(upperVal);

                long inclusiveLowerPoint, inclusiveUpperPoint;

                // Hints:
                // * binarySearchLookup returns -1, if value was null.
                // * the value is <0 if no exact hit was found, the returned value
                //   is (-(insertion point) - 1)
                if (lowerPoint == -1 && lowerVal == null)
                {
                    inclusiveLowerPoint = 0;
                }
                else if (includeLower && lowerPoint >= 0)
                {
                    inclusiveLowerPoint = lowerPoint;
                }
                else if (lowerPoint >= 0)
                {
                    inclusiveLowerPoint = lowerPoint + 1;
                }
                else
                {
                    inclusiveLowerPoint = Math.Max(0, -lowerPoint - 1);
                }

                if (upperPoint == -1 && upperVal == null)
                {
                    inclusiveUpperPoint = long.MaxValue;
                }
                else if (includeUpper && upperPoint >= 0)
                {
                    inclusiveUpperPoint = upperPoint;
                }
                else if (upperPoint >= 0)
                {
                    inclusiveUpperPoint = upperPoint - 1;
                }
                else
                {
                    inclusiveUpperPoint = -upperPoint - 2;
                }

                if (inclusiveUpperPoint < 0 || inclusiveLowerPoint > inclusiveUpperPoint)
                {
                    return(null);
                }

                if (Debugging.AssertsEnabled)
                {
                    Debugging.Assert(inclusiveLowerPoint >= 0 && inclusiveUpperPoint >= 0);
                }

                return(new FieldCacheDocIdSetAnonymousInnerClassHelper(this, context.AtomicReader.MaxDoc, acceptDocs, docTermOrds, inclusiveLowerPoint, inclusiveUpperPoint));
            }
Пример #2
0
            internal SlowMinShouldMatchScorer(BooleanWeight weight, AtomicReader reader, IndexSearcher searcher)
                : base(weight)
            {
                this.Dv     = reader.GetSortedSetDocValues("dv");
                this.MaxDoc = reader.MaxDoc;
                BooleanQuery bq = (BooleanQuery)weight.Query;

                this.MinNrShouldMatch = bq.MinimumNumberShouldMatch;
                this.Sims             = new SimScorer[(int)Dv.ValueCount];
                foreach (BooleanClause clause in bq.Clauses)
                {
                    Debug.Assert(!clause.Prohibited);
                    Debug.Assert(!clause.Required);
                    Term term = ((TermQuery)clause.Query).Term;
                    long ord  = Dv.LookupTerm(term.Bytes);
                    if (ord >= 0)
                    {
                        bool success = Ords.Add(ord);
                        Debug.Assert(success); // no dups
                        TermContext context = TermContext.Build(reader.Context, term);
                        SimWeight   w       = weight.Similarity.ComputeWeight(1f, searcher.CollectionStatistics("field"), searcher.TermStatistics(term, context));
                        var         dummy   = w.ValueForNormalization; // ignored
                        w.Normalize(1F, 1F);
                        Sims[(int)ord] = weight.Similarity.DoSimScorer(w, (AtomicReaderContext)reader.Context);
                    }
                }
            }
Пример #3
0
        public override float GetSpecificValue(string dim, params string[] path)
        {
            if (path.Length != 1)
            {
                throw new ArgumentException("path must be length=1");
            }
            int ord = (int)dv.LookupTerm(new BytesRef(FacetsConfig.PathToString(dim, path)));

            if (ord < 0)
            {
                return(-1);
            }

            return(counts[ord]);
        }
Пример #4
0
 public override long LookupTerm(BytesRef key)
 {
     return(@in.LookupTerm(key));
 }
Пример #5
0
 public override int LookupTerm(BytesRef key)
 {
     return((int)@in.LookupTerm(key));
 }
Пример #6
0
            public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs)
            {
                SortedSetDocValues docTermOrds = FieldCache.DEFAULT.GetDocTermOrds(context.AtomicReader, field);
                long lowerPoint = lowerVal == null ? -1 : docTermOrds.LookupTerm(lowerVal);
                long upperPoint = upperVal == null ? -1 : docTermOrds.LookupTerm(upperVal);

                long inclusiveLowerPoint, inclusiveUpperPoint;

                // Hints:
                // * binarySearchLookup returns -1, if value was null.
                // * the value is <0 if no exact hit was found, the returned value
                //   is (-(insertion point) - 1)
                if (lowerPoint == -1 && lowerVal == null)
                {
                    inclusiveLowerPoint = 0;
                }
                else if (includeLower && lowerPoint >= 0)
                {
                    inclusiveLowerPoint = lowerPoint;
                }
                else if (lowerPoint >= 0)
                {
                    inclusiveLowerPoint = lowerPoint + 1;
                }
                else
                {
                    inclusiveLowerPoint = Math.Max(0, -lowerPoint - 1);
                }

                if (upperPoint == -1 && upperVal == null)
                {
                    inclusiveUpperPoint = long.MaxValue;
                }
                else if (includeUpper && upperPoint >= 0)
                {
                    inclusiveUpperPoint = upperPoint;
                }
                else if (upperPoint >= 0)
                {
                    inclusiveUpperPoint = upperPoint - 1;
                }
                else
                {
                    inclusiveUpperPoint = -upperPoint - 2;
                }

                if (inclusiveUpperPoint < 0 || inclusiveLowerPoint > inclusiveUpperPoint)
                {
                    return(null);
                }

                if (Debugging.AssertsEnabled)
                {
                    Debugging.Assert(inclusiveLowerPoint >= 0 && inclusiveUpperPoint >= 0);
                }

                return(new FieldCacheDocIdSet(context.AtomicReader.MaxDoc, acceptDocs, (doc) =>
                {
                    docTermOrds.SetDocument(doc);
                    long ord;
                    while ((ord = docTermOrds.NextOrd()) != SortedSetDocValues.NO_MORE_ORDS)
                    {
                        if (ord > inclusiveUpperPoint)
                        {
                            return false;
                        }
                        else if (ord >= inclusiveLowerPoint)
                        {
                            return true;
                        }
                    }
                    return false;
                }));
            }