Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
FullTableScannerAdapterBase.hpp
1#pragma once
2
3#include "migration/cassandra/CassandraMigrationBackend.hpp"
4#include "migration/cassandra/impl/FullTableScanner.hpp"
5
6#include <boost/asio/spawn.hpp>
7
8#include <memory>
9#include <utility>
10
11namespace migration::cassandra::impl {
12
20template <TableSpec TableDesc>
22 static_assert(TableSpec<TableDesc>);
23
24protected:
28 std::shared_ptr<CassandraMigrationBackend> backend_;
29
30public:
31 virtual ~FullTableScannerAdapterBase() = default;
32
38 FullTableScannerAdapterBase(std::shared_ptr<CassandraMigrationBackend> backend)
39 : backend_(std::move(backend))
40 {
41 }
42
50 void
51 readByTokenRange(TokenRange const& range, boost::asio::yield_context yield)
52 {
53 backend_->migrateInTokenRange<TableDesc>(
54 range.start, range.end, [this](auto const& row) { onRowRead(row); }, yield
55 );
56 }
57
64 virtual void
65 onRowRead(TableDesc::Row const& row) = 0;
66};
67} // namespace migration::cassandra::impl
void readByTokenRange(TokenRange const &range, boost::asio::yield_context yield)
Read the row in the given token range from database, this is the adapt function for the FullTableScan...
Definition FullTableScannerAdapterBase.hpp:51
FullTableScannerAdapterBase(std::shared_ptr< CassandraMigrationBackend > backend)
Construct a new Full Table Scanner Adapter Base object.
Definition FullTableScannerAdapterBase.hpp:38
std::shared_ptr< CassandraMigrationBackend > backend_
The backend to use.
Definition FullTableScannerAdapterBase.hpp:28
virtual void onRowRead(TableDesc::Row const &row)=0
Called when a row is read. The derived class should implement this function to convert the database b...
The token range used to split the full table scan into multiple ranges.
Definition FullTableScanner.hpp:23