From d094af49c8b0e3829e0eb6f08572678c3a916940 Mon Sep 17 00:00:00 2001 From: cyan Date: Fri, 13 Dec 2024 18:06:28 +0000 Subject: [PATCH] Fix comments --- .../cassandra/CassandraMigrationBackend.hpp | 10 ++++++++-- src/migration/cassandra/impl/FullTableScanner.hpp | 2 ++ tests/common/util/MockMigrationBackend.hpp | 12 +----------- .../cassandra/CassandraMigrationTestBackend.hpp | 2 -- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/migration/cassandra/CassandraMigrationBackend.hpp b/src/migration/cassandra/CassandraMigrationBackend.hpp index f8223859b..1735a920f 100644 --- a/src/migration/cassandra/CassandraMigrationBackend.hpp +++ b/src/migration/cassandra/CassandraMigrationBackend.hpp @@ -69,8 +69,8 @@ class CassandraMigrationBackend : public data::cassandra::CassandraBackend { template void migrateInTokenRange( - std::int64_t const& start, - std::int64_t const& end, + std::int64_t const start, + std::int64_t const end, auto const& callback, boost::asio::yield_context yield ) @@ -84,6 +84,12 @@ class CassandraMigrationBackend : public data::cassandra::CassandraBackend { auto const statement = statementPrepared.bind(start, end); auto const res = this->executor_.read(yield, statement); + if (not res) { + LOG(log_.error()) << "Could not fetch data from table: " << TableDesc::TABLE_NAME << " range: " << start + << " - " << end << ";" << res.error(); + return; + } + auto const& results = res.value(); if (not results.hasRows()) { LOG(log_.debug()) << "No rows returned - table: " << TableDesc::TABLE_NAME << " range: " << start << " - " diff --git a/src/migration/cassandra/impl/FullTableScanner.hpp b/src/migration/cassandra/impl/FullTableScanner.hpp index e013c4a9a..4f24e0b67 100644 --- a/src/migration/cassandra/impl/FullTableScanner.hpp +++ b/src/migration/cassandra/impl/FullTableScanner.hpp @@ -85,6 +85,8 @@ class FullTableScanner { { auto const minValue = std::numeric_limits::min(); auto const maxValue = std::numeric_limits::max(); + if (numRanges_ == 1) + return {TokenRange{minValue, maxValue}}; // Safely calculate the range size using uint64_t to avoid overflow uint64_t rangeSize = (static_cast(maxValue) * 2) / numRanges_; diff --git a/tests/common/util/MockMigrationBackend.hpp b/tests/common/util/MockMigrationBackend.hpp index a35d60587..48c757b69 100644 --- a/tests/common/util/MockMigrationBackend.hpp +++ b/tests/common/util/MockMigrationBackend.hpp @@ -20,17 +20,7 @@ #pragma once #include "util/MockBackend.hpp" -#include "util/config/Config.hpp" - -#include -#include -#include -#include -#include -#include struct MockMigrationBackend : public MockBackend { - MockMigrationBackend(util::Config) : MockBackend(util::Config{}) - { - } + using MockBackend::MockBackend; }; diff --git a/tests/integration/migration/cassandra/CassandraMigrationTestBackend.hpp b/tests/integration/migration/cassandra/CassandraMigrationTestBackend.hpp index 024d2a264..53cdb5d37 100644 --- a/tests/integration/migration/cassandra/CassandraMigrationTestBackend.hpp +++ b/tests/integration/migration/cassandra/CassandraMigrationTestBackend.hpp @@ -60,8 +60,6 @@ class CassandraMigrationTestBackend : public migration::cassandra::CassandraMigr throw std::runtime_error("Could not create schema: " + res.error()); } - ~CassandraMigrationTestBackend() override = default; - /** * @brief Write a transaction hash and its transaction type to the tx_index_example table. It's used by * ExampleTransactionsMigrator.