 |
SWC-DB
v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
|
Go to the documentation of this file.
13 namespace SWC {
namespace client {
namespace SQL {
17 static const char TOKEN_SELECT[] =
"select";
18 static const uint8_t LEN_SELECT = 6;
19 static const char TOKEN_DUMP[] =
"dump";
20 static const uint8_t LEN_DUMP = 4;
21 static const char TOKEN_WHERE[] =
"where";
22 static const uint8_t LEN_WHERE = 5;
23 static const char TOKEN_COL[] =
"col";
24 static const uint8_t LEN_COL = 3;
25 static const char TOKEN_CELLS[] =
"cells";
26 static const uint8_t LEN_CELLS = 5;
29 static const char TOKEN_RANGE[] =
"range";
30 static const uint8_t LEN_RANGE = 5;
31 static const char TOKEN_KEY[] =
"key";
32 static const uint8_t LEN_KEY = 3;
33 static const char TOKEN_VALUE[] =
"value";
34 static const uint8_t LEN_VALUE = 5;
35 static const char TOKEN_TIMESTAMP[] =
"timestamp";
36 static const uint8_t LEN_TIMESTAMP = 9;
37 static const char TOKEN_OFFSET_KEY[] =
"offset_key";
38 static const uint8_t LEN_OFFSET_KEY = 10;
39 static const char TOKEN_OFFSET_REV[] =
"offset_rev";
40 static const uint8_t LEN_OFFSET_REV = 10;
41 static const char TOKEN_RANGE_END_REST[] =
"range_end_rest";
42 static const uint8_t LEN_RANGE_END_REST = 14;
44 static const char TOKEN_LIMIT[] =
"limit";
45 static const uint8_t LEN_LIMIT = 5;
46 static const char TOKEN_OFFSET[] =
"offset";
47 static const uint8_t LEN_OFFSET = 6;
48 static const char TOKEN_MAX_VERS[] =
"max_versions";
49 static const uint8_t LEN_MAX_VERS = 12;
50 static const char TOKEN_MAX_BUFF[] =
"max_buffer";
51 static const uint8_t LEN_MAX_BUFF = 10;
52 static const char TOKEN_ONLY_DELETES[] =
"only_deletes";
53 static const uint8_t LEN_ONLY_DELETES = 12;
54 static const char TOKEN_ONLY_KEYS[] =
"only_keys";
55 static const uint8_t LEN_ONLY_KEYS = 9;
57 static const char TOKEN_DELETE_MATCHING[] =
"delete_matching";
58 static const uint8_t LEN_DELETE_MATCHING = 15;
64 std::string& a_message)
65 :
Reader(a_sql, a_message),
66 clients(a_clients), specs(a_specs) {
71 bool token_cmd =
false;
72 bool token_where =
false;
74 while(
remain && !
err && (!token_cmd || !token_where)) {
95 for(
auto& intval : col) {
96 if(!intval->flags.was_set)
106 uint64_t& split_size,
107 std::string& ext,
int& level) {
108 bool token_cmd =
false;
109 bool token_col =
false;
125 if(!
err && buff.empty())
150 if(!
err && fs.empty())
169 if(!
err && n.empty())
189 if(!
err && ext.empty())
286 bool token_col =
false;
287 bool bracket_round =
false;
289 bool col_names_set =
false;
290 bool processed =
false;
291 bool possible_and =
false;
294 std::string col_name;
302 possible_and =
false;
312 if(token_col && !col_names_set) {
338 bracket_round =
false;
339 col_names_set =
true;
353 if(!col_name.empty()) {
376 bracket_round =
false;
387 col_names_set =
false;
388 bracket_round =
false;
403 if(schema->cid == col.cid)
416 for(
auto& schema : schemas) {
419 if(schema->cid == it->cid)
429 bool token_cells =
false;
430 bool bracket_round =
false;
432 bool processed =
false;
433 bool possible_and =
false;
440 possible_and =
false;
460 bool value_except =
false;
461 auto col_type = cols.
front()->col_type;
462 for(
auto& schema : cols) {
463 if(col_type != schema->col_type) {
472 for(
auto& schema : cols) {
473 if(col.cid == schema->cid)
478 bracket_round =
false;
488 bracket_round =
false;
500 bool quote_1 =
false;
501 bool quote_2 =
false;
502 bool is_quoted =
false;
503 bool possible_and =
false;
504 bool found_any =
false;
505 bool flw_and =
false;
506 uint32_t base_remain =
remain;
507 const char* base_rptr =
ptr;
516 possible_and =
false;
525 }
else if(escape && escape !=
remain)
531 is_quoted = quote_1 || quote_2;
547 if(
found_token(TOKEN_RANGE_END_REST, LEN_RANGE_END_REST))
576 if(
found_token(TOKEN_OFFSET_KEY, LEN_OFFSET_KEY)) {
583 if(
found_token(TOKEN_OFFSET_REV, LEN_OFFSET_REV)) {
615 }
else if(
found_token(TOKEN_DELETE_MATCHING, LEN_DELETE_MATCHING)) {
624 uint32_t base_remain =
remain;
625 const char* base_ptr =
ptr;
642 uint32_t mark_remain =
remain;
643 const char* mark_ptr =
ptr;
645 uint32_t remain_start =
sql.length()+1;
647 ptr = base_ptr - LEN_RANGE;
683 if(comp_left == comp_right) {
693 bool flw, uint8_t& options) {
694 uint32_t base_remain =
remain;
695 const char* base_ptr =
ptr;
718 uint32_t mark_remain =
remain;
719 const char* mark_ptr =
ptr;
721 uint32_t remain_start =
sql.length()+1;
723 ptr = base_ptr - LEN_KEY;
759 if(comp_right == comp_left) {
770 bool bracket_square =
false;
776 std::string fraction;
784 read(fraction,
",]");
785 key.
add(std::move(fraction), comp);
805 "unsupported 'comparator' allowed EQ, NE");
807 bool bracket_square =
false;
882 "unsupported 'comparator' allowed EQ");
894 fields.
add(std::move(field));
913 auto& item = field->items.emplace_back();
920 field->items.pop_back();
923 item.value = std::stoll(buff);
926 " signed 64-bit integer out of range");
935 fields.
add(std::move(field));
951 auto& item = field->items.emplace_back();
957 if(item.value.empty())
958 field->items.pop_back();
968 fields.
add(std::move(field));
988 case DB::Types::Column::COUNTER_I64:
989 case DB::Types::Column::COUNTER_I32:
990 case DB::Types::Column::COUNTER_I16:
991 case DB::Types::Column::COUNTER_I8: {
996 read(buf,
nullptr,
false);
1016 uint32_t base_remain =
remain;
1017 const char* base_ptr =
ptr;
1029 "unsupported 'comparator' allowed NE|EQ|GE|GT|LE|LT"
1046 start.
set(ts, comp_right);
1048 finish.
set(ts, comp_right);
1053 uint32_t mark_remain =
remain;
1054 const char* mark_ptr =
ptr;
1056 uint32_t end =
sql.length()+1;
1058 ptr = base_ptr - LEN_TIMESTAMP;
1093 "unsupported 'comparator' allowed GE|GT|LE|LT"
1103 if(comp_left == comp_right) {
1109 start.
set(ts, comp_left);
1111 finish.
set(ts, comp_left);
1129 if((any =
found_token(TOKEN_OFFSET, LEN_OFFSET))) {
1134 if((any =
found_token(TOKEN_MAX_VERS, LEN_MAX_VERS))) {
1139 if((any =
found_token(TOKEN_MAX_BUFF, LEN_MAX_BUFF))) {
1145 if((any =
found_token(TOKEN_ONLY_DELETES, LEN_ONLY_DELETES))) {
1146 flags.set_only_deletes();
1147 flags.was_set =
true;
1150 if((any =
found_token(TOKEN_ONLY_KEYS, LEN_ONLY_KEYS))) {
1151 flags.set_only_keys();
1152 flags.was_set =
true;
1173 bool bracket_round =
false;
1197 cell.
value =
nullptr;
static SWC_CAN_INLINE Field::Ptr make(uint24_t fid, Condition::Comp comp, const long double &value)
constexpr SWC_CAN_INLINE reference front() noexcept
constexpr SWC_CAN_INLINE int code() const noexcept
KeyIntervals key_intervals
static constexpr const uint8_t OPT_KEY_EQUAL
void read_key(DB::Specs::Key &start, DB::Specs::Key &finish, bool flw, uint8_t &options)
void expect_token(const char *token, uint8_t token_len, bool &found)
std::shared_ptr< Schema > Ptr
void add(Field::Ptr &&field)
SWC_CAN_INLINE void clear() noexcept(_NoExceptDestructor)
SWC_CAN_INLINE void set(const char *data_n, Condition::Comp comp_n, bool owner)
void read_ts_and_value(DB::Types::Column col_type, bool require_ts, DB::Cells::Cell &cell, DB::Types::Encoder *encoder, bool w_serial=false)
static constexpr const uint8_t REPLACE
KeySeq SWC_PURE_FUNC range_seq_from(const std::string &typ) noexcept
static constexpr const uint8_t SERIAL
const uint COMP_EXTENDED_VALUE
void read_uint64_t(uint64_t &value, bool &was_set, const char *stop=nullptr)
void read_column_tags(DB::Schemas::TagsPattern &tags)
const uint COMP_EXTENDED_KEY
DB::Schema::Ptr add_column(const std::string &col)
SWC_CAN_INLINE bool eq(const uint8_t *p1, uint32_t p1_len, const uint8_t *p2, uint32_t p2_len) noexcept
static SWC_CAN_INLINE std::unique_ptr< Field_KEY > make(uint24_t fid, Types::KeySeq seq)
SWC_CAN_INLINE uint8_t get_op() const noexcept
bool found_comparator(Condition::Comp &comp, uint8_t extended=0x00)
void read_range(DB::Cell::Key &begin, DB::Cell::Key &end, bool flw)
void read_int64_t(int64_t &value, bool &was_set, const char *stop=nullptr)
void read_value(DB::Types::Column col_type, DB::Specs::Value &value)
bool found_char(const char c)
bool is_numeric_comparator(Condition::Comp &comp, bool _double=false)
constexpr SWC_CAN_INLINE bool empty() const noexcept
DB::Schema::Ptr get_schema(const Clients::Ptr &clients, const std::string &col)
void read_double_t(long double &value, bool &was_set, const char *stop=nullptr)
void read(std::string &buf, const char *stop=nullptr, bool keep_escape=false)
void expect_comparator(Condition::Comp &comp, uint8_t extended=0x00)
void read_key(DB::Cell::Key &key)
#define SWC_CURRENT_EXCEPTION(_msg_)
The SWC-DB C++ namespace 'SWC'.
int64_t parse_ns(int &err, const std::string &buf)
void read_timestamp(DB::Specs::Timestamp &start, DB::Specs::Timestamp &finish, bool flw)
static SWC_CAN_INLINE Field::Ptr make(uint24_t fid, Condition::Comp comp, int64_t value)
void parse_display_flags(uint8_t &display_flags)
bool found_quote_double(bool "e)
static SWC_CAN_INLINE std::unique_ptr< Field_LIST_BYTES > make(uint24_t fid, Condition::Comp comp)
void from_string(const char *s, double *value)
bool found_token(const char *token, uint8_t token_len)
constexpr SWC_CAN_INLINE void set_opt__range_end_rest() noexcept
static SWC_CAN_INLINE Ptr make_ptr(Types::Column col_type=Types::Column::UNKNOWN)
static SWC_CAN_INLINE std::unique_ptr< Field_LIST_INT64 > make(uint24_t fid, Condition::Comp comp)
bool found_quote_single(bool "e)
DB::Cell::Serial::Value::Type read_serial_value_type()
IntervalUpdate::Ptr updating
void read_cells_intervals(const DB::SchemasVec &cols)
Fraction & add(Fraction &&other)
void read_operation(const DB::Types::Column col_type, DB::Specs::UpdateOP &operation)
constexpr SWC_CAN_INLINE int64_t get_timestamp() const noexcept
void read_column(const char *stop, std::string &col_name, DB::Schemas::NamePatterns &names)
Value & add(Condition::Comp comp=Condition::EQ)
constexpr SWC_CAN_INLINE const_iterator cend() const noexcept
void read_update(DB::Specs::Interval &intval)
std::string filepath(cid_t cid)
constexpr SWC_CAN_INLINE void set_timestamp_null() noexcept
constexpr SWC_CAN_INLINE void set_opt__deleting() noexcept
QuerySelect(const Clients::Ptr &clients, const std::string &sql, DB::Specs::Scan &specs, std::string &message)
void read_flags(DB::Specs::Flags &flags)
void error_msg(int error, const std::string &msg)
SWC_CAN_INLINE void push_back(ArgsT &&... args)
void read_cells_interval(DB::Specs::Interval &spec, bool value_except)
constexpr SWC_CAN_INLINE const_iterator cbegin() const noexcept
int parse_dump(std::string &fs, std::string &filepath, uint64_t &split_size, std::string &ext, int &level)
virtual SWC_CAN_INLINE const char * what() const noexcept override
void read_uint32_t(uint32_t &value, bool &was_set, const char *stop=nullptr)
void read_columns_intervals()
static SWC_CAN_INLINE Ptr make(ArgsT &&... args)
SWC_CAN_INLINE reference emplace_back(ArgsT &&... args)
static SWC_CAN_INLINE Field::Ptr make(uint24_t fid, Condition::Comp comp, const uint8_t *ptr, size_t len)
constexpr SWC_CAN_INLINE void set(int64_t timestamp, Condition::Comp comperator) noexcept
void parse_output_flags(uint8_t &output_flags)
void encode(Specs::Value &value) const