Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cindyyan317 committed Dec 13, 2024
1 parent 17f6db7 commit d094af4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
10 changes: 8 additions & 2 deletions src/migration/cassandra/CassandraMigrationBackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class CassandraMigrationBackend : public data::cassandra::CassandraBackend {
template <impl::TableSpec TableDesc>
void
migrateInTokenRange(

Check warning on line 71 in src/migration/cassandra/CassandraMigrationBackend.hpp

View check run for this annotation

Codecov / codecov/patch

src/migration/cassandra/CassandraMigrationBackend.hpp#L71

Added line #L71 was not covered by tests
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
)
Expand All @@ -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;

Check warning on line 90 in src/migration/cassandra/CassandraMigrationBackend.hpp

View check run for this annotation

Codecov / codecov/patch

src/migration/cassandra/CassandraMigrationBackend.hpp#L90

Added line #L90 was not covered by tests
}

auto const& results = res.value();
if (not results.hasRows()) {
LOG(log_.debug()) << "No rows returned - table: " << TableDesc::TABLE_NAME << " range: " << start << " - "
Expand Down
2 changes: 2 additions & 0 deletions src/migration/cassandra/impl/FullTableScanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class FullTableScanner {
{
auto const minValue = std::numeric_limits<std::int64_t>::min();
auto const maxValue = std::numeric_limits<std::int64_t>::max();
if (numRanges_ == 1)
return {TokenRange{minValue, maxValue}};

// Safely calculate the range size using uint64_t to avoid overflow
uint64_t rangeSize = (static_cast<uint64_t>(maxValue) * 2) / numRanges_;
Expand Down
12 changes: 1 addition & 11 deletions tests/common/util/MockMigrationBackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,7 @@
#pragma once

#include "util/MockBackend.hpp"
#include "util/config/Config.hpp"

#include <boost/asio/spawn.hpp>
#include <boost/json/object.hpp>
#include <gmock/gmock.h>
#include <xrpl/basics/base_uint.h>
#include <xrpl/protocol/AccountID.h>
#include <xrpl/protocol/LedgerHeader.h>

struct MockMigrationBackend : public MockBackend {
MockMigrationBackend(util::Config) : MockBackend(util::Config{})
{
}
using MockBackend::MockBackend;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d094af4

Please sign in to comment.