Ejemplo n.º 1
0
            public override void  Collect(int doc, IState state)
            {
                float score = sc.Score(null);

                lastDoc[0] = doc;
                try
                {
                    if (scorer == null)
                    {
                        Weight w = q.Weight(s, null);
                        scorer = w.Scorer(reader, true, false, null);
                    }
                    int op = order[(opidx[0]++) % order.Length];
                    // System.out.println(op==skip_op ?
                    // "skip("+(sdoc[0]+1)+")":"next()");
                    bool more = op == skip_op
                                                    ? scorer.Advance(scorer.DocID() + 1, null) != DocIdSetIterator.NO_MORE_DOCS
                                                    : scorer.NextDoc(null) != DocIdSetIterator.NO_MORE_DOCS;

                    int   scorerDoc    = scorer.DocID();
                    float scorerScore  = scorer.Score(null);
                    float scorerScore2 = scorer.Score(null);
                    float scoreDiff    = System.Math.Abs(score - scorerScore);
                    float scorerDiff   = System.Math.Abs(scorerScore2 - scorerScore);
                    if (!more || doc != scorerDoc || scoreDiff > maxDiff || scorerDiff > maxDiff)
                    {
                        System.Text.StringBuilder sbord = new System.Text.StringBuilder();
                        for (int i = 0; i < order.Length; i++)
                        {
                            sbord.Append(order[i] == skip_op?" skip()":" next()");
                        }
                        throw new System.SystemException("ERROR matching docs:" + "\n\t" + (doc != scorerDoc ? "--> " : "") + "scorerDoc=" +
                                                         scorerDoc + "\n\t" + (!more ? "--> " : "") + "tscorer.more=" + more + "\n\t" +
                                                         (scoreDiff > maxDiff ? "--> " : "") + "scorerScore=" + scorerScore +
                                                         " scoreDiff=" + scoreDiff + " maxDiff=" + maxDiff + "\n\t" +
                                                         (scorerDiff > maxDiff ? "--> " : "") + "scorerScore2=" + scorerScore2 +
                                                         " scorerDiff=" + scorerDiff + "\n\thitCollector.doc=" + doc + " score=" +
                                                         score + "\n\t Scorer=" + scorer + "\n\t Query=" + q + "  " +
                                                         q.GetType().FullName + "\n\t Searcher=" + s + "\n\t Order=" + sbord +
                                                         "\n\t Op=" + (op == skip_op ? " skip()" : " next()"));
                    }
                }
                catch (System.IO.IOException e)
                {
                    throw new System.SystemException("", e);
                }
            }
Ejemplo n.º 2
0
            public override void  Collect(int doc, IState state)
            {
                //System.out.println("doc="+doc);
                float score = this.scorer.Score(null);

                try
                {
                    for (int i = lastDoc[0] + 1; i <= doc; i++)
                    {
                        Weight w      = q.Weight(s, null);
                        Scorer scorer = w.Scorer(reader, true, false, null);
                        Assert.IsTrue(scorer.Advance(i, null) != DocIdSetIterator.NO_MORE_DOCS, "query collected " + doc + " but skipTo(" + i + ") says no more docs!");
                        Assert.AreEqual(doc, scorer.DocID(), "query collected " + doc + " but skipTo(" + i + ") got to " + scorer.DocID());
                        float skipToScore = scorer.Score(null);
                        Assert.AreEqual(skipToScore, scorer.Score(null), maxDiff, "unstable skipTo(" + i + ") score!");
                        Assert.AreEqual(score, skipToScore, maxDiff, "query assigned doc " + doc + " a score of <" + score + "> but skipTo(" + i + ") has <" + skipToScore + ">!");
                    }
                    lastDoc[0] = doc;
                }
                catch (System.IO.IOException e)
                {
                    throw new System.SystemException("", e);
                }
            }