Search in sources :

Example 1 with SearchCutoffWrapper

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

the class DocCollectorTest method testQueryOverridesDefaultTimeout.

@Test
public void testQueryOverridesDefaultTimeout() {
    IndexState indexState = Mockito.mock(IndexState.class);
    when(indexState.getDefaultSearchTimeoutSec()).thenReturn(3.0);
    when(indexState.getDefaultSearchTimeoutCheckEvery()).thenReturn(0);
    SearchRequest request = SearchRequest.newBuilder().setTopHits(10).setTimeoutSec(2.0).build();
    TestDocCollector docCollector = new TestDocCollector(request, indexState);
    assertTrue(docCollector.getManager() instanceof TestDocCollector.TestCollectorManager);
    assertTrue(docCollector.getWrappedManager() instanceof SearchCutoffWrapper);
    SearchCutoffWrapper<?> cutoffWrapper = (SearchCutoffWrapper<?>) docCollector.getWrappedManager();
    assertEquals(2.0, cutoffWrapper.getTimeoutSec(), 0.0);
    assertEquals(0, cutoffWrapper.getCheckEvery());
}
Also used : SearchRequest(com.yelp.nrtsearch.server.grpc.SearchRequest) SearchCutoffWrapper(com.yelp.nrtsearch.server.luceneserver.search.SearchCutoffWrapper) IndexState(com.yelp.nrtsearch.server.luceneserver.IndexState) Test(org.junit.Test)

Example 2 with SearchCutoffWrapper

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

the class DocCollectorTest method testHasStatsAndTimeoutWrapper.

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

Example 3 with SearchCutoffWrapper

use of com.yelp.nrtsearch.server.luceneserver.search.SearchCutoffWrapper 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 4 with SearchCutoffWrapper

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

the class DocCollectorTest method testUsesDefaultTimeoutCheckEvery.

@Test
public void testUsesDefaultTimeoutCheckEvery() {
    IndexState indexState = Mockito.mock(IndexState.class);
    when(indexState.getDefaultSearchTimeoutSec()).thenReturn(6.0);
    when(indexState.getDefaultSearchTimeoutCheckEvery()).thenReturn(10);
    SearchRequest request = SearchRequest.newBuilder().setTopHits(10).build();
    TestDocCollector docCollector = new TestDocCollector(request, indexState);
    assertTrue(docCollector.getManager() instanceof TestDocCollector.TestCollectorManager);
    assertTrue(docCollector.getWrappedManager() instanceof SearchCutoffWrapper);
    SearchCutoffWrapper<?> cutoffWrapper = (SearchCutoffWrapper<?>) docCollector.getWrappedManager();
    assertEquals(6.0, cutoffWrapper.getTimeoutSec(), 0.0);
    assertEquals(10, cutoffWrapper.getCheckEvery());
}
Also used : SearchRequest(com.yelp.nrtsearch.server.grpc.SearchRequest) SearchCutoffWrapper(com.yelp.nrtsearch.server.luceneserver.search.SearchCutoffWrapper) IndexState(com.yelp.nrtsearch.server.luceneserver.IndexState) Test(org.junit.Test)

Example 5 with SearchCutoffWrapper

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

the class DocCollectorTest method testHasTimeoutWrapper.

@Test
public void testHasTimeoutWrapper() {
    SearchRequest request = SearchRequest.newBuilder().setTopHits(10).setTimeoutSec(5).build();
    TestDocCollector docCollector = new TestDocCollector(request);
    assertTrue(docCollector.getManager() instanceof TestDocCollector.TestCollectorManager);
    assertTrue(docCollector.getWrappedManager() instanceof SearchCutoffWrapper);
}
Also used : SearchRequest(com.yelp.nrtsearch.server.grpc.SearchRequest) SearchCutoffWrapper(com.yelp.nrtsearch.server.luceneserver.search.SearchCutoffWrapper) Test(org.junit.Test)

Aggregations

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