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.declarator: factory = JsonNodeFactory.instance
test_class.modifier: private
test_class.original_string: private JsonNodeFactory factory = JsonNodeFactory.instance;
test_class.type: JsonNodeFactory
test_class.var_name: factory
test_class.file: real-time/foxtrot/foxtrot-core/src/test/java/com/flipkart/foxtrot/core/querystore/actions/HistogramActionTest.java
test_class.identifier: HistogramActionTest
test_case.body: @Test
      public void testHistogramActionIntervalDayNoFilter() throws QueryStoreException, JsonProcessingException {
          HistogramRequest histogramRequest = new HistogramRequest();
          histogramRequest.setTable(TestUtils.TEST_TABLE_NAME);
          histogramRequest.setPeriod(Period.days);
          LessThanFilter lessThanFilter = new LessThanFilter();
          lessThanFilter.setTemporal(true);
          lessThanFilter.setField("_timestamp");
          lessThanFilter.setValue(System.currentTimeMillis());
          histogramRequest.setFilters(Lists.<Filter>newArrayList(lessThanFilter));
  
          HistogramResponse response = HistogramResponse.class.cast(queryExecutor.execute(histogramRequest));
          List<HistogramResponse.Count> counts = new ArrayList<HistogramResponse.Count>();
          counts.add(new HistogramResponse.Count(1397606400000L, 6));
          counts.add(new HistogramResponse.Count(1397692800000L, 1));
          counts.add(new HistogramResponse.Count(1397952000000L, 1));
          counts.add(new HistogramResponse.Count(1398643200000L, 3));
          assertTrue(response.getCounts().equals(counts));
      }
test_case.class_method_signature: HistogramActionTest.testHistogramActionIntervalDayNoFilter()
test_case.full_signature: @Test public void testHistogramActionIntervalDayNoFilter()
test_case.identifier: testHistogramActionIntervalDayNoFilter
test_case.invocations: setTable setPeriod setTemporal setField setValue currentTimeMillis setFilters newArrayList cast execute add add add add assertTrue equals getCounts
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testHistogramActionIntervalDayNoFilter()
focal_class.declarator: logger = LoggerFactory.getLogger(HistogramAction.class.getSimpleName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(HistogramAction.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/HistogramAction.java
focal_class.identifier: HistogramAction
focal_class.class_method_signature: HistogramAction.HistogramAction(HistogramRequest parameter,
                             TableMetadataManager tableMetadataManager,
                             DataStore dataStore,
                             QueryStore queryStore,
                             ElasticsearchConnection connection,
                             String cacheToken)
focal_class.full_signature: public  HistogramAction(HistogramRequest parameter,
                             TableMetadataManager tableMetadataManager,
                             DataStore dataStore,
                             QueryStore queryStore,
                             ElasticsearchConnection connection,
                             String cacheToken)
focal_class.identifier: HistogramAction
focal_class.modifiers: public
focal_class.parameters: (HistogramRequest parameter,
                             TableMetadataManager tableMetadataManager,
                             DataStore dataStore,
                             QueryStore queryStore,
                             ElasticsearchConnection connection,
                             String cacheToken)
focal_class.signature:  HistogramAction(HistogramRequest parameter,
                             TableMetadataManager tableMetadataManager,
                             DataStore dataStore,
                             QueryStore queryStore,
                             ElasticsearchConnection connection,
                             String cacheToken)
focal_class.class_method_signature: HistogramAction.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: HistogramAction.execute(HistogramRequest parameter)
focal_class.full_signature: @Override public ActionResponse execute(HistogramRequest parameter)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (HistogramRequest parameter)
focal_class.return: ActionResponse
focal_class.signature: ActionResponse execute(HistogramRequest parameter)
focal_class.class_method_signature: HistogramAction.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.superclass: extends Action<HistogramRequest>
focal_method.body: @Override
      public ActionResponse execute(HistogramRequest parameter) throws QueryStoreException {
          parameter.setTable(ElasticsearchUtils.getValidTableName(parameter.getTable()));
          if (null == parameter.getFilters()) {
              parameter.setFilters(Lists.<Filter>newArrayList(new AnyFilter(parameter.getTable())));
          }
  
          if (parameter.getField() == null || parameter.getField().trim().isEmpty()) {
              throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, "Illegal Nesting Parameters");
          }
  
          try {
              /*if(!tableManager.exists(query.getTable())) {
                  throw new QueryStoreException(QueryStoreException.ErrorCode.NO_SUCH_TABLE,
                          "There is no table called: " + query.getTable());
              }*/
              DateHistogram.Interval interval = null;
              switch (parameter.getPeriod()) {
                  case seconds:
                      interval = DateHistogram.Interval.SECOND;
                      break;
                  case minutes:
                      interval = DateHistogram.Interval.MINUTE;
                      break;
                  case hours:
                      interval = DateHistogram.Interval.HOUR;
                      break;
                  case days:
                      interval = DateHistogram.Interval.DAY;
                      break;
              }
  
              String dateHistogramKey = Utils.sanitizeFieldForAggregation(parameter.getField());
              SearchResponse response = getConnection().getClient().prepareSearch(
                      ElasticsearchUtils.getIndices(parameter.getTable(), parameter))
                      .setTypes(ElasticsearchUtils.TYPE_NAME)
                      .setQuery(new ElasticSearchQueryGenerator(FilterCombinerType.and)
                              .genFilter(parameter.getFilters()))
                      .setSize(0)
                      .setSearchType(SearchType.COUNT)
                      .addAggregation(AggregationBuilders.dateHistogram(dateHistogramKey)
                              .field(parameter.getField())
                              .interval(interval))
                      .execute()
                      .actionGet();
              Aggregations aggregations = response.getAggregations();
              if (aggregations == null) {
                  logger.error("Null response for Histogram. Request : " + parameter.toString());
                  return new HistogramResponse(Collections.<HistogramResponse.Count>emptyList());
              }
              DateHistogram dateHistogram = aggregations.get(dateHistogramKey);
              Collection<? extends DateHistogram.Bucket> buckets = dateHistogram.getBuckets();
              List<HistogramResponse.Count> counts = new ArrayList<HistogramResponse.Count>(buckets.size());
              for (DateHistogram.Bucket bucket : buckets) {
                  HistogramResponse.Count count = new HistogramResponse.Count(
                          bucket.getKeyAsNumber(), bucket.getDocCount());
                  counts.add(count);
              }
              return new HistogramResponse(counts);
          } catch (QueryStoreException ex) {
              throw ex;
          } catch (Exception e) {
              throw new QueryStoreException(QueryStoreException.ErrorCode.HISTOGRAM_GENERATION_ERROR,
                      "Malformed query", e);
          }
      }
focal_method.class_method_signature: HistogramAction.execute(HistogramRequest parameter)
focal_method.full_signature: @Override public ActionResponse execute(HistogramRequest parameter)
focal_method.identifier: execute
focal_method.invocations: setTable getValidTableName getTable getFilters setFilters newArrayList getTable getField isEmpty trim getField getPeriod sanitizeFieldForAggregation getField actionGet execute addAggregation setSearchType setSize setQuery setTypes prepareSearch getClient getConnection getIndices getTable genFilter getFilters interval field dateHistogram getField getAggregations error toString emptyList get getBuckets size getKeyAsNumber getDocCount add
focal_method.modifiers: @Override public
focal_method.parameters: (HistogramRequest parameter)
focal_method.return: ActionResponse
focal_method.signature: ActionResponse execute(HistogramRequest parameter)