Exemplo n.º 1
0
            /// <returns> true if it was able to make sure, that currentDisi is valid </returns>
            internal virtual bool EnsureValidDisi()
            {
                try
                {
                    while (CurrentIdIterator == null)
                    {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                        if (MatchingDocs.hasNext())
                        {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                            CurrentDocs       = MatchingDocs.next();
                            CurrentIdIterator = CurrentDocs.docIdSet.GetEnumerator();
                            if (CurrentIdIterator != null)
                            {
                                DocValuesCache.Clear();
                                CurrentDocValues = CurrentDocs.readDocValues(Field);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                catch (IOException e)
                {
                    throw new Exception(e);
                }
            }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCollectAllHitsPerSegment() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldCollectAllHitsPerSegment()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector();
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Collect(1);
            collector.Collect(3);
            collector.Collect(5);
            collector.Collect(9);

            // then
            assertEquals(4, collector.TotalHits);
            IList <DocValuesCollector.MatchingDocs> allMatchingDocs = collector.GetMatchingDocs();

            assertEquals(1, allMatchingDocs.Count);
            DocValuesCollector.MatchingDocs matchingDocs = allMatchingDocs[0];
            assertSame(readerStub.Context, matchingDocs.Context);
            assertEquals(4, matchingDocs.TotalHits);
            DocIdSetIterator idIterator = matchingDocs.DocIdSet.GetEnumerator();

            assertEquals(1, idIterator.nextDoc());
            assertEquals(3, idIterator.nextDoc());
            assertEquals(5, idIterator.nextDoc());
            assertEquals(9, idIterator.nextDoc());
            assertEquals(DocIdSetIterator.NO_MORE_DOCS, idIterator.nextDoc());
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotSaveScoresWhenNotRequired() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldNotSaveScoresWhenNotRequired()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(false);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Collect(1);

            // then
            DocValuesCollector.MatchingDocs matchingDocs = collector.GetMatchingDocs()[0];
            assertNull(matchingDocs.Scores);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSaveScoresWhenRequired() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldSaveScoresWhenRequired()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(true);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Scorer = ConstantScorer(13.42f);
            collector.Collect(1);

            // then
            DocValuesCollector.MatchingDocs matchingDocs = collector.GetMatchingDocs()[0];
            assertArrayEquals(new float[] { 13.42f }, matchingDocs.Scores, 0.001f);
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldDynamicallyResizeScoresArray() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldDynamicallyResizeScoresArray()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(true);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Scorer = ConstantScorer(1.0f);
            // scores starts with array size of 32, adding 42 docs forces resize
            for (int i = 0; i < 42; i++)
            {
                collector.Collect(i);
            }

            // then
            DocValuesCollector.MatchingDocs matchingDocs = collector.GetMatchingDocs()[0];
            float[] scores = new float[42];
            Arrays.fill(scores, 1.0f);
            assertArrayEquals(scores, matchingDocs.Scores, 0.001f);
        }