Search in sources :

Example 1 with ProfileResult

use of com.yelp.nrtsearch.server.grpc.ProfileResult in project nrtsearch by Yelp.

the class SearchStatsWrapperTest method testTerminateFlag.

@Test
public void testTerminateFlag() throws IOException {
    SearchStatsWrapper searchStatsWrapper = new SearchStatsWrapper(new MockTerminateCollectorManager());
    List<Collector> collectors = new ArrayList<>();
    for (int i = 0; i < 3; ++i) {
        Collector c = searchStatsWrapper.newCollector();
        collectors.add(c);
        try {
            c.getLeafCollector(null);
            assert false;
        } catch (CollectionTerminatedException ignored) {
        }
    }
    searchStatsWrapper.reduce(collectors);
    ProfileResult.Builder builder = ProfileResult.newBuilder();
    searchStatsWrapper.addProfiling(builder);
    ProfileResult result = builder.build();
    assertEquals(3, result.getSearchStats().getCollectorStatsCount());
    for (CollectorStats collectorStats : result.getSearchStats().getCollectorStatsList()) {
        assertTrue(collectorStats.getTerminated());
    }
}
Also used : ProfileResult(com.yelp.nrtsearch.server.grpc.ProfileResult) CollectionTerminatedException(org.apache.lucene.search.CollectionTerminatedException) CollectorStats(com.yelp.nrtsearch.server.grpc.ProfileResult.CollectorStats) LeafCollector(org.apache.lucene.search.LeafCollector) Collector(org.apache.lucene.search.Collector) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ProfileResult (com.yelp.nrtsearch.server.grpc.ProfileResult)1 CollectorStats (com.yelp.nrtsearch.server.grpc.ProfileResult.CollectorStats)1 ArrayList (java.util.ArrayList)1 CollectionTerminatedException (org.apache.lucene.search.CollectionTerminatedException)1 Collector (org.apache.lucene.search.Collector)1 LeafCollector (org.apache.lucene.search.LeafCollector)1 Test (org.junit.Test)1