Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldStartWithEmptyMatchingDocs()
        internal void ShouldStartWithEmptyMatchingDocs()
        {
            //given
            DocValuesCollector collector = new DocValuesCollector();

            // when
            // then
            assertEquals(emptyList(), collector.GetMatchingDocs());
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }