コード例 #1
0
        internal void  Add(Scorer scorer, bool required, bool prohibited)
        {
            int mask = 0;

            if (required || prohibited)
            {
                if (nextMask == 0)
                {
                    throw new System.IndexOutOfRangeException("More than 32 required/prohibited clauses in query.");
                }
                mask     = nextMask;
                nextMask = nextMask << 1;
            }
            else
            {
                mask = 0;
            }

            if (!prohibited)
            {
                maxCoord++;
            }

            if (prohibited)
            {
                prohibitedMask |= mask;
            }
            // update prohibited mask
            else if (required)
            {
                requiredMask |= mask;                 // update required mask
            }
            scorers = new SubScorer(scorer, required, prohibited, bucketTable.NewCollector(mask), scorers);
        }
コード例 #2
0
ファイル: BooleanScorer.cs プロジェクト: stgwilli/ravendb
 public SubScorer(Scorer scorer, bool required, bool prohibited, Collector collector, SubScorer next)
 {
     this.scorer     = scorer;
     this.required   = required;
     this.prohibited = prohibited;
     this.collector  = collector;
     this.next       = next;
 }
コード例 #3
0
ファイル: BooleanScorer.cs プロジェクト: zweib730/beagrep
			public SubScorer(Scorer scorer, bool required, bool prohibited, HitCollector collector, SubScorer next)
			{
				this.scorer = scorer;
				this.done = !scorer.Next();
				this.required = required;
				this.prohibited = prohibited;
				this.collector = collector;
				this.next = next;
			}
コード例 #4
0
ファイル: BooleanScorer.cs プロジェクト: stgwilli/ravendb
 public override System.String ToString()
 {
     System.Text.StringBuilder buffer = new System.Text.StringBuilder();
     buffer.Append("boolean(");
     for (SubScorer sub = scorers; sub != null; sub = sub.next)
     {
         buffer.Append(sub.scorer.ToString());
         buffer.Append(" ");
     }
     buffer.Append(")");
     return(buffer.ToString());
 }
コード例 #5
0
ファイル: BooleanScorer.cs プロジェクト: kushanp/lucene.net
        public override string ToString()
        {
            StringBuilder buffer = new StringBuilder();

            buffer.Append("boolean(");
            for (SubScorer sub = Scorers; sub != null; sub = sub.Next)
            {
                buffer.Append(sub.Scorer.ToString());
                buffer.Append(" ");
            }
            buffer.Append(")");
            return(buffer.ToString());
        }
コード例 #6
0
ファイル: BooleanScorer.cs プロジェクト: kushanp/lucene.net
 public SubScorer(BulkScorer scorer, bool required, bool prohibited, Collector collector, SubScorer next)
 {
     if (required)
     {
         throw new System.ArgumentException("this scorer cannot handle required=true");
     }
     this.Scorer = scorer;
     this.More   = true;
     // TODO: re-enable this if BQ ever sends us required clauses
     //this.required = required;
     this.Prohibited = prohibited;
     this.Collector  = collector;
     this.Next       = next;
 }
コード例 #7
0
ファイル: BooleanScorer.cs プロジェクト: stgwilli/ravendb
        public /*internal*/ BooleanScorer(Similarity similarity, int minNrShouldMatch, System.Collections.IList optionalScorers, System.Collections.IList prohibitedScorers) : base(similarity)
        {
            InitBlock();
            this.minNrShouldMatch = minNrShouldMatch;

            if (optionalScorers != null && optionalScorers.Count > 0)
            {
                for (System.Collections.IEnumerator si = optionalScorers.GetEnumerator(); si.MoveNext();)
                {
                    Scorer scorer = (Scorer)si.Current;
                    maxCoord++;
                    if (scorer.NextDoc() != NO_MORE_DOCS)
                    {
                        scorers = new SubScorer(scorer, false, false, bucketTable.NewCollector(0), scorers);
                    }
                }
            }

            if (prohibitedScorers != null && prohibitedScorers.Count > 0)
            {
                for (System.Collections.IEnumerator si = prohibitedScorers.GetEnumerator(); si.MoveNext();)
                {
                    Scorer scorer = (Scorer)si.Current;
                    int    mask   = nextMask;
                    nextMask        = nextMask << 1;
                    prohibitedMask |= mask;                     // update prohibited mask
                    if (scorer.NextDoc() != NO_MORE_DOCS)
                    {
                        scorers = new SubScorer(scorer, false, true, bucketTable.NewCollector(mask), scorers);
                    }
                }
            }

            coordFactors = new float[maxCoord];
            Similarity sim = GetSimilarity();

            for (int i = 0; i < maxCoord; i++)
            {
                coordFactors[i] = sim.Coord(i, maxCoord - 1);
            }
        }
