Skip to content

Commit

Permalink
db: rename kv Query to Request
Browse files Browse the repository at this point in the history
  • Loading branch information
battlmonstr committed Mar 6, 2025
1 parent c12dd00 commit f8a354e
Show file tree
Hide file tree
Showing 32 changed files with 439 additions and 439 deletions.
52 changes: 26 additions & 26 deletions cmd/dev/grpc_toolbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,12 +849,12 @@ int kv_seek() {
}

Task<void> kv_get_latest_query(const std::shared_ptr<Service>& kv_service,
GetLatestQuery&& query,
GetLatestRequest request,
const bool /*verbose*/) {
try {
auto tx = co_await kv_service->begin_transaction();
std::cout << "KV GetLatest -> " << query.table << " key=" << to_hex(query.key) << " latest=true\n";
const auto result = co_await tx->get_latest(std::move(query));
std::cout << "KV GetLatest -> " << request.table << " key=" << to_hex(request.key) << " latest=true\n";
const auto result = co_await tx->get_latest(std::move(request));
std::cout << "KV GetLatest <- success: " << result.success << " value=" << to_hex(result.value) << "\n";
co_await tx->close();
} catch (const std::exception& e) {
Expand All @@ -863,13 +863,13 @@ Task<void> kv_get_latest_query(const std::shared_ptr<Service>& kv_service,
}

Task<void> kv_get_as_of_query(const std::shared_ptr<Service>& kv_service,
GetAsOfQuery&& query,
GetAsOfRequest request,
const bool /*verbose*/) {
try {
auto tx = co_await kv_service->begin_transaction();
std::cout << "KV GetLatest -> " << query.table << " key=" << to_hex(query.key)
<< " ts=" << query.timestamp << " latest=false\n";
const auto result = co_await tx->get_as_of(std::move(query));
std::cout << "KV GetLatest -> " << request.table << " key=" << to_hex(request.key)
<< " ts=" << request.timestamp << " latest=false\n";
const auto result = co_await tx->get_as_of(std::move(request));
std::cout << "KV GetLatest <- success: " << result.success << " value=" << to_hex(result.value) << "\n";
co_await tx->close();
} catch (const std::exception& e) {
Expand All @@ -878,12 +878,12 @@ Task<void> kv_get_as_of_query(const std::shared_ptr<Service>& kv_service,
}

Task<void> kv_history_seek_query(const std::shared_ptr<Service>& kv_service,
HistoryPointQuery&& query,
HistoryPointRequest request,
const bool /*verbose*/) {
try {
auto tx = co_await kv_service->begin_transaction();
std::cout << "KV HistorySeek -> " << query.table << " key=" << to_hex(query.key) << " ts=" << query.timestamp << "\n";
const auto result = co_await tx->history_seek(std::move(query));
std::cout << "KV HistorySeek -> " << request.table << " key=" << to_hex(request.key) << " ts=" << request.timestamp << "\n";
const auto result = co_await tx->history_seek(std::move(request));
std::cout << "KV HistorySeek <- success: " << result.success << " value=" << to_hex(result.value) << "\n";
co_await tx->close();
} catch (const std::exception& e) {
Expand All @@ -892,12 +892,12 @@ Task<void> kv_history_seek_query(const std::shared_ptr<Service>& kv_service,
}

Task<void> kv_index_range_query(const std::shared_ptr<Service>& kv_service,
IndexRangeQuery&& query,
IndexRangeRequest request,
const bool verbose) {
try {
auto tx = co_await kv_service->begin_transaction();
std::cout << "KV IndexRange -> " << query.table << "\n";
auto paginated_result = co_await tx->index_range(std::move(query));
std::cout << "KV IndexRange -> " << request.table << "\n";
auto paginated_result = co_await tx->index_range(std::move(request));
auto it = co_await paginated_result.begin();
std::cout << "KV IndexRange <- #timestamps: ";
int count{0};
Expand All @@ -919,12 +919,12 @@ Task<void> kv_index_range_query(const std::shared_ptr<Service>& kv_service,
}

Task<void> kv_history_range_query(const std::shared_ptr<Service>& kv_service,
HistoryRangeQuery&& query,
HistoryRangeRequest request,
const bool verbose) {
try {
auto tx = co_await kv_service->begin_transaction();
std::cout << "KV HistoryRange -> " << query.table << " limit=" << query.limit << "\n";
auto paginated_result = co_await tx->history_range(std::move(query));
std::cout << "KV HistoryRange -> " << request.table << " limit=" << request.limit << "\n";
auto paginated_result = co_await tx->history_range(std::move(request));
auto it = co_await paginated_result.begin();
std::cout << "KV HistoryRange <- #keys and #values: ";
int count{0};
Expand All @@ -946,12 +946,12 @@ Task<void> kv_history_range_query(const std::shared_ptr<Service>& kv_service,
}

Task<void> kv_range_as_of_query(const std::shared_ptr<Service>& kv_service,
DomainRangeQuery&& query,
DomainRangeRequest request,
const bool verbose) {
try {
auto tx = co_await kv_service->begin_transaction();
std::cout << "KV RangeAsOf -> " << query.table << " limit=" << query.limit << "\n";
auto paginated_result = co_await tx->range_as_of(std::move(query));
std::cout << "KV RangeAsOf -> " << request.table << " limit=" << request.limit << "\n";
auto paginated_result = co_await tx->range_as_of(std::move(request));
auto it = co_await paginated_result.begin();
std::cout << "KV RangeAsOf <- #keys and #values: ";
int count{0};
Expand All @@ -973,7 +973,7 @@ Task<void> kv_range_as_of_query(const std::shared_ptr<Service>& kv_service,
}

template <typename Q>
using KVQueryFunc = Task<void> (*)(const std::shared_ptr<Service>&, Q&&, bool);
using KVQueryFunc = Task<void> (*)(const std::shared_ptr<Service>&, Q, bool);

template <typename Q>
int execute_temporal_kv_query(const std::string& target, KVQueryFunc<Q> query_func, Q&& query, const bool verbose) {
Expand Down Expand Up @@ -1050,14 +1050,14 @@ int kv_get_latest() {
const auto verbose{absl::GetFlag(FLAGS_verbose)};

if (timestamp > -1) {
GetAsOfQuery query{
GetAsOfRequest query{
.table = table_name,
.key = *key_bytes,
.timestamp = timestamp,
};
return execute_temporal_kv_query(target, kv_get_as_of_query, std::move(query), verbose);
}
GetLatestQuery query{
GetLatestRequest query{
.table = table_name,
.key = *key_bytes,
};
Expand Down Expand Up @@ -1096,7 +1096,7 @@ int kv_history_seek() {

const auto verbose{absl::GetFlag(FLAGS_verbose)};

HistoryPointQuery query{
HistoryPointRequest query{
.table = table_name,
.key = *key_bytes,
.timestamp = timestamp,
Expand Down Expand Up @@ -1136,7 +1136,7 @@ int kv_index_range() {

const auto verbose{absl::GetFlag(FLAGS_verbose)};

IndexRangeQuery query{
IndexRangeRequest query{
.table = table_name,
.key = *key_bytes,
.from_timestamp = 0,
Expand Down Expand Up @@ -1171,7 +1171,7 @@ int kv_history_range() {

const auto verbose{absl::GetFlag(FLAGS_verbose)};

HistoryRangeQuery query{
HistoryRangeRequest query{
.table = table_name,
.from_timestamp = 0,
.to_timestamp = -1,
Expand Down Expand Up @@ -1228,7 +1228,7 @@ int kv_get_as_of() {

const auto verbose{absl::GetFlag(FLAGS_verbose)};

DomainRangeQuery query{
DomainRangeRequest query{
.table = table_name,
.from_key = *from_key_bytes,
.to_key = *to_key_bytes,
Expand Down
14 changes: 7 additions & 7 deletions silkworm/db/kv/api/endpoint/temporal_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct PointResult {
Bytes value;
};

struct HistoryPointQuery {
struct HistoryPointRequest {
TxId tx_id{0};
std::string table;
Bytes key;
Expand All @@ -37,17 +37,17 @@ struct HistoryPointQuery {

using HistoryPointResult = PointResult;

struct GetLatestQuery {
struct GetLatestRequest {
TxId tx_id{0};
std::string table;
Bytes key;
Bytes sub_key;

// TODO(canepat) we need clang >= 17 to use spaceship operator instead of hand-made operator== below
// auto operator<=>(const GetLatestQuery&) const = default;
// auto operator<=>(const GetLatestRequest&) const = default;
};

inline bool operator==(const GetLatestQuery& lhs, const GetLatestQuery& rhs) {
inline bool operator==(const GetLatestRequest& lhs, const GetLatestRequest& rhs) {
return (lhs.tx_id == rhs.tx_id) &&
(lhs.table == rhs.table) &&
(lhs.key == rhs.key) &&
Expand All @@ -56,18 +56,18 @@ inline bool operator==(const GetLatestQuery& lhs, const GetLatestQuery& rhs) {

using GetLatestResult = PointResult;

struct GetAsOfQuery {
struct GetAsOfRequest {
TxId tx_id{0};
std::string table;
Bytes key;
Bytes sub_key;
Timestamp timestamp;

// TODO(canepat) we need clang >= 17 to use spaceship operator instead of hand-made operator== below
// auto operator<=>(const GetAsOfQuery&) const = default;
// auto operator<=>(const GetAsOfRequest&) const = default;
};

inline bool operator==(const GetAsOfQuery& lhs, const GetAsOfQuery& rhs) {
inline bool operator==(const GetAsOfRequest& lhs, const GetAsOfRequest& rhs) {
return (lhs.tx_id == rhs.tx_id) &&
(lhs.table == rhs.table) &&
(lhs.key == rhs.key) &&
Expand Down
10 changes: 5 additions & 5 deletions silkworm/db/kv/api/endpoint/temporal_range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ inline constexpr int64_t kUnlimited{-1};
//! Infinite timestamp value in range queries
inline constexpr Timestamp kInfinite{-1};

struct IndexRangeQuery {
struct IndexRangeRequest {
TxId tx_id{0};
std::string table;
Bytes key;
Expand All @@ -55,7 +55,7 @@ struct RangeResult {
std::string next_page_token;
};

struct HistoryRangeQuery {
struct HistoryRangeRequest {
TxId tx_id{0};
std::string table;
Timestamp from_timestamp;
Expand All @@ -66,10 +66,10 @@ struct HistoryRangeQuery {
std::string page_token;

// TODO(canepat) we need clang >= 17 to use spaceship operator instead of hand-made operator== below
// auto operator<=>(const HistoryRangeQuery&) const = default;
// auto operator<=>(const HistoryRangeRequest&) const = default;
};

inline bool operator==(const HistoryRangeQuery& lhs, const HistoryRangeQuery& rhs) {
inline bool operator==(const HistoryRangeRequest& lhs, const HistoryRangeRequest& rhs) {
return (lhs.tx_id == rhs.tx_id) &&
(lhs.table == rhs.table) &&
(lhs.from_timestamp == rhs.from_timestamp) &&
Expand All @@ -82,7 +82,7 @@ inline bool operator==(const HistoryRangeQuery& lhs, const HistoryRangeQuery& rh

using HistoryRangeResult = RangeResult;

struct DomainRangeQuery {
struct DomainRangeRequest {
TxId tx_id{0};
std::string table;
Bytes from_key;
Expand Down
Loading

0 comments on commit f8a354e

Please # to comment.