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.file: real-time/foxtrot/foxtrot-core/src/test/java/com/flipkart/foxtrot/core/querystore/actions/FilterActionTest.java
test_class.identifier: FilterActionTest
test_case.body: @Test
      public void testQueryCaching() throws QueryStoreException, JsonProcessingException {
          Query query = new Query();
          query.setTable(TestUtils.TEST_TABLE_NAME);
  
          ResultSort resultSort = new ResultSort();
          resultSort.setOrder(ResultSort.Order.desc);
          resultSort.setField("_timestamp");
          query.setSort(resultSort);
  
          EqualsFilter equalsFilter = new EqualsFilter();
          equalsFilter.setField("os");
          equalsFilter.setValue("ios");
          query.setFilters(Lists.<Filter>newArrayList(equalsFilter));
  
          query.setFrom(1);
          query.setLimit(1);
  
          List<Document> documents = new ArrayList<Document>();
          documents.add(TestUtils.getDocument("D", 1397658118003L, new Object[]{"os", "ios", "version", 1, "device", "iphone"}, mapper));
          QueryResponse actualResponse = QueryResponse.class.cast(queryExecutor.execute(query));
          compare(documents, actualResponse.getDocuments());
      }
test_case.class_method_signature: FilterActionTest.testQueryCaching()
test_case.full_signature: @Test public void testQueryCaching()
test_case.identifier: testQueryCaching
test_case.invocations: setTable setOrder setField setSort setField setValue setFilters newArrayList setFrom setLimit add getDocument cast execute compare getDocuments
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testQueryCaching()
focal_class.declarator: logger = LoggerFactory.getLogger(FilterAction.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(FilterAction.class);
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/FilterAction.java
focal_class.identifier: FilterAction
focal_class.class_method_signature: FilterAction.FilterAction(Query parameter,
                          TableMetadataManager tableMetadataManager,
                          DataStore dataStore,
                          QueryStore queryStore,
                          ElasticsearchConnection connection,
                          String cacheToken)
focal_class.full_signature: public  FilterAction(Query parameter,
                          TableMetadataManager tableMetadataManager,
                          DataStore dataStore,
                          QueryStore queryStore,
                          ElasticsearchConnection connection,
                          String cacheToken)
focal_class.identifier: FilterAction
focal_class.modifiers: public
focal_class.parameters: (Query parameter,
                          TableMetadataManager tableMetadataManager,
                          DataStore dataStore,
                          QueryStore queryStore,
                          ElasticsearchConnection connection,
                          String cacheToken)
focal_class.signature:  FilterAction(Query parameter,
                          TableMetadataManager tableMetadataManager,
                          DataStore dataStore,
                          QueryStore queryStore,
                          ElasticsearchConnection connection,
                          String cacheToken)
focal_class.class_method_signature: FilterAction.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: FilterAction.execute(Query parameter)
focal_class.full_signature: @Override public QueryResponse execute(Query parameter)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (Query parameter)
focal_class.return: QueryResponse
focal_class.signature: QueryResponse execute(Query parameter)
focal_class.superclass: extends Action<Query>
focal_method.body: @Override
      public QueryResponse execute(Query parameter) throws QueryStoreException {
          parameter.setTable(ElasticsearchUtils.getValidTableName(parameter.getTable()));
          if (null == parameter.getFilters() || parameter.getFilters().isEmpty()) {
              parameter.setFilters(Lists.<Filter>newArrayList(new AnyFilter(parameter.getTable())));
          }
          if (null == parameter.getSort()) {
              ResultSort resultSort = new ResultSort();
              resultSort.setField("_timestamp");
              resultSort.setOrder(ResultSort.Order.desc);
              parameter.setSort(resultSort);
          }
          SearchRequestBuilder search = null;
          SearchResponse response;
          try {
              /*if(!tableManager.exists(query.getTable())) {
                  throw new QueryStoreException(QueryStoreException.ErrorCode.NO_SUCH_TABLE,
                          "There is no table called: " + query.getTable());
              }*/
              search = getConnection().getClient().prepareSearch(ElasticsearchUtils.getIndices(parameter.getTable(), parameter))
                      .setTypes(ElasticsearchUtils.TYPE_NAME)
                      .setQuery(new ElasticSearchQueryGenerator(FilterCombinerType.and).genFilter(parameter.getFilters()))
                      .setSearchType(SearchType.QUERY_THEN_FETCH)
                      .setFrom(parameter.getFrom())
                      .setSize(parameter.getLimit());
              search.addSort(parameter.getSort().getField(),
                      ResultSort.Order.desc == parameter.getSort().getOrder() ? SortOrder.DESC : SortOrder.ASC);
              response = search.execute().actionGet();
              Vector<String> ids = new Vector<String>();
              for (SearchHit searchHit : response.getHits()) {
                  ids.add(searchHit.getId());
              }
              if (ids.isEmpty()) {
                  return new QueryResponse(Collections.<Document>emptyList());
              }
              return new QueryResponse(getQueryStore().get(parameter.getTable(), ids));
          } catch (Exception e) {
              if (null != search) {
                  logger.error("Error running generated query: " + search, e);
              } else {
                  logger.error("Query generation error: ", e);
              }
              throw new QueryStoreException(QueryStoreException.ErrorCode.QUERY_EXECUTION_ERROR,
                      "Error running query: " + parameter.toString());
          }
      }
focal_method.class_method_signature: FilterAction.execute(Query parameter)
focal_method.full_signature: @Override public QueryResponse execute(Query parameter)
focal_method.identifier: execute
focal_method.invocations: setTable getValidTableName getTable getFilters isEmpty getFilters setFilters newArrayList getTable getSort setField setOrder setSort setSize setFrom setSearchType setQuery setTypes prepareSearch getClient getConnection getIndices getTable genFilter getFilters getFrom getLimit addSort getField getSort getOrder getSort actionGet execute getHits add getId isEmpty emptyList get getQueryStore getTable error error toString
focal_method.modifiers: @Override public
focal_method.parameters: (Query parameter)
focal_method.return: QueryResponse
focal_method.signature: QueryResponse execute(Query parameter)