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: dataStore
test_class.modifier: private
test_class.original_string: private DataStore dataStore;
test_class.type: DataStore
test_class.var_name: dataStore
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.declarator: mapper
test_class.modifier: private
test_class.original_string: private ObjectMapper mapper;
test_class.type: ObjectMapper
test_class.var_name: mapper
test_class.file: real-time/foxtrot/foxtrot-core/src/test/java/com/flipkart/foxtrot/core/querystore/impl/ElasticsearchQueryStoreTest.java
test_class.identifier: ElasticsearchQueryStoreTest
test_case.body: @Test
      public void testSaveBulkEmptyList() throws Exception {
          List<Document> list = new Vector<Document>();
          try {
              queryStore.save(TestUtils.TEST_TABLE_NAME, list);
              fail();
          } catch (QueryStoreException ex) {
              assertEquals(QueryStoreException.ErrorCode.INVALID_REQUEST, ex.getErrorCode());
          }
      }
test_case.class_method_signature: ElasticsearchQueryStoreTest.testSaveBulkEmptyList()
test_case.full_signature: @Test public void testSaveBulkEmptyList()
test_case.identifier: testSaveBulkEmptyList
test_case.invocations: save fail assertEquals getErrorCode
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSaveBulkEmptyList()
focal_class.declarator: logger = LoggerFactory.getLogger(ElasticsearchQueryStore.class.getSimpleName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(ElasticsearchQueryStore.class.getSimpleName());
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: tableMetadataManager
focal_class.modifier: private final
focal_class.original_string: private final TableMetadataManager tableMetadataManager;
focal_class.type: TableMetadataManager
focal_class.var_name: tableMetadataManager
focal_class.declarator: connection
focal_class.modifier: private final
focal_class.original_string: private final ElasticsearchConnection connection;
focal_class.type: ElasticsearchConnection
focal_class.var_name: connection
focal_class.declarator: dataStore
focal_class.modifier: private final
focal_class.original_string: private final DataStore dataStore;
focal_class.type: DataStore
focal_class.var_name: dataStore
focal_class.declarator: mapper
focal_class.modifier: private final
focal_class.original_string: private final ObjectMapper mapper;
focal_class.type: ObjectMapper
focal_class.var_name: mapper
focal_class.file: real-time/foxtrot/foxtrot-core/src/main/java/com/flipkart/foxtrot/core/querystore/impl/ElasticsearchQueryStore.java
focal_class.identifier: ElasticsearchQueryStore
focal_class.interfaces: implements QueryStore
focal_class.class_method_signature: ElasticsearchQueryStore.ElasticsearchQueryStore(TableMetadataManager tableMetadataManager,
                                     ElasticsearchConnection connection,
                                     DataStore dataStore)
focal_class.full_signature: public  ElasticsearchQueryStore(TableMetadataManager tableMetadataManager,
                                     ElasticsearchConnection connection,
                                     DataStore dataStore)
focal_class.identifier: ElasticsearchQueryStore
focal_class.modifiers: public
focal_class.parameters: (TableMetadataManager tableMetadataManager,
                                     ElasticsearchConnection connection,
                                     DataStore dataStore)
focal_class.signature:  ElasticsearchQueryStore(TableMetadataManager tableMetadataManager,
                                     ElasticsearchConnection connection,
                                     DataStore dataStore)
focal_class.class_method_signature: ElasticsearchQueryStore.save(String table, Document document)
focal_class.full_signature: @Override public void save(String table, Document document)
focal_class.identifier: save
focal_class.modifiers: @Override public
focal_class.parameters: (String table, Document document)
focal_class.return: void
focal_class.signature: void save(String table, Document document)
focal_class.class_method_signature: ElasticsearchQueryStore.save(String table, List<Document> documents)
focal_class.full_signature: @Override public void save(String table, List<Document> documents)
focal_class.identifier: save
focal_class.modifiers: @Override public
focal_class.parameters: (String table, List<Document> documents)
focal_class.return: void
focal_class.signature: void save(String table, List<Document> documents)
focal_class.class_method_signature: ElasticsearchQueryStore.get(String table, String id)
focal_class.full_signature: @Override public Document get(String table, String id)
focal_class.identifier: get
focal_class.modifiers: @Override public
focal_class.parameters: (String table, String id)
focal_class.return: Document
focal_class.signature: Document get(String table, String id)
focal_class.class_method_signature: ElasticsearchQueryStore.get(String table, List<String> ids)
focal_class.full_signature: @Override public List<Document> get(String table, List<String> ids)
focal_class.identifier: get
focal_class.modifiers: @Override public
focal_class.parameters: (String table, List<String> ids)
focal_class.return: List<Document>
focal_class.signature: List<Document> get(String table, List<String> ids)
focal_class.class_method_signature: ElasticsearchQueryStore.getFieldMappings(String table)
focal_class.full_signature: @Override public TableFieldMapping getFieldMappings(String table)
focal_class.identifier: getFieldMappings
focal_class.modifiers: @Override public
focal_class.parameters: (String table)
focal_class.return: TableFieldMapping
focal_class.signature: TableFieldMapping getFieldMappings(String table)
focal_class.class_method_signature: ElasticsearchQueryStore.cleanupAll()
focal_class.full_signature: @Override public void cleanupAll()
focal_class.identifier: cleanupAll
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void cleanupAll()
focal_class.class_method_signature: ElasticsearchQueryStore.cleanup(final String table)
focal_class.full_signature: @Override public void cleanup(final String table)
focal_class.identifier: cleanup
focal_class.modifiers: @Override public
focal_class.parameters: (final String table)
focal_class.return: void
focal_class.signature: void cleanup(final String table)
focal_class.class_method_signature: ElasticsearchQueryStore.cleanup(Set<String> tables)
focal_class.full_signature: @Override public void cleanup(Set<String> tables)
focal_class.identifier: cleanup
focal_class.modifiers: @Override public
focal_class.parameters: (Set<String> tables)
focal_class.return: void
focal_class.signature: void cleanup(Set<String> tables)
focal_method.body: @Override
      public void save(String table, Document document) throws QueryStoreException {
          table = ElasticsearchUtils.getValidTableName(table);
          try {
              if (!tableMetadataManager.exists(table)) {
                  throw new QueryStoreException(QueryStoreException.ErrorCode.NO_SUCH_TABLE,
                          "No table exists with the name: " + table);
              }
              if (new DateTime().plusDays(1).minus(document.getTimestamp()).getMillis() <  0) {
                  return;
              }
              dataStore.save(tableMetadataManager.get(table), document);
              long timestamp = document.getTimestamp();
              Stopwatch stopwatch = new Stopwatch();
              stopwatch.start();
              connection.getClient()
                      .prepareIndex()
                      .setIndex(ElasticsearchUtils.getCurrentIndex(table, timestamp))
                      .setType(ElasticsearchUtils.TYPE_NAME)
                      .setId(document.getId())
                      .setTimestamp(Long.toString(timestamp))
                      .setSource(mapper.writeValueAsBytes(document.getData()))
                      .setConsistencyLevel(WriteConsistencyLevel.QUORUM)
                      .execute()
                      .get(2, TimeUnit.SECONDS);
              logger.info(String.format("ES took : %d table : %s", stopwatch.elapsedMillis(), table));
          } catch (QueryStoreException ex) {
              throw ex;
          } catch (DataStoreException ex) {
              DataStoreException.ErrorCode code = ex.getErrorCode();
              if (code.equals(DataStoreException.ErrorCode.STORE_INVALID_REQUEST)
                      || code.equals(DataStoreException.ErrorCode.STORE_INVALID_DOCUMENT)) {
                  throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST,
                          ex.getMessage(), ex);
              } else {
                  throw new QueryStoreException(QueryStoreException.ErrorCode.DOCUMENT_SAVE_ERROR,
                          ex.getMessage(), ex);
              }
          } catch (JsonProcessingException ex) {
              throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST,
                      ex.getMessage(), ex);
          } catch (Exception ex) {
              throw new QueryStoreException(QueryStoreException.ErrorCode.DOCUMENT_SAVE_ERROR,
                      ex.getMessage(), ex);
          }
      }
focal_method.class_method_signature: ElasticsearchQueryStore.save(String table, Document document)
focal_method.full_signature: @Override public void save(String table, Document document)
focal_method.identifier: save
focal_method.invocations: getValidTableName exists getMillis minus plusDays getTimestamp save get getTimestamp start get execute setConsistencyLevel setSource setTimestamp setId setType setIndex prepareIndex getClient getCurrentIndex getId toString writeValueAsBytes getData info format elapsedMillis getErrorCode equals equals getMessage getMessage getMessage getMessage
focal_method.modifiers: @Override public
focal_method.parameters: (String table, Document document)
focal_method.return: void
focal_method.signature: void save(String table, Document document)