Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
CassandraMigrationSchema.hpp
1
#pragma once
2
3
#include "data/cassandra/Handle.hpp"
4
#include "data/cassandra/Schema.hpp"
5
#include "data/cassandra/SettingsProvider.hpp"
6
#include "data/cassandra/Types.hpp"
7
8
#include <fmt/format.h>
9
10
#include <functional>
11
#include <string>
12
13
namespace
migration::cassandra::impl {
14
19
class
CassandraMigrationSchema
{
20
using
SettingsProviderType =
data::cassandra::SettingsProvider
;
21
std::reference_wrapper<SettingsProviderType const> settingsProvider_;
22
23
public
:
29
explicit
CassandraMigrationSchema
(SettingsProviderType
const
& settings)
30
: settingsProvider_{settings}
31
{
32
}
33
42
data::cassandra::PreparedStatement
43
getPreparedFullScanStatement
(
44
data::cassandra::Handle
const
& handler,
45
std::string
const
& tableName,
46
std::string
const
& key
47
)
48
{
49
return
handler.
prepare
(
50
fmt::format(
51
R
"(
52
SELECT *
53
FROM {}
54
WHERE TOKEN({}) >= ? AND TOKEN({}) <= ?
55
)",
56
data::cassandra::qualifiedTableName<SettingsProviderType>
(
57
settingsProvider_.get(), tableName
58
),
59
key,
60
key
61
)
62
);
63
}
64
68
* @param handler The database handler
69
* @return The prepared statement to insert into migrator_status table
70
*/
71
data::cassandra::PreparedStatement
const
&
72
getPreparedInsertMigratedMigrator
(
data::cassandra::Handle
const
& handler)
73
{
74
static
auto
const
kPrepared = handler.
prepare
(
75
fmt::format(
76
R
"(
77
INSERT INTO {}
78
(migrator_name, status)
79
VALUES (?, ?)
80
)",
81
data::cassandra::qualifiedTableName<SettingsProviderType>
(
82
settingsProvider_.get(),
"migrator_status"
83
)
84
)
85
);
86
return
kPrepared;
87
}
88
};
89
}
// namespace migration::cassandra::impl
data::cassandra::Handle
Represents a handle to the cassandra database cluster.
Definition
Handle.hpp:27
data::cassandra::Handle::prepare
PreparedStatementType prepare(std::string_view query) const
Prepare a statement.
Definition
Handle.cpp:149
data::cassandra::SettingsProvider
Provides settings for BasicCassandraBackend.
Definition
SettingsProvider.hpp:17
migration::cassandra::impl::CassandraMigrationSchema::getPreparedFullScanStatement
data::cassandra::PreparedStatement getPreparedFullScanStatement(data::cassandra::Handle const &handler, std::string const &tableName, std::string const &key)
Get the prepared statement for the full scan of a table.
Definition
CassandraMigrationSchema.hpp:43
migration::cassandra::impl::CassandraMigrationSchema::getPreparedInsertMigratedMigrator
data::cassandra::PreparedStatement const & getPreparedInsertMigratedMigrator(data::cassandra::Handle const &handler)
Get the prepared statement for insertion of migrator_status table.
Definition
CassandraMigrationSchema.hpp:68
migration::cassandra::impl::CassandraMigrationSchema::CassandraMigrationSchema
CassandraMigrationSchema(SettingsProviderType const &settings)
Construct a new Cassandra Migration Schema object.
Definition
CassandraMigrationSchema.hpp:29
data::cassandra::qualifiedTableName
std::string qualifiedTableName(SettingsProviderType const &provider, std::string_view name)
Returns the table name qualified with the keyspace and table prefix.
Definition
Schema.hpp:27
src
migration
cassandra
impl
CassandraMigrationSchema.hpp
Generated by
1.17.0