 |
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.
11 namespace SWC {
namespace client {
namespace SQL {
15 : sql(a_sql), message(a_message),
101 if(std::isdigit(*
ptr)) {
138 const std::string& col) {
140 if(std::find_if(col.cbegin(), col.cend(),
141 [](
unsigned char c){ return !std::isdigit(c); } ) != col.cend()){
142 schema = clients->get_schema(
err, col);
145 schema = clients->get_schema(
err, std::stoull(col));
152 error_msg(
err,
"problem getting column '"+col+
"' schema");
159 auto schemas = clients->get_schema(
err, patterns);
161 std::string msg(
"problem getting columns schema on patterns");
163 msg.append(
" names=[");
164 for(
auto& p : patterns.
names) {
166 msg.append(
"'" + p +
"', ");
174 for(
auto& p : patterns.
tags) {
176 msg.append(
"'" + p +
"', ");
185 void Reader::read(std::string& buf,
const char* stop,
bool keep_escape) {
187 bool quote_1 =
false;
188 bool quote_2 =
false;
189 bool is_quoted =
false;
190 bool was_quoted =
false;
193 if(!escape && *
ptr ==
'\\') {
200 }
else if(escape && escape !=
remain)
208 is_quoted = quote_1 || quote_2;
212 if((was_quoted && !is_quoted) ||
226 if (!was_set || v > UINT8_MAX || v < INT8_MIN)
235 if (!was_set || v > UINT16_MAX || v < INT16_MIN)
253 if (!was_set || v > UINT32_MAX || v < INT32_MIN)
261 read(buf, stop ? stop :
"),]");
264 value = std::stoll(buf);
276 read(buf, stop ? stop :
"),]");
280 value = std::stoull(buf);
292 read(buf, stop ? stop :
"),]");
296 value = std::stold(buf);
306 read(buf, stop ? stop :
"),]");
309 value = std::stoull(buf.c_str(), &pos);
311 if(pos == buf.size())
313 const char* p = buf.c_str() + pos;
315 value *= 60 * 60 * 24 * 7;
317 value *= 60 * 60 * 24;
365 bool bracket_square =
false;
366 std::string fraction;
375 read(fraction,
",]");
399 "unsupported numeric 'comparator' PF,RE,POSBS,POSPS");
406 "unsupported double numeric 'comparator' FOSPS,FOSBS");
434 std::string(
"unsupported 'comparator' ") +
468 std::string& col_name,
474 if(col_name.empty()) {
477 "expected column name(expression) after comparator"
531 if(
err || (require_ts && buf.empty())) {
542 case DB::Types::Column::PLAIN: {
571 bool bracket_square =
false;
609 wfields.
add(&ufield);
627 wfields.
add(&ufield);
645 wfields.
add(fid, buf);
647 wfields.
add(&ufield);
657 wfields.
add(fid, fkey);
695 "unsupported 'comparator' RE|PF"
713 wfields.
add(fid, items);
715 wfields.
add(&ufield);
750 auto& uitem = ufield.
add_item(comp);
753 if(uitem.is_value_set() &&
757 "unsupported 'comparator' RE|PF for set-value"
773 wfields.
add(fid, items);
775 wfields.
add(&ufield);
809 case DB::Types::Column::COUNTER_I64:
810 case DB::Types::Column::COUNTER_I32:
811 case DB::Types::Column::COUNTER_I16:
812 case DB::Types::Column::COUNTER_I8: {
818 const uint8_t* valp =
reinterpret_cast<const uint8_t*
>(value.c_str());
819 size_t _remain = value.length();
832 : DB::Types::Column::COUNTER_I64
void set_counter(uint8_t op, int64_t v, Types::Column typ=Types::Column::COUNTER_I64, int64_t rev=TIMESTAMP_NULL)
SWC_CAN_INLINE void set_value(uint8_t *v, uint32_t len, bool owner)
constexpr SWC_CAN_INLINE int code() const noexcept
SWC_CAN_INLINE void set_pos(uint32_t a_pos) noexcept
void expect_token(const char *token, uint8_t token_len, bool &found)
void expect_comma(bool &comma)
std::shared_ptr< Schema > Ptr
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)
void read_uint16_t(uint16_t &value, bool &was_set)
static constexpr const uint8_t REPLACE
const char * get_text(const int err) noexcept
constexpr const uint24_t UINT24_MAX
static constexpr const uint8_t INSERT
static constexpr const uint8_t SERIAL
const uint COMP_EXTENDED_VALUE
SWC_CAN_INLINE UpdateField_T & add_item(uint32_t i, ArgsT &&... args)
void read_uint64_t(uint64_t &value, bool &was_set, const char *stop=nullptr)
void read_duration_secs(uint64_t &value, bool &was_set, const char *stop=nullptr)
Type SWC_PURE_FUNC encoding_from(const std::string &typ) noexcept
void read_column_tags(DB::Schemas::TagsPattern &tags)
static int counter_from_str(const uint8_t **ptrp, size_t *remainp, uint8_t &op, int64_t &value) noexcept
SWC_CAN_INLINE bool eq(const uint8_t *p1, uint32_t p1_len, const uint8_t *p2, uint32_t p2_len) noexcept
SWC_CAN_INLINE void add(Field *field)
bool found_comparator(Condition::Comp &comp, uint8_t extended=0x00)
SWC_CAN_INLINE bool is_op_by_idx() const noexcept
SWC_CAN_INLINE void add(const std::string_view &fraction)
void read_int64_t(int64_t &value, bool &was_set, const char *stop=nullptr)
bool found_char(const char c)
SWC_CAN_INLINE bool is_delete_field() const noexcept
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_)
void read_uint8_t(uint8_t &value, bool &was_set)
The SWC-DB C++ namespace 'SWC'.
int64_t parse_ns(int &err, const std::string &buf)
bool SWC_CONST_FUNC is_counter(const Column typ) noexcept
static constexpr const uint8_t OVERWRITE
void length(const ConnHandlerPtr &conn, const Event::Ptr &ev)
bool found_quote_double(bool "e)
bool found_token(const char *token, uint8_t token_len)
Reader(const std::string &sql, std::string &message)
constexpr SWC_CAN_INLINE void set_timestamp_auto() noexcept
bool found_quote_single(bool "e)
DB::Cell::Serial::Value::Type read_serial_value_type()
static constexpr const uint8_t APPEND
constexpr SWC_CAN_INLINE size_t fill() const noexcept
Comp from(const char **buf, uint32_t *remainp, uint8_t extended=0x00) noexcept
void read_uint24_t(uint24_t &value, bool &was_set, const char *stop=nullptr)
void read_operation(const DB::Types::Column col_type, DB::Specs::UpdateOP &operation)
SWC_CAN_INLINE bool is_op_by_unique() const noexcept
SWC_CAN_INLINE bool is_op_by_cond() const noexcept
constexpr const uint8_t OP_EQUAL
bool SWC_PURE_FUNC is_char(const char *stop) const
void read_column(const char *stop, std::string &col_name, DB::Schemas::NamePatterns &names)
SWC_CAN_INLINE void set_op(const char **ptr, uint32_t *remainp, bool w_value_ctrl=false) noexcept
const char *SWC_CONST_FUNC to_string(Comp comp) noexcept
static constexpr const uint8_t PREPEND
constexpr const int24_t INT24_MIN
void expected_boolean(bool &value)
SWC_CAN_INLINE void set_op(const char **ptr, uint32_t *remainp, int &err, bool w_value_ctrl=false) noexcept
void error_msg(int error, const std::string &msg)
SWC_CAN_INLINE void set_op(uint8_t a_op) noexcept
SWC_CAN_INLINE std::string to_string(const BitFieldInt< T, SZ > &v)
void read_uint32_t(uint32_t &value, bool &was_set, const char *stop=nullptr)
bool str_case_eq(const char *s1, const char *s2, size_t count) noexcept SWC_ATTRIBS((SWC_ATTRIB_O3))
SWC_CAN_INLINE reference emplace_back(ArgsT &&... args)
DB::Types::Encoder read_encoder()
constexpr SWC_CAN_INLINE void set_timestamp(int64_t ts) noexcept