コード例 #8
0
        public /*internal*/ BooleanScorer(Similarity similarity, int minNrShouldMatch,
                                          System.Collections.Generic.List <Scorer> optionalScorers, System.Collections.Generic.List <Scorer> prohibitedScorers)
            : base(similarity)
        {
            InitBlock();
            this.minNrShouldMatch = minNrShouldMatch;

            if (optionalScorers != null && optionalScorers.Count > 0)
            {
                foreach (Scorer scorer in optionalScorers)
                {
                    maxCoord++;
                    if (scorer.NextDoc() != NO_MORE_DOCS)
                    {
                        scorers = new SubScorer(scorer, false, false, bucketTable.NewCollector(0), scorers);
                    }
                }
            }

            if (prohibitedScorers != null && prohibitedScorers.Count > 0)
            {
                foreach (Scorer scorer in prohibitedScorers)
                {
                    int mask = nextMask;
                    nextMask        = nextMask << 1;
                    prohibitedMask |= mask;                     // update prohibited mask
                    if (scorer.NextDoc() != NO_MORE_DOCS)
                    {
                        scorers = new SubScorer(scorer, false, true, bucketTable.NewCollector(mask), scorers);
                    }
                }
            }

            coordFactors = new float[maxCoord];
            Similarity sim = Similarity;

            for (int i = 0; i < maxCoord; i++)
            {
                coordFactors[i] = sim.Coord(i, maxCoord - 1);
            }
        }
コード例 #9
0
        //private readonly Weight weight; // LUCENENET: Never read

        internal BooleanScorer(BooleanWeight weight, bool disableCoord, int minNrShouldMatch, IList <BulkScorer> optionalScorers, IList <BulkScorer> prohibitedScorers, int maxCoord)
        {
            this.minNrShouldMatch = minNrShouldMatch;
            //this.weight = weight; // LUCENENET: Never read

            foreach (BulkScorer scorer in optionalScorers)
            {
                scorers = new SubScorer(scorer, false, false, bucketTable.NewCollector(0), scorers);
            }

            foreach (BulkScorer scorer in prohibitedScorers)
            {
                scorers = new SubScorer(scorer, false, true, bucketTable.NewCollector(PROHIBITED_MASK), scorers);
            }

            coordFactors = new float[optionalScorers.Count + 1];
            for (int i = 0; i < coordFactors.Length; i++)
            {
                coordFactors[i] = disableCoord ? 1.0f : weight.Coord(i, maxCoord);
            }
        }
コード例 #10
0
ファイル: BooleanScorer.cs プロジェクト: kushanp/lucene.net
        public BooleanScorer(BooleanWeight weight, bool disableCoord, int minNrShouldMatch, IList <BulkScorer> optionalScorers, IList <BulkScorer> prohibitedScorers, int maxCoord)
        {
            this.MinNrShouldMatch = minNrShouldMatch;
            this.Weight           = weight;

            foreach (BulkScorer scorer in optionalScorers)
            {
                Scorers = new SubScorer(scorer, false, false, bucketTable.NewCollector(0), Scorers);
            }

            foreach (BulkScorer scorer in prohibitedScorers)
            {
                Scorers = new SubScorer(scorer, false, true, bucketTable.NewCollector(PROHIBITED_MASK), Scorers);
            }

            CoordFactors = new float[optionalScorers.Count + 1];
            for (int i = 0; i < CoordFactors.Length; i++)
            {
                CoordFactors[i] = disableCoord ? 1.0f : weight.Coord(i, maxCoord);
            }
        }
