Пример #1
0
        public override Scorer Scorer(AtomicReaderContext context, Bits acceptDocs)
        {
            // if the caller asks for in-order scoring or if the weight does not support
            // out-of order scoring then collection will have to happen in-order.
            Scorer inScorer = @in.Scorer(context, acceptDocs);

            return(AssertingScorer.Wrap(new Random(Random.Next()), inScorer));
        }
Пример #2
0
        public static Scorer Wrap(Random random, Scorer other)
        {
            if (other == null || other is AssertingScorer)
            {
                return(other);
            }
            AssertingScorer assertScorer = new AssertingScorer(random, other);

            ASSERTING_INSTANCES[other] = new WeakReference(assertScorer);
            return(assertScorer);
        }
Пример #3
0
        public static Scorer Wrap(Random random, Scorer other)
        {
            if (other == null || other is AssertingScorer)
            {
                return(other);
            }
            AssertingScorer assertScorer = new AssertingScorer(random, other);

#if FEATURE_CONDITIONALWEAKTABLE_ADDORUPDATE
            ASSERTING_INSTANCES.AddOrUpdate(other, new WeakReference <AssertingScorer>(assertScorer));
#else
            ASSERTING_INSTANCES[other] = new WeakReference <AssertingScorer>(assertScorer);
#endif

            return(assertScorer);
        }
Пример #4
0
        internal static Scorer GetAssertingScorer(Random random, Scorer other)
        {
            if (other == null || other is AssertingScorer)
            {
                return(other);
            }
            WeakReference   assertingScorerRef = ASSERTING_INSTANCES[other];
            AssertingScorer assertingScorer    = assertingScorerRef == null ? null : (AssertingScorer)assertingScorerRef.Target;

            if (assertingScorer == null)
            {
                // can happen in case of memory pressure or if
                // scorer1.Score(collector) calls
                // collector.setScorer(scorer2) with scorer1 != scorer2, such as
                // BooleanScorer. In that case we can't enable all assertions
                return(new AssertingScorer(random, other));
            }
            else
            {
                return(assertingScorer);
            }
        }
Пример #5
0
        public static Scorer Wrap(Random random, Scorer other)
        {
            if (other is null || other is AssertingScorer)
            {
                return(other);
            }
            AssertingScorer assertScorer = new AssertingScorer(random, other);

#if !FEATURE_CONDITIONALWEAKTABLE_ADDORUPDATE
            UninterruptableMonitor.Enter(assertingInstancesLock);
            try
            {
#endif
            assertingInstances.AddOrUpdate(other, new WeakReference <AssertingScorer>(assertScorer));
#if !FEATURE_CONDITIONALWEAKTABLE_ADDORUPDATE
        }
        finally
        {
            UninterruptableMonitor.Exit(assertingInstancesLock);
        }
#endif

            return(assertScorer);
        }
Пример #6
0
 public virtual void SetScorer(Scorer scorer)
 => @in.SetScorer(AssertingScorer.GetAssertingScorer(random, scorer));
Пример #7
0
 public static Scorer Wrap(Random random, Scorer other)
 {
     if (other == null || other is AssertingScorer)
     {
         return other;
     }
     AssertingScorer assertScorer = new AssertingScorer(random, other);
     ASSERTING_INSTANCES[other] = new WeakReference(assertScorer);
     return assertScorer;
 }