NCBI C++ ToolKit
fetch.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef OBJTOOLS__PUBSEQ_GATEWAY__CASSANDRA__BLOB_TASK__FETCH_HPP_
2 #define OBJTOOLS__PUBSEQ_GATEWAY__CASSANDRA__BLOB_TASK__FETCH_HPP_
3 
4 /* $Id: fetch.hpp 97228 2022-06-28 14:10:54Z saprykin $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Dmitrii Saprykin
30  *
31  * File Description:
32  *
33  * Cassandra insert blob according to extended schema task.
34  *
35  */
36 
37 #include <functional>
38 #include <string>
39 #include <memory>
40 #include <vector>
41 
42 #include <corelib/ncbistr.hpp>
43 
47 
50 
52  : public CCassBlobWaiter
53 {
55  eInit = 0,
59  };
60 
61  public:
63  shared_ptr<CCassConnection> connection,
64  const string & keyspace,
65  string accession,
67  int16_t seq_id_type,
68  const vector<string> & annot_names,
69  TNAnnotConsumeCallback consume_callback,
70  TDataErrorCallback data_error_cb
71  );
72 
74  shared_ptr<CCassConnection> connection,
75  const string & keyspace,
76  string accession,
78  int16_t seq_id_type,
79  const vector<CTempString> & annot_names,
80  TNAnnotConsumeCallback consume_callback,
81  TDataErrorCallback data_error_cb
82  );
83 
85  shared_ptr<CCassConnection> connection,
86  const string & keyspace,
87  string accession,
89  int16_t seq_id_type,
90  TNAnnotConsumeCallback consume_callback,
91  TDataErrorCallback data_error_cb
92  );
93 
94  void SetDataReadyCB(shared_ptr<CCassDataCallbackReceiver> callback);
96 
97  string GetAccession() const
98  {
99  return m_Accession;
100  }
101 
103  {
104  return m_Version;
105  }
106 
108  {
109  return m_SeqIdType;
110  }
111 
112  vector<string> GetAnnotNames() const
113  {
114  if (!m_AnnotNamesTemp.empty()) {
115  vector<string> result;
116  result.reserve(m_AnnotNamesTemp.size());
117  for (CTempString const& item : m_AnnotNamesTemp) {
118  result.push_back(item);
119  }
120  return result;
121  }
122  return m_AnnotNames;
123  }
124 
125  protected:
126  void Wait1() override;
127 
128  private:
129  size_t x_AnnotNamesSize() const;
130  size_t x_AnnotNamesCount(string const & more) const;
131  void x_AnnotNamesBind(shared_ptr<CCassQuery>& query, string const & more, unsigned int first) const;
132 
133  string m_Accession;
136  vector<string> m_AnnotNames;
137  vector<CTempString> m_AnnotNamesTemp;
140  protected:
142  unsigned int m_RestartCounter{0};
143 };
144 
146 
147 #endif // OBJTOOLS__PUBSEQ_GATEWAY__CASSANDRA__BLOB_TASK__FETCH_HPP_
#define END_IDBLOB_SCOPE
Definition: IdCassScope.hpp:40
#define BEGIN_IDBLOB_SCOPE
Definition: IdCassScope.hpp:39
function< void(CRequestStatus::ECode status, int code, EDiagSev severity, const string &message)> TDataErrorCallback
TNAnnotConsumeCallback m_Consume
Definition: fetch.hpp:138
void SetDataReadyCB(shared_ptr< CCassDataCallbackReceiver > callback)
Definition: fetch.cpp:108
vector< CTempString > m_AnnotNamesTemp
Definition: fetch.hpp:137
void x_AnnotNamesBind(shared_ptr< CCassQuery > &query, string const &more, unsigned int first) const
Definition: fetch.cpp:147
int16_t GetSeqIdType() const
Definition: fetch.hpp:107
size_t x_AnnotNamesCount(string const &more) const
Definition: fetch.cpp:128
vector< string > GetAnnotNames() const
Definition: fetch.hpp:112
void Wait1() override
Definition: fetch.cpp:168
CCassNAnnotTaskFetch(shared_ptr< CCassConnection > connection, const string &keyspace, string accession, int16_t version, int16_t seq_id_type, const vector< string > &annot_names, TNAnnotConsumeCallback consume_callback, TDataErrorCallback data_error_cb)
Definition: fetch.cpp:51
string m_LastConsumedAnnot
Definition: fetch.hpp:139
unsigned int m_RestartCounter
Definition: fetch.hpp:142
void SetConsumeCallback(TNAnnotConsumeCallback callback)
Definition: fetch.cpp:103
int16_t m_SeqIdType
Definition: fetch.hpp:135
vector< string > m_AnnotNames
Definition: fetch.hpp:136
unsigned int m_PageSize
Definition: fetch.hpp:141
int16_t GetVersion() const
Definition: fetch.hpp:102
size_t x_AnnotNamesSize() const
Definition: fetch.cpp:118
string GetAccession() const
Definition: fetch.hpp:97
static const unsigned int DEFAULT_PAGE_SIZE
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
The NCBI C++ standard methods for dealing with std::string.
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
static int version
Definition: mdb_load.c:29
function< bool(CNAnnotRecord &&, bool last)> TNAnnotConsumeCallback
Definition: record.hpp:238
BEGIN_IDBLOB_SCOPE USING_NCBI_SCOPE
Definition: fetch.hpp:49
signed short int16_t
Definition: stdint.h:122
static string query
else result
Definition: token2.c:20
Modified on Fri Jan 05 07:23:56 2024 by modify_doxy.py rev. 669887