test_class.declarator: queryExecutor
test_class.modifier: private
test_class.original_string: private QueryExecutor queryExecutor;
test_class.type: QueryExecutor
test_class.var_name: queryExecutor
test_class.declarator: mapper = new ObjectMapper()
test_class.modifier: private
test_class.original_string: private ObjectMapper mapper = new ObjectMapper();
test_class.type: ObjectMapper
test_class.var_name: mapper
test_class.declarator: elasticsearchServer
test_class.modifier: private
test_class.original_string: private MockElasticsearchServer elasticsearchServer;
test_class.type: MockElasticsearchServer
test_class.var_name: elasticsearchServer
test_class.declarator: hazelcastInstance
test_class.modifier: private
test_class.original_string: private HazelcastInstance hazelcastInstance;
test_class.type: HazelcastInstance
test_class.var_name: hazelcastInstance
test_class.declarator: queryStore
test_class.modifier: private
test_class.original_string: private ElasticsearchQueryStore queryStore;
test_class.type: ElasticsearchQueryStore
test_class.var_name: queryStore
test_class.file: real-time/foxtrot/foxtrot-core/src/test/java/com/flipkart/foxtrot/core/querystore/actions/TrendActionTest.java
test_class.identifier: TrendActionTest
test_case.body: @Test
      public void testTrendActionWithFieldWithValues() throws QueryStoreException, JsonProcessingException {
          TrendRequest trendRequest = new TrendRequest();
          trendRequest.setTable(TestUtils.TEST_TABLE_NAME);
          BetweenFilter betweenFilter = new BetweenFilter();
          betweenFilter.setFrom(1L);
          betweenFilter.setTo(System.currentTimeMillis());
          betweenFilter.setTemporal(true);
          betweenFilter.setField("_timestamp");
          trendRequest.setField("os");
          trendRequest.setFilters(Lists.<Filter>newArrayList(betweenFilter));
          trendRequest.setValues(Arrays.asList("android"));
  
          TrendResponse expectedResponse = new TrendResponse();
          Map<String, List<TrendResponse.Count>> trends = new HashMap<String, List<TrendResponse.Count>>();
  
          List<TrendResponse.Count> counts = Lists.newArrayList();
          counts.add(new TrendResponse.Count(1397606400000L, 6));
          counts.add(new TrendResponse.Count(1398643200000L, 1));
          trends.put("android", counts);
  
          expectedResponse.setTrends(trends);
  
          TrendResponse actualResponse = TrendResponse.class.cast(queryExecutor.execute(trendRequest));
          assertEquals(expectedResponse, actualResponse);
      }
test_case.class_method_signature: TrendActionTest.testTrendActionWithFieldWithValues()
test_case.full_signature: @Test public void testTrendActionWithFieldWithValues()
test_case.identifier: testTrendActionWithFieldWithValues
test_case.invocations: setTable setFrom setTo currentTimeMillis setTemporal setField setField setFilters newArrayList setValues asList newArrayList add add put setTrends cast execute assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testTrendActionWithFieldWithValues()
focal_class.declarator: logger = LoggerFactory.getLogger(TrendAction.class.getSimpleName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(TrendAction.class.getSimpleName());
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: real-time/foxtrot/foxtrot-core/src/main/java/com/flipkart/foxtrot/core/querystore/actions/TrendAction.java
focal_class.identifier: TrendAction
focal_class.class_method_signature: TrendAction.TrendAction(TrendRequest parameter,
                         TableMetadataManager tableMetadataManager,
                         DataStore dataStore,
                         QueryStore queryStore,
                         ElasticsearchConnection connection,
                         String cacheToken)
focal_class.full_signature: public  TrendAction(TrendRequest parameter,
                         TableMetadataManager tableMetadataManager,
                         DataStore dataStore,
                         QueryStore queryStore,
                         ElasticsearchConnection connection,
                         String cacheToken)
focal_class.identifier: TrendAction
focal_class.modifiers: public
focal_class.parameters: (TrendRequest parameter,
                         TableMetadataManager tableMetadataManager,
                         DataStore dataStore,
                         QueryStore queryStore,
                         ElasticsearchConnection connection,
                         String cacheToken)
focal_class.signature:  TrendAction(TrendRequest parameter,
                         TableMetadataManager tableMetadataManager,
                         DataStore dataStore,
                         QueryStore queryStore,
                         ElasticsearchConnection connection,
                         String cacheToken)
focal_class.class_method_signature: TrendAction.getRequestCacheKey()
focal_class.full_signature: @Override protected String getRequestCacheKey()
focal_class.identifier: getRequestCacheKey
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getRequestCacheKey()
focal_class.class_method_signature: TrendAction.execute(TrendRequest parameter)
focal_class.full_signature: @Override public ActionResponse execute(TrendRequest parameter)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (TrendRequest parameter)
focal_class.return: ActionResponse
focal_class.signature: ActionResponse execute(TrendRequest parameter)
focal_class.class_method_signature: TrendAction.getDefaultTimeSpan()
focal_class.full_signature: @Override protected Filter getDefaultTimeSpan()
focal_class.identifier: getDefaultTimeSpan
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: Filter
focal_class.signature: Filter getDefaultTimeSpan()
focal_class.class_method_signature: TrendAction.buildAggregation(TrendRequest request)
focal_class.full_signature: private AbstractAggregationBuilder buildAggregation(TrendRequest request)
focal_class.identifier: buildAggregation
focal_class.modifiers: private
focal_class.parameters: (TrendRequest request)
focal_class.return: AbstractAggregationBuilder
focal_class.signature: AbstractAggregationBuilder buildAggregation(TrendRequest request)
focal_class.class_method_signature: TrendAction.buildResponse(TrendRequest request, Aggregations aggregations)
focal_class.full_signature: private TrendResponse buildResponse(TrendRequest request, Aggregations aggregations)
focal_class.identifier: buildResponse
focal_class.modifiers: private
focal_class.parameters: (TrendRequest request, Aggregations aggregations)
focal_class.return: TrendResponse
focal_class.signature: TrendResponse buildResponse(TrendRequest request, Aggregations aggregations)
focal_class.superclass: extends Action<TrendRequest>
focal_method.body: @Override
      public ActionResponse execute(TrendRequest parameter) throws QueryStoreException {
          parameter.setTable(ElasticsearchUtils.getValidTableName(parameter.getTable()));
          if (null == parameter.getFilters()) {
              parameter.setFilters(Lists.<Filter>newArrayList(new AnyFilter(parameter.getTable())));
          }
          String field = parameter.getField();
          if (parameter.getTable() == null) {
              throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, "Invalid table name");
          }
          if (null == field || field.isEmpty()) {
              throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, "Invalid field name");
          }
          if (null != parameter.getValues() && parameter.getValues().size() != 0) {
              List<Object> values = (List) parameter.getValues();
              Filter filter = new InFilter(field, values);
              parameter.getFilters().add(filter);
          }
  
          try {
              AbstractAggregationBuilder aggregationBuilder = buildAggregation(parameter);
              SearchResponse searchResponse = getConnection().getClient()
                      .prepareSearch(ElasticsearchUtils.getIndices(parameter.getTable(), parameter))
                      .setQuery(new ElasticSearchQueryGenerator(FilterCombinerType.and).genFilter(parameter.getFilters()))
                      .setSearchType(SearchType.COUNT)
                      .addAggregation(aggregationBuilder)
                      .execute()
                      .get();
  
              Aggregations aggregations = searchResponse.getAggregations();
              if (aggregations != null) {
                  return buildResponse(parameter, aggregations);
              } else {
                  logger.error("Null response for Trend. Request : " + parameter.toString());
                  return new TrendResponse(Collections.<String, List<TrendResponse.Count>>emptyMap());
              }
          } catch (Exception e) {
              logger.error("Error running trend action: ", e);
              throw new QueryStoreException(QueryStoreException.ErrorCode.QUERY_EXECUTION_ERROR,
                      "Error running trend action.", e);
          }
      }
focal_method.class_method_signature: TrendAction.execute(TrendRequest parameter)
focal_method.full_signature: @Override public ActionResponse execute(TrendRequest parameter)
focal_method.identifier: execute
focal_method.invocations: setTable getValidTableName getTable getFilters setFilters newArrayList getTable getField getTable isEmpty getValues size getValues getValues add getFilters buildAggregation get execute addAggregation setSearchType setQuery prepareSearch getClient getConnection getIndices getTable genFilter getFilters getAggregations buildResponse error toString emptyMap error
focal_method.modifiers: @Override public
focal_method.parameters: (TrendRequest parameter)
focal_method.return: ActionResponse
focal_method.signature: ActionResponse execute(TrendRequest parameter)