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

Go to the SVN repository for this file.

1 /*****************************************************************************
2  * $Id: consumer.hpp 100970 2023-10-06 14:32:13Z 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: interface of cassandra fullscan record consumer.
26  *
27  */
28 
29 #ifndef OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__FULLSCAN__CONSUMER_HPP
30 #define OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__FULLSCAN__CONSUMER_HPP
31 
32 #include <corelib/ncbistl.hpp>
33 
36 
37 #include <memory>
38 #include <functional>
39 #include <string>
40 
43 
45  eOnePerThread = 0,
46  eOnePerQuery = 1,
47 };
48 
50 {
51  public:
52  // Called for every iteration
53  // @return false to stop processing
54  virtual bool Tick()
55  {
56  return true;
57  };
58 
59  // Override to handle segment Query restarts
60  virtual void OnQueryRestart() {};
61 
62  // Called for every row
63  // @return false to stop processing
64  virtual bool ReadRow(CCassQuery const & query) = 0;
65 
66  // Called once before consumer destruction
67  virtual void Finalize() = 0;
68 
69  virtual ~ICassandraFullscanConsumer() = default;
70 };
71 
72 using TCassandraFullscanConsumerFactory = function<unique_ptr<ICassandraFullscanConsumer>()>;
73 
75 
76 #endif // OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__FULLSCAN__CONSUMER_HPP
#define END_IDBLOB_SCOPE
Definition: IdCassScope.hpp:40
#define BEGIN_IDBLOB_SCOPE
Definition: IdCassScope.hpp:39
virtual ~ICassandraFullscanConsumer()=default
virtual void OnQueryRestart()
Definition: consumer.hpp:60
virtual void Finalize()=0
virtual bool ReadRow(CCassQuery const &query)=0
function< unique_ptr< ICassandraFullscanConsumer >()> TCassandraFullscanConsumerFactory
Definition: consumer.hpp:72
ECassandraFullscanConsumerPolicy
Definition: consumer.hpp:44
BEGIN_IDBLOB_SCOPE USING_NCBI_SCOPE
Definition: consumer.hpp:42
The NCBI C++/STL use hints.
static string query
Modified on Fri Sep 20 14:57:35 2024 by modify_doxy.py rev. 669887