Search in sources :

Example 1 with CollectorStats

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

the class CollectorStatsWrapperTest method testHasAdditionalCollectorStats.

@Test
public void testHasAdditionalCollectorStats() {
    SearchResponse searchResponse = getGrpcServer().getBlockingStub().search(SearchRequest.newBuilder().setIndexName(TEST_INDEX).setStartHit(0).setTopHits(5).addRetrieveFields("doc_id").addRetrieveFields("int_score").addRetrieveFields("int_field").setQuery(Query.newBuilder()).putCollectors("test_collector1", Collector.newBuilder().setTerms(TermsCollector.newBuilder().setSize(10).setScript(Script.newBuilder().setLang("test_lang").setSource("test_script").build()).build()).build()).putCollectors("test_collector2", Collector.newBuilder().setTerms(TermsCollector.newBuilder().setSize(10).setScript(Script.newBuilder().setLang("test_lang").setSource("test_script").build()).build()).build()).setProfile(true).build());
    assertTrue(searchResponse.getProfileResult().getSearchStats().getCollectorStatsCount() > 1);
    assertTrue(searchResponse.getProfileResult().getSearchStats().getTotalCollectTimeMs() > 0.0);
    assertTrue(searchResponse.getProfileResult().getSearchStats().getTotalReduceTimeMs() > 0.0);
    for (CollectorStats collectorStats : searchResponse.getProfileResult().getSearchStats().getCollectorStatsList()) {
        assertFalse(collectorStats.getTerminated());
        assertTrue(collectorStats.getTotalCollectTimeMs() > 0.0);
        assertEquals(50, collectorStats.getTotalCollectedCount());
        assertEquals(2, collectorStats.getAdditionalCollectorStatsCount());
        AdditionalCollectorStats additionalCollectorStats = collectorStats.getAdditionalCollectorStatsOrThrow("test_collector1");
        assertTrue(additionalCollectorStats.getCollectTimeMs() > 0.0);
        additionalCollectorStats = collectorStats.getAdditionalCollectorStatsOrThrow("test_collector2");
        assertTrue(additionalCollectorStats.getCollectTimeMs() > 0.0);
        for (SegmentStats segmentStats : collectorStats.getSegmentStatsList()) {
            assertEquals(10, segmentStats.getMaxDoc());
            assertEquals(10, segmentStats.getNumDocs());
            assertEquals(10, segmentStats.getCollectedCount());
            assertTrue(segmentStats.getCollectTimeMs() > 0.0);
            assertTrue(segmentStats.getRelativeStartTimeMs() > 0.0);
        }
    }
}
Also used : AdditionalCollectorStats(com.yelp.nrtsearch.server.grpc.ProfileResult.AdditionalCollectorStats) AdditionalCollectorStats(com.yelp.nrtsearch.server.grpc.ProfileResult.AdditionalCollectorStats) CollectorStats(com.yelp.nrtsearch.server.grpc.ProfileResult.CollectorStats) SegmentStats(com.yelp.nrtsearch.server.grpc.ProfileResult.SegmentStats) SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse) Test(org.junit.Test)

Example 2 with CollectorStats

use of com.yelp.nrtsearch.server.grpc.ProfileResult.CollectorStats 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)

Example 3 with CollectorStats

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

the class SearchStatsWrapperTest method testHasSearchStats.

@Test
public void testHasSearchStats() {
    SearchResponse searchResponse = getGrpcServer().getBlockingStub().search(SearchRequest.newBuilder().setIndexName(TEST_INDEX).setStartHit(0).setTopHits(5).addRetrieveFields("doc_id").addRetrieveFields("int_score").addRetrieveFields("int_field").setQuery(Query.newBuilder()).setProfile(true).build());
    assertTrue(searchResponse.getProfileResult().getSearchStats().getCollectorStatsCount() > 1);
    assertTrue(searchResponse.getProfileResult().getSearchStats().getTotalCollectTimeMs() > 0.0);
    assertTrue(searchResponse.getProfileResult().getSearchStats().getTotalReduceTimeMs() > 0.0);
    for (CollectorStats collectorStats : searchResponse.getProfileResult().getSearchStats().getCollectorStatsList()) {
        assertFalse(collectorStats.getTerminated());
        assertTrue(collectorStats.getTotalCollectTimeMs() > 0.0);
        assertEquals(50, collectorStats.getTotalCollectedCount());
        assertEquals(0, collectorStats.getAdditionalCollectorStatsCount());
        for (SegmentStats segmentStats : collectorStats.getSegmentStatsList()) {
            assertEquals(10, segmentStats.getMaxDoc());
            assertEquals(10, segmentStats.getNumDocs());
            assertEquals(10, segmentStats.getCollectedCount());
            assertTrue(segmentStats.getCollectTimeMs() > 0.0);
            assertTrue(segmentStats.getRelativeStartTimeMs() > 0.0);
        }
    }
}
Also used : CollectorStats(com.yelp.nrtsearch.server.grpc.ProfileResult.CollectorStats) SegmentStats(com.yelp.nrtsearch.server.grpc.ProfileResult.SegmentStats) SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse) Test(org.junit.Test)

Aggregations

CollectorStats (com.yelp.nrtsearch.server.grpc.ProfileResult.CollectorStats)3 Test (org.junit.Test)3 SegmentStats (com.yelp.nrtsearch.server.grpc.ProfileResult.SegmentStats)2 SearchResponse (com.yelp.nrtsearch.server.grpc.SearchResponse)2 ProfileResult (com.yelp.nrtsearch.server.grpc.ProfileResult)1 AdditionalCollectorStats (com.yelp.nrtsearch.server.grpc.ProfileResult.AdditionalCollectorStats)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