#include "binding.hpp"
#include "rust_callbacks.hpp"
static Cost_estimate make_cost(double io, double cpu, double import, double mem) {
Cost_estimate cost;
cost.add_io(io);
cost.add_cpu(cpu);
cost.add_import(import);
cost.add_mem(mem);
return cost;
}
double RustHandlerBase::scan_time() {
if (rust_ctx_) {
double v = 0;
if (rust__handler__scan_time(rust_ctx_, &v)) return v;
}
return handler::scan_time();
}
double RustHandlerBase::read_time(uint index, uint ranges, ha_rows rows) {
if (rust_ctx_) {
double v = 0;
if (rust__handler__read_time(rust_ctx_, index, ranges, rows, &v)) return v;
}
return handler::read_time(index, ranges, rows);
}
double RustHandlerBase::index_only_read_time(uint keynr, double records) {
if (rust_ctx_) {
double v = 0;
if (rust__handler__index_only_read_time(rust_ctx_, keynr, records, &v))
return v;
}
return handler::index_only_read_time(keynr, records);
}
Cost_estimate RustHandlerBase::table_scan_cost() {
if (rust_ctx_) {
double io = 0, cpu = 0, import = 0, mem = 0;
if (rust__handler__table_scan_cost(rust_ctx_, &io, &cpu, &import, &mem))
return make_cost(io, cpu, import, mem);
}
return handler::table_scan_cost();
}
Cost_estimate RustHandlerBase::index_scan_cost(uint index, double ranges,
double rows) {
if (rust_ctx_) {
double io = 0, cpu = 0, import = 0, mem = 0;
if (rust__handler__index_scan_cost(rust_ctx_, index, ranges, rows, &io,
&cpu, &import, &mem))
return make_cost(io, cpu, import, mem);
}
return handler::index_scan_cost(index, ranges, rows);
}
Cost_estimate RustHandlerBase::read_cost(uint index, double ranges,
double rows) {
if (rust_ctx_) {
double io = 0, cpu = 0, import = 0, mem = 0;
if (rust__handler__read_cost(rust_ctx_, index, ranges, rows, &io, &cpu,
&import, &mem))
return make_cost(io, cpu, import, mem);
}
return handler::read_cost(index, ranges, rows);
}
double RustHandlerBase::page_read_cost(uint index, double reads) {
if (rust_ctx_) {
double v = 0;
if (rust__handler__page_read_cost(rust_ctx_, index, reads, &v)) return v;
}
return handler::page_read_cost(index, reads);
}
double RustHandlerBase::worst_seek_times(double reads) {
if (rust_ctx_) {
double v = 0;
if (rust__handler__worst_seek_times(rust_ctx_, reads, &v)) return v;
}
return handler::worst_seek_times(reads);
}