Search in sources :

Example 1 with TerminateAfterWrapper

use of com.yelp.nrtsearch.server.luceneserver.search.TerminateAfterWrapper in project nrtsearch by Yelp.

the class DocCollectorTest method testWithAllWrappers.

@Test
public void testWithAllWrappers() {
    SearchRequest request = SearchRequest.newBuilder().setTopHits(10).setTerminateAfter(3).setTimeoutSec(5).setProfile(true).build();
    TestDocCollector docCollector = new TestDocCollector(request);
    assertTrue(docCollector.getManager() instanceof TestDocCollector.TestCollectorManager);
    assertTrue(docCollector.getWrappedManager() instanceof SearchStatsWrapper);
    SearchStatsWrapper<?> statsWrapper = (SearchStatsWrapper<?>) docCollector.getWrappedManager();
    assertTrue(statsWrapper.getWrapped() instanceof TerminateAfterWrapper);
    TerminateAfterWrapper<?> terminateAfterWrapper = (TerminateAfterWrapper<?>) statsWrapper.getWrapped();
    assertTrue(terminateAfterWrapper.getWrapped() instanceof SearchCutoffWrapper);
}
Also used : SearchRequest(com.yelp.nrtsearch.server.grpc.SearchRequest) TerminateAfterWrapper(com.yelp.nrtsearch.server.luceneserver.search.TerminateAfterWrapper) SearchCutoffWrapper(com.yelp.nrtsearch.server.luceneserver.search.SearchCutoffWrapper) SearchStatsWrapper(com.yelp.nrtsearch.server.luceneserver.search.SearchStatsWrapper) Test(org.junit.Test)

Example 2 with TerminateAfterWrapper

use of com.yelp.nrtsearch.server.luceneserver.search.TerminateAfterWrapper in project nrtsearch by Yelp.

the class DocCollectorTest method testHasTerminateAfterWrapper.

@Test
public void testHasTerminateAfterWrapper() {
    SearchRequest request = SearchRequest.newBuilder().setTopHits(10).setTerminateAfter(5).build();
    TestDocCollector docCollector = new TestDocCollector(request);
    assertTrue(docCollector.getManager() instanceof TestDocCollector.TestCollectorManager);
    assertTrue(docCollector.getWrappedManager() instanceof TerminateAfterWrapper);
    assertEquals(5, ((TerminateAfterWrapper<?>) docCollector.getWrappedManager()).getTerminateAfter());
}
Also used : SearchRequest(com.yelp.nrtsearch.server.grpc.SearchRequest) TerminateAfterWrapper(com.yelp.nrtsearch.server.luceneserver.search.TerminateAfterWrapper) Test(org.junit.Test)

Example 3 with TerminateAfterWrapper

use of com.yelp.nrtsearch.server.luceneserver.search.TerminateAfterWrapper in project nrtsearch by Yelp.

the class DocCollectorTest method testOverrideDefaultTerminateAfter.

@Test
public void testOverrideDefaultTerminateAfter() {
    IndexState indexState = Mockito.mock(IndexState.class);
    when(indexState.getDefaultTerminateAfter()).thenReturn(100);
    SearchRequest request = SearchRequest.newBuilder().setTopHits(10).setTerminateAfter(75).build();
    TestDocCollector docCollector = new TestDocCollector(request, indexState);
    assertTrue(docCollector.getManager() instanceof TestDocCollector.TestCollectorManager);
    assertTrue(docCollector.getWrappedManager() instanceof TerminateAfterWrapper);
    assertEquals(75, ((TerminateAfterWrapper<?>) docCollector.getWrappedManager()).getTerminateAfter());
}
Also used : SearchRequest(com.yelp.nrtsearch.server.grpc.SearchRequest) TerminateAfterWrapper(com.yelp.nrtsearch.server.luceneserver.search.TerminateAfterWrapper) IndexState(com.yelp.nrtsearch.server.luceneserver.IndexState) Test(org.junit.Test)

Example 4 with TerminateAfterWrapper

use of com.yelp.nrtsearch.server.luceneserver.search.TerminateAfterWrapper in project nrtsearch by Yelp.

the class DocCollectorTest method testUsesDefaultTerminateAfter.

@Test
public void testUsesDefaultTerminateAfter() {
    IndexState indexState = Mockito.mock(IndexState.class);
    when(indexState.getDefaultTerminateAfter()).thenReturn(100);
    SearchRequest request = SearchRequest.newBuilder().setTopHits(10).build();
    TestDocCollector docCollector = new TestDocCollector(request, indexState);
    assertTrue(docCollector.getManager() instanceof TestDocCollector.TestCollectorManager);
    assertTrue(docCollector.getWrappedManager() instanceof TerminateAfterWrapper);
    assertEquals(100, ((TerminateAfterWrapper<?>) docCollector.getWrappedManager()).getTerminateAfter());
}
Also used : SearchRequest(com.yelp.nrtsearch.server.grpc.SearchRequest) TerminateAfterWrapper(com.yelp.nrtsearch.server.luceneserver.search.TerminateAfterWrapper) IndexState(com.yelp.nrtsearch.server.luceneserver.IndexState) Test(org.junit.Test)

Aggregations

SearchRequest (com.yelp.nrtsearch.server.grpc.SearchRequest)4 TerminateAfterWrapper (com.yelp.nrtsearch.server.luceneserver.search.TerminateAfterWrapper)4 Test (org.junit.Test)4 IndexState (com.yelp.nrtsearch.server.luceneserver.IndexState)2 SearchCutoffWrapper (com.yelp.nrtsearch.server.luceneserver.search.SearchCutoffWrapper)1 SearchStatsWrapper (com.yelp.nrtsearch.server.luceneserver.search.SearchStatsWrapper)1