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

Go to the SVN repository for this file.

1 /*****************************************************************************
2  * $Id: plan.hpp 100949 2023-10-04 15:26:38Z saprykin $
3  * ===========================================================================
4  *
5  * PUBLIC DOMAIN NOTICE
6  * National Center for Biotechnology Information
7  *
8  * This software/database is a "United States Government Work" under the
9  * terms of the United States Copyright Act. It was written as part of
10  * the author's official duties as a United States Government employee and
11  * thus cannot be copyrighted. This software/database is freely available
12  * to the public for use. The National Library of Medicine and the U.S.
13  * Government have not placed any restriction on its use or reproduction.
14  *
15  * Although all reasonable efforts have been taken to ensure the accuracy
16  * and reliability of the software and data, the NLM and the U.S.
17  * Government do not and cannot warrant the performance or results that
18  * may be obtained by using this software or data. The NLM and the U.S.
19  * Government disclaim all warranties, express or implied, including
20  * warranties of performance, merchantability or fitness for any particular
21  * purpose.
22  *
23  * Please cite the author in any work or product based on this material.
24  *
25  * Db Cassandra: class generating execution plans for cassandra table fullscans.
26  *
27  */
28 
29 #ifndef OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__FULLSCAN__PLAN_HPP
30 #define OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__FULLSCAN__PLAN_HPP
31 
32 #include <corelib/ncbistl.hpp>
35 
36 #include <memory>
37 #include <vector>
38 #include <string>
39 
42 
44 {
45  public:
46  using TQueryPtr = shared_ptr<CCassQuery>;
47 
48  virtual TQueryPtr GetNextQuery() = 0;
49  virtual size_t GetQueryCount() const = 0;
50  virtual void Generate() = 0;
51  virtual ~ICassandraFullscanPlan() = default;
52 };
53 
55  : public ICassandraFullscanPlan
56 {
57  static const size_t kMinPartitionsForSubrangeScanDefault = 100'000;
58  public:
59  using TQueryPtr = shared_ptr<CCassQuery>;
60 
66 
67  virtual ~CCassandraFullscanPlan() = default;
68 
69  CCassandraFullscanPlan& SetConnection(shared_ptr<CCassConnection> connection);
70  CCassandraFullscanPlan& SetFieldList(vector<string> fields);
71  CCassandraFullscanPlan& SetWhereFilter(string const & where_filter);
73  CCassandraFullscanPlan& SetKeyspace(string const & keyspace);
74  CCassandraFullscanPlan& SetTable(string const & table);
75 
76  // If original schema token ranges contain too many records
77  // we could split them further to distribute workload more equally
78  // and reduce paging sub-queries count
81 
82  void Generate() override;
83  TQueryPtr GetNextQuery() override;
84  size_t GetQueryCount() const override;
85 
86  protected:
90  {
92  }
93 
94  private:
96 
97  shared_ptr<CCassConnection> m_Connection;
98  vector<string> m_FieldList{"*"};
99  string m_Keyspace;
100  string m_Table;
106 };
107 
109 
110 #endif // OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__FULLSCAN__PLAN_HPP
#define END_IDBLOB_SCOPE
Definition: IdCassScope.hpp:40
#define BEGIN_IDBLOB_SCOPE
Definition: IdCassScope.hpp:39
vector< pair< TTokenValue, TTokenValue > > TTokenRanges
int64_t GetPartitionCountPerQueryLimit() const
Definition: plan.hpp:89
CCassandraFullscanPlan & operator=(CCassandraFullscanPlan &&)=default
void SplitTokenRangesForLimits()
Definition: plan.cpp:233
CCassandraFullscanPlan & SetConnection(shared_ptr< CCassConnection > connection)
Definition: plan.cpp:117
CCassandraFullscanPlan & SetWhereFilter(string const &where_filter)
Definition: plan.cpp:129
void Generate() override
Definition: plan.cpp:293
size_t GetMinPartitionsForSubrangeScan()
Definition: plan.cpp:163
virtual ~CCassandraFullscanPlan()=default
CCassandraFullscanPlan & operator=(const CCassandraFullscanPlan &)=default
TQueryPtr GetNextQuery() override
Definition: plan.cpp:210
size_t m_MinPartitionsForSubrangeScan
Definition: plan.hpp:104
size_t GetPartitionCountEstimate()
Definition: plan.cpp:168
shared_ptr< CCassConnection > m_Connection
Definition: plan.hpp:97
size_t GetQueryCount() const override
Definition: plan.cpp:228
static const size_t kMinPartitionsForSubrangeScanDefault
Definition: plan.hpp:57
int64_t m_PartitionCountPerQueryLimit
Definition: plan.hpp:105
CCassandraFullscanPlan & SetTable(string const &table)
Definition: plan.cpp:147
CCassandraFullscanPlan & SetFieldList(vector< string > fields)
Definition: plan.cpp:123
CCassandraFullscanPlan(const CCassandraFullscanPlan &)=default
CCassandraFullscanPlan & SetMinPartitionsForSubrangeScan(size_t value)
Definition: plan.cpp:135
vector< string > m_FieldList
Definition: plan.hpp:98
CCassandraFullscanPlan & SetKeyspace(string const &keyspace)
Definition: plan.cpp:141
CCassandraFullscanPlan & SetPartitionCountPerQueryLimit(int64_t value)
Definition: plan.cpp:153
CCassConnection::TTokenRanges & GetTokenRanges()
Definition: plan.cpp:322
CCassConnection::TTokenRanges m_TokenRanges
Definition: plan.hpp:103
CCassandraFullscanPlan(CCassandraFullscanPlan &&)=default
shared_ptr< CCassQuery > TQueryPtr
Definition: plan.hpp:46
virtual void Generate()=0
virtual size_t GetQueryCount() const =0
virtual TQueryPtr GetNextQuery()=0
virtual ~ICassandraFullscanPlan()=default
char value[7]
Definition: config.c:431
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
The NCBI C++/STL use hints.
BEGIN_IDBLOB_SCOPE USING_NCBI_SCOPE
Definition: plan.hpp:41
signed __int64 int64_t
Definition: stdint.h:135
Modified on Mon Mar 04 05:13:14 2024 by modify_doxy.py rev. 669887