コード例 #11
0
        public override bool Next()
        {
            bool more;

            do
            {
                while (bucketTable.first != null)
                {
                    // more queued
                    current           = bucketTable.first;
                    bucketTable.first = current.next;                     // pop the queue

                    // check prohibited & required
                    if ((current.bits & prohibitedMask) == 0 && (current.bits & requiredMask) == requiredMask)
                    {
                        return(true);
                    }
                }

                // refill the queue
                more = false;
                end += BucketTable.SIZE;
                for (SubScorer sub = scorers; sub != null; sub = sub.next)
                {
                    Scorer scorer = sub.scorer;
                    while (!sub.done && scorer.Doc() < end)
                    {
                        sub.collector.Collect(scorer.Doc(), scorer.Score());
                        sub.done = !scorer.Next();
                    }
                    if (!sub.done)
                    {
                        more = true;
                    }
                }
            }while (bucketTable.first != null || more);

            return(false);
        }
コード例 #12
0
ファイル: BooleanScorer.cs プロジェクト: stgwilli/ravendb
        public override int NextDoc()
        {
            bool more;

            do
            {
                while (bucketTable.first != null)
                {
                    // more queued
                    current           = bucketTable.first;
                    bucketTable.first = current.next;                     // pop the queue

                    // check prohibited & required, and minNrShouldMatch
                    if ((current.bits & prohibitedMask) == 0 && (current.bits & requiredMask) == requiredMask && current.coord >= minNrShouldMatch)
                    {
                        return(doc = current.doc);
                    }
                }

                // refill the queue
                more = false;
                end += BucketTable.SIZE;
                for (SubScorer sub = scorers; sub != null; sub = sub.next)
                {
                    Scorer scorer = sub.scorer;
                    sub.collector.SetScorer(scorer);
                    int doc = scorer.DocID();
                    while (doc < end)
                    {
                        sub.collector.Collect(doc);
                        doc = scorer.NextDoc();
                    }
                    more |= (doc != NO_MORE_DOCS);
                }
            }while (bucketTable.first != null || more);

            return(this.doc = NO_MORE_DOCS);
        }
コード例 #13
0
ファイル: BooleanScorer.cs プロジェクト: zweib730/beagrep
		internal void  Add(Scorer scorer, bool required, bool prohibited)
		{
			int mask = 0;
			if (required || prohibited)
			{
				if (nextMask == 0)
					throw new System.IndexOutOfRangeException("More than 32 required/prohibited clauses in query.");
				mask = nextMask;
				nextMask = nextMask << 1;
			}
			else
				mask = 0;
			
			if (!prohibited)
				maxCoord++;
			
			if (prohibited)
				prohibitedMask |= mask;
			// update prohibited mask
			else if (required)
				requiredMask |= mask; // update required mask
			
			scorers = new SubScorer(scorer, required, prohibited, bucketTable.NewCollector(mask), scorers);
		}
コード例 #14
0
ファイル: BooleanScorer.cs プロジェクト: Cefa68000/lucenenet
 public SubScorer(BulkScorer scorer, bool required, bool prohibited, Collector collector, SubScorer next)
 {
     if (required)
     {
         throw new System.ArgumentException("this scorer cannot handle required=true");
     }
     this.Scorer = scorer;
     this.More = true;
     // TODO: re-enable this if BQ ever sends us required clauses
     //this.required = required;
     this.Prohibited = prohibited;
     this.Collector = collector;
     this.Next = next;
 }
コード例 #15
0
ファイル: BooleanScorer.cs プロジェクト: stgwilli/ravendb
        // firstDocID is ignored since nextDoc() initializes 'current'
        public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
        {
            bool         more;
            Bucket       tmp;
            BucketScorer bs = new BucketScorer();

            // The internal loop will set the score and doc before calling collect.
            collector.SetScorer(bs);
            do
            {
                bucketTable.first = null;

                while (current != null)
                {
                    // more queued

                    // check prohibited & required
                    if ((current.bits & prohibitedMask) == 0 && (current.bits & requiredMask) == requiredMask)
                    {
                        if (current.doc >= max)
                        {
                            tmp               = current;
                            current           = current.next;
                            tmp.next          = bucketTable.first;
                            bucketTable.first = tmp;
                            continue;
                        }

                        if (current.coord >= minNrShouldMatch)
                        {
                            bs.score = current.score * coordFactors[current.coord];
                            bs.doc   = current.doc;
                            collector.Collect(current.doc);
                        }
                    }

                    current = current.next;                     // pop the queue
                }

                if (bucketTable.first != null)
                {
                    current           = bucketTable.first;
                    bucketTable.first = current.next;
                    return(true);
                }

                // refill the queue
                more = false;
                end += BucketTable.SIZE;
                for (SubScorer sub = scorers; sub != null; sub = sub.next)
                {
                    int subScorerDocID = sub.scorer.DocID();
                    if (subScorerDocID != NO_MORE_DOCS)
                    {
                        more |= sub.scorer.Score(sub.collector, end, subScorerDocID);
                    }
                }
                current = bucketTable.first;
            }while (current != null || more);

            return(false);
        }
コード例 #16
0
ファイル: BooleanScorer.cs プロジェクト: carrie901/mono
		public /*internal*/ BooleanScorer(Similarity similarity, int minNrShouldMatch, System.Collections.IList optionalScorers, System.Collections.IList prohibitedScorers):base(similarity)
		{
			InitBlock();
			this.minNrShouldMatch = minNrShouldMatch;
			
			if (optionalScorers != null && optionalScorers.Count > 0)
			{
				for (System.Collections.IEnumerator si = optionalScorers.GetEnumerator(); si.MoveNext(); )
				{
					Scorer scorer = (Scorer) si.Current;
					maxCoord++;
					if (scorer.NextDoc() != NO_MORE_DOCS)
					{
						scorers = new SubScorer(scorer, false, false, bucketTable.NewCollector(0), scorers);
					}
				}
			}
			
			if (prohibitedScorers != null && prohibitedScorers.Count > 0)
			{
				for (System.Collections.IEnumerator si = prohibitedScorers.GetEnumerator(); si.MoveNext(); )
				{
					Scorer scorer = (Scorer) si.Current;
					int mask = nextMask;
					nextMask = nextMask << 1;
					prohibitedMask |= mask; // update prohibited mask
					if (scorer.NextDoc() != NO_MORE_DOCS)
					{
						scorers = new SubScorer(scorer, false, true, bucketTable.NewCollector(mask), scorers);
					}
				}
			}
			
			coordFactors = new float[maxCoord];
			Similarity sim = GetSimilarity();
			for (int i = 0; i < maxCoord; i++)
			{
				coordFactors[i] = sim.Coord(i, maxCoord - 1);
			}
		}
コード例 #17
0
        protected internal override bool Score(HitCollector hc, int max)
        {
            if (coordFactors == null)
            {
                ComputeCoordFactors();
            }

            bool   more;
            Bucket tmp;

            do
            {
                bucketTable.first = null;

                while (current != null)
                {
                    // more queued

                    // check prohibited & required
                    if ((current.bits & prohibitedMask) == 0 && (current.bits & requiredMask) == requiredMask)
                    {
                        if (current.doc >= max)
                        {
                            tmp               = current;
                            current           = current.next;
                            tmp.next          = bucketTable.first;
                            bucketTable.first = tmp;
                            continue;
                        }

                        hc.Collect(current.doc, current.score * coordFactors[current.coord]);
                    }

                    current = current.next;                     // pop the queue
                }

                if (bucketTable.first != null)
                {
                    current           = bucketTable.first;
                    bucketTable.first = current.next;
                    return(true);
                }

                // refill the queue
                more = false;
                end += BucketTable.SIZE;
                for (SubScorer sub = scorers; sub != null; sub = sub.next)
                {
                    if (!sub.done)
                    {
                        sub.done = !sub.scorer.Score(sub.collector, end);
                        if (!sub.done)
                        {
                            more = true;
                        }
                    }
                }
                current = bucketTable.first;
            }while (current != null || more);

            return(false);
        }
コード例 #18
0
ファイル: BooleanScorer.cs プロジェクト: Cefa68000/lucenenet
        public BooleanScorer(BooleanWeight weight, bool disableCoord, int minNrShouldMatch, IList<BulkScorer> optionalScorers, IList<BulkScorer> prohibitedScorers, int maxCoord)
        {
            this.MinNrShouldMatch = minNrShouldMatch;
            this.Weight = weight;

            foreach (BulkScorer scorer in optionalScorers)
            {
                Scorers = new SubScorer(scorer, false, false, bucketTable.NewCollector(0), Scorers);
            }

            foreach (BulkScorer scorer in prohibitedScorers)
            {
                Scorers = new SubScorer(scorer, false, true, bucketTable.NewCollector(PROHIBITED_MASK), Scorers);
            }

            CoordFactors = new float[optionalScorers.Count + 1];
            for (int i = 0; i < CoordFactors.Length; i++)
            {
                CoordFactors[i] = disableCoord ? 1.0f : weight.Coord(i, maxCoord);
            }
        }
コード例 #19
0
ファイル: BooleanScorer.cs プロジェクト: kushanp/lucene.net
        public override bool Score(Collector collector, int max)
        {
            bool       more;
            Bucket     tmp;
            FakeScorer fs = new FakeScorer();

            // The internal loop will set the score and doc before calling collect.
            collector.Scorer = fs;
            do
            {
                bucketTable.First = null;

                while (Current != null) // more queued
                {
                    // check prohibited & required
                    if ((Current.Bits & PROHIBITED_MASK) == 0)
                    {
                        // TODO: re-enable this if BQ ever sends us required
                        // clauses
                        //&& (current.bits & requiredMask) == requiredMask) {
                        // NOTE: Lucene always passes max =
                        // Integer.MAX_VALUE today, because we never embed
                        // a BooleanScorer inside another (even though
                        // that should work)... but in theory an outside
                        // app could pass a different max so we must check
                        // it:
                        if (Current.Doc >= max)
                        {
                            tmp               = Current;
                            Current           = Current.Next;
                            tmp.Next          = bucketTable.First;
                            bucketTable.First = tmp;
                            continue;
                        }

                        if (Current.Coord >= MinNrShouldMatch)
                        {
                            fs.score = (float)(Current.Score * CoordFactors[Current.Coord]);
                            fs.doc   = Current.Doc;
                            fs.freq  = Current.Coord;
                            collector.Collect(Current.Doc);
                        }
                    }

                    Current = Current.Next; // pop the queue
                }

                if (bucketTable.First != null)
                {
                    Current           = bucketTable.First;
                    bucketTable.First = Current.Next;
                    return(true);
                }

                // refill the queue
                more = false;
                End += BucketTable.SIZE;
                for (SubScorer sub = Scorers; sub != null; sub = sub.Next)
                {
                    if (sub.More)
                    {
                        sub.More = sub.Scorer.Score(sub.Collector, End);
                        more    |= sub.More;
                    }
                }
                Current = bucketTable.First;
            } while (Current != null || more);

            return(false);
        }
コード例 #20
0
		public /*internal*/ BooleanScorer(Similarity similarity, int minNrShouldMatch,
            System.Collections.Generic.List<Scorer> optionalScorers, System.Collections.Generic.List<Scorer> prohibitedScorers)
            : base(similarity)
		{
			InitBlock();
			this.minNrShouldMatch = minNrShouldMatch;
			
			if (optionalScorers != null && optionalScorers.Count > 0)
			{
				foreach (Scorer scorer in optionalScorers)
				{
					maxCoord++;
					if (scorer.NextDoc() != NO_MORE_DOCS)
					{
						scorers = new SubScorer(scorer, false, false, bucketTable.NewCollector(0), scorers);
					}
				}
			}
			
			if (prohibitedScorers != null && prohibitedScorers.Count > 0)
			{
				foreach(Scorer scorer in prohibitedScorers)
				{
					int mask = nextMask;
					nextMask = nextMask << 1;
					prohibitedMask |= mask; // update prohibited mask
					if (scorer.NextDoc() != NO_MORE_DOCS)
					{
						scorers = new SubScorer(scorer, false, true, bucketTable.NewCollector(mask), scorers);
					}
				}
			}
			
			coordFactors = new float[maxCoord];
			Similarity sim = Similarity;
			for (int i = 0; i < maxCoord; i++)
			{
				coordFactors[i] = sim.Coord(i, maxCoord - 1);
			}
		}