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 final
test_class.original_string: private final 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.file: real-time/foxtrot/foxtrot-core/src/test/java/com/flipkart/foxtrot/core/querystore/actions/GroupActionTest.java
test_class.identifier: GroupActionTest
test_case.body: @Test
      public void testGroupActionSingleFieldSpecialCharactersNoFilter() throws QueryStoreException, JsonProcessingException {
          GroupRequest groupRequest = new GroupRequest();
          groupRequest.setTable(TestUtils.TEST_TABLE_NAME);
          groupRequest.setNesting(Arrays.asList(""));
  
          try {
              queryExecutor.execute(groupRequest);
              fail();
          } catch (QueryStoreException ex) {
              assertEquals(QueryStoreException.ErrorCode.INVALID_REQUEST, ex.getErrorCode());
          }
      }
test_case.class_method_signature: GroupActionTest.testGroupActionSingleFieldSpecialCharactersNoFilter()
test_case.full_signature: @Test public void testGroupActionSingleFieldSpecialCharactersNoFilter()
test_case.identifier: testGroupActionSingleFieldSpecialCharactersNoFilter
test_case.invocations: setTable setNesting asList execute fail assertEquals getErrorCode
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGroupActionSingleFieldSpecialCharactersNoFilter()
focal_class.declarator: logger = LoggerFactory.getLogger(GroupAction.class.getSimpleName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(GroupAction.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/GroupAction.java
focal_class.identifier: GroupAction
focal_class.class_method_signature: GroupAction.GroupAction(GroupRequest parameter,
                         TableMetadataManager tableMetadataManager,
                         DataStore dataStore,
                         QueryStore queryStore,
                         ElasticsearchConnection connection,
                         String cacheToken)
focal_class.full_signature: public  GroupAction(GroupRequest parameter,
                         TableMetadataManager tableMetadataManager,
                         DataStore dataStore,
                         QueryStore queryStore,
                         ElasticsearchConnection connection,
                         String cacheToken)
focal_class.identifier: GroupAction
focal_class.modifiers: public
focal_class.parameters: (GroupRequest parameter,
                         TableMetadataManager tableMetadataManager,
                         DataStore dataStore,
                         QueryStore queryStore,
                         ElasticsearchConnection connection,
                         String cacheToken)
focal_class.signature:  GroupAction(GroupRequest parameter,
                         TableMetadataManager tableMetadataManager,
                         DataStore dataStore,
                         QueryStore queryStore,
                         ElasticsearchConnection connection,
                         String cacheToken)
focal_class.class_method_signature: GroupAction.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: GroupAction.execute(GroupRequest parameter)
focal_class.full_signature: @Override public ActionResponse execute(GroupRequest parameter)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (GroupRequest parameter)
focal_class.return: ActionResponse
focal_class.signature: ActionResponse execute(GroupRequest parameter)
focal_class.class_method_signature: GroupAction.getMap(List<String> fields, Aggregations aggregations)
focal_class.full_signature: private Map<String, Object> getMap(List<String> fields, Aggregations aggregations)
focal_class.identifier: getMap
focal_class.modifiers: private
focal_class.parameters: (List<String> fields, Aggregations aggregations)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> getMap(List<String> fields, Aggregations aggregations)
focal_class.superclass: extends Action<GroupRequest>
focal_method.body: @Override
      public ActionResponse execute(GroupRequest parameter) throws QueryStoreException {
          parameter.setTable(ElasticsearchUtils.getValidTableName(parameter.getTable()));
          if (null == parameter.getFilters()) {
              parameter.setFilters(Lists.<Filter>newArrayList(new AnyFilter(parameter.getTable())));
          }
          if (parameter.getTable() == null) {
              throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, "Invalid Table");
          }
          try {
              SearchRequestBuilder query = getConnection().getClient().prepareSearch(ElasticsearchUtils.getIndices(
                      parameter.getTable(), parameter));
              TermsBuilder rootBuilder = null;
              TermsBuilder termsBuilder = null;
              for (String field : parameter.getNesting()) {
                  if (field == null || field.trim().isEmpty()) {
                      throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, "Illegal Nesting Parameters");
                  }
                  if (null == termsBuilder) {
                      termsBuilder = AggregationBuilders.terms(Utils.sanitizeFieldForAggregation(field)).field(field);
                  } else {
                      TermsBuilder tempBuilder = AggregationBuilders.terms(Utils.sanitizeFieldForAggregation(field)).field(field);
                      termsBuilder.subAggregation(tempBuilder);
                      termsBuilder = tempBuilder;
                  }
                  termsBuilder.size(0);
                  if (null == rootBuilder) {
                      rootBuilder = termsBuilder;
                  }
              }
              query.setQuery(new ElasticSearchQueryGenerator(FilterCombinerType.and)
                      .genFilter(parameter.getFilters()))
                      .setSearchType(SearchType.COUNT)
                      .addAggregation(rootBuilder);
              SearchResponse response = query.execute().actionGet();
              List<String> fields = parameter.getNesting();
              Aggregations aggregations = response.getAggregations();
              // Check if any aggregation is present or not
              if (aggregations == null) {
                  logger.error("Null response for Group. Request : " + parameter.toString());
                  return new GroupResponse(Collections.<String, Object>emptyMap());
              }
              return new GroupResponse(getMap(fields, aggregations));
          } catch (QueryStoreException ex) {
              throw ex;
          } catch (Exception e) {
              logger.error("Error running grouping: ", e);
              throw new QueryStoreException(QueryStoreException.ErrorCode.QUERY_EXECUTION_ERROR,
                      "Error running group query.", e);
          }
      }
focal_method.class_method_signature: GroupAction.execute(GroupRequest parameter)
focal_method.full_signature: @Override public ActionResponse execute(GroupRequest parameter)
focal_method.identifier: execute
focal_method.invocations: setTable getValidTableName getTable getFilters setFilters newArrayList getTable getTable prepareSearch getClient getConnection getIndices getTable getNesting isEmpty trim field terms sanitizeFieldForAggregation field terms sanitizeFieldForAggregation subAggregation size addAggregation setSearchType setQuery genFilter getFilters actionGet execute getNesting getAggregations error toString emptyMap getMap error
focal_method.modifiers: @Override public
focal_method.parameters: (GroupRequest parameter)
focal_method.return: ActionResponse
focal_method.signature: ActionResponse execute(GroupRequest parameter)