raft: broadcast_tables: add definition of intermediate language
In broadcast tables, raft command contains a whole program to be executed. Sending and parsing on each node entire CQL statement is inefficient, thus we decided to compile it to an intermediate language which can be easily serializable. This patch adds a definition of such a language. For now, only the following types of statements can be compiled: * select value where key = CONST from system.broadcast_kv_store; * update system.broadcast_kv_store set value = CONST where key = CONST; * update system.broadcast_kv_store set value = CONST where key = CONST if value = CONST; where CONST is string literal.
This commit is contained in:
@@ -1151,6 +1151,7 @@ idls = ['idl/gossip_digest.idl.hh',
|
||||
'idl/replica_exception.idl.hh',
|
||||
'idl/per_partition_rate_limit_info.idl.hh',
|
||||
'idl/position_in_partition.idl.hh',
|
||||
'idl/experimental/broadcast_tables_lang.idl.hh',
|
||||
]
|
||||
|
||||
rusts = [
|
||||
|
||||
27
idl/experimental/broadcast_tables_lang.idl.hh
Normal file
27
idl/experimental/broadcast_tables_lang.idl.hh
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2022-present ScyllaDB
|
||||
*/
|
||||
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace service {
|
||||
namespace broadcast_tables {
|
||||
|
||||
struct select_query {
|
||||
bytes key;
|
||||
};
|
||||
|
||||
struct update_query {
|
||||
bytes key;
|
||||
bytes new_value;
|
||||
std::optional<bytes_opt> value_condition;
|
||||
};
|
||||
|
||||
struct query {
|
||||
std::variant<service::broadcast_tables::select_query, service::broadcast_tables::update_query> q;
|
||||
};
|
||||
|
||||
} // namespace broadcast_tables
|
||||
} // namespace service
|
||||
37
service/broadcast_tables/experimental/lang.hh
Normal file
37
service/broadcast_tables/experimental/lang.hh
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2022-present ScyllaDB
|
||||
*/
|
||||
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
|
||||
#include "bytes.hh"
|
||||
|
||||
|
||||
namespace service::broadcast_tables {
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
// Represents 'SELECT value WHERE key = {key} FROM system.broadcast_kv_store;'.
|
||||
struct select_query {
|
||||
bytes key;
|
||||
};
|
||||
|
||||
// Represents 'UPDATE system.broadcast_kv_store SET value = {new_value} WHERE key = {key} [IF value = {value_condition}];'.
|
||||
// If value_condition is nullopt, the update is unconditional.
|
||||
struct update_query {
|
||||
bytes key;
|
||||
bytes new_value;
|
||||
std::optional<bytes_opt> value_condition;
|
||||
};
|
||||
|
||||
struct query {
|
||||
std::variant<select_query, update_query> q;
|
||||
};
|
||||
|
||||
} // namespace service::broadcast_tables
|
||||
Reference in New Issue
Block a user