Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions modules/util/dump/ddl_dumper_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ const shcore::Option_pack_def<Ddl_dumper_options>
.optional("checksum", &Ddl_dumper_options::m_checksum)
.optional("lakehouseTarget",
&Ddl_dumper_options::set_lakehouse_target)
.optional("maxKeyPrefixLength",
&Ddl_dumper_options::set_max_key_prefix_len)
.optional("adaptiveStepStrategy",
&Ddl_dumper_options::set_adaptive_step_strategy)
.on_done(&Ddl_dumper_options::on_unpacked_options);

return opts;
Expand Down Expand Up @@ -207,6 +211,42 @@ void Ddl_dumper_options::set_threads(uint64_t threads) {
m_worker_threads = threads;
}

void Ddl_dumper_options::set_max_key_prefix_len(const size_t &value) {
if (!split()) {
throw std::invalid_argument(
"The option 'maxKeyPrefixLength' cannot be used if the 'chunking' "
"option is set to false.");
}

m_max_key_prefix_len = value;
}

static AdaptiveStepStrategy to_adaptive_step_strategy(
const std::string &option) {
if (option == "enhanced") {
return AdaptiveStepStrategy::ENHANCED;
} else if (option == "original") {
return AdaptiveStepStrategy::ORIGINAL;
}
throw std::invalid_argument(
"Invalid value for 'adaptiveStepStrategy' option: " + option);
}

void Ddl_dumper_options::set_adaptive_step_strategy(const std::string &value) {
if (value.empty()) {
throw std::invalid_argument(
"The option 'adaptiveStepStrategy' cannot be set to an empty string.");
}

if (!split()) {
throw std::invalid_argument(
"The option 'adaptiveStepStrategy' cannot be used if the 'chunking' "
"option is set to false.");
}

m_adaptive_step_strategy = to_adaptive_step_strategy(value);
}

void Ddl_dumper_options::on_set_url(
const std::string &url, Storage_type storage,
const mysqlshdk::storage::Config_ptr &config) {
Expand Down
14 changes: 14 additions & 0 deletions modules/util/dump/ddl_dumper_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class Ddl_dumper_options : public Dump_options {

bool checksum() const override { return m_checksum; }

AdaptiveStepStrategy adaptive_step_strategy() const override {
return m_adaptive_step_strategy;
}

size_t max_key_prefix_length() const override { return m_max_key_prefix_len; }

void enable_mds_compatibility_checks();

using Dump_options::set_compatibility_option;
Expand All @@ -106,6 +112,8 @@ class Ddl_dumper_options : public Dump_options {
void set_target_version_str(const std::string &value);
void set_dry_run(bool dry_run);
void set_threads(uint64_t threads);
void set_max_key_prefix_len(const size_t &value);
void set_adaptive_step_strategy(const std::string &value);

bool m_split = true;
uint64_t m_bytes_per_chunk;
Expand All @@ -126,6 +134,12 @@ class Ddl_dumper_options : public Dump_options {
bool m_skip_consistency_checks = false;
bool m_skip_upgrade_checks = false;
bool m_checksum = false;

// max nesting depth for composite keys
size_t m_max_key_prefix_len = 1;

AdaptiveStepStrategy m_adaptive_step_strategy =
AdaptiveStepStrategy::ORIGINAL;
};

} // namespace dump
Expand Down
2 changes: 2 additions & 0 deletions modules/util/dump/decimal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Decimal::Decimal(const std::string &d) {
}
}

Decimal::Decimal(std::int64_t value) : m_decimal(value) {}

std::string Decimal::to_string() const {
auto str = m_decimal.to_string();

Expand Down
8 changes: 8 additions & 0 deletions modules/util/dump/decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class Decimal final {
public:
explicit Decimal(const std::string &d);

/** Integer value with no fractional digits (e.g. generic chunking code). */
explicit Decimal(std::int64_t value);

Decimal(const Decimal &other) = default;
Decimal(Decimal &&other) = default;

Expand All @@ -77,6 +80,11 @@ class Decimal final {
Decimal &operator*=(const Decimal &rhs);
Decimal &operator/=(const Decimal &rhs);

inline Decimal &operator=(shcore::Bignum rhs) {
m_decimal = shcore::Bignum(rhs);
return *this;
}

inline Decimal &operator+=(shcore::Bignum rhs) {
*this += convert(std::move(rhs));
return *this;
Expand Down
1 change: 0 additions & 1 deletion modules/util/dump/dump_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ void Dump_options::set_string_option(const std::string &option,
throw std::invalid_argument(
"The option 'compression' cannot be set to an empty string.");
}

m_compression =
mysqlshdk::storage::to_compression(value, &m_compression_options);
} else {
Expand Down
9 changes: 9 additions & 0 deletions modules/util/dump/dump_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ enum class Dry_run {
DONT_WRITE_ANY_FILES,
};

enum class AdaptiveStepStrategy {
ORIGINAL,
ENHANCED,
};

class Dump_options : public mysqlsh::common::Common_options {
public:
using Filtering_options = mysqlshdk::db::Filtering_options;
Expand Down Expand Up @@ -158,6 +163,10 @@ class Dump_options : public mysqlsh::common::Common_options {

void set_report_dump_option(bool value) { m_report_dump_option = value; }

virtual AdaptiveStepStrategy adaptive_step_strategy() const = 0;

virtual size_t max_key_prefix_length() const = 0;

virtual bool split() const = 0;

virtual uint64_t bytes_per_chunk() const = 0;
Expand Down
Loading