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);
}
}
}
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());
}
}
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);
}
}
}
Aggregations