24    : 
Reader(table, diag, transaction)
 
   29        throw invalid_argument(
"delimiter and quote must not be the same character");
 
   42    std::unique_ptr<StackMachine> W;
 
   48    std::vector<const Attribute*> columns; 
 
   61        return C.pool(&
buf[0]);
 
   66        while (
c != EOF 
and c != 
'\n') {
 
   67            auto name = read_cell();
 
   71            } 
catch (std::out_of_range) {  }
 
   72            columns.push_back(attr);
 
   79        for (
auto &attr : 
table)
 
   80            columns.push_back(&attr);
 
   82            in.ignore(std::numeric_limits<std::streamsize>::max(), 
'\n'); 
 
   91                                    return attr.name == C.pool(
"$ts_begin");
 
   95                                    return attr.name == C.pool(
"$ts_end");
 
  103        for (std::size_t i = 0; i != columns.size(); ++i) {
 
  104            auto col = columns[i];
 
  125        if (
c != EOF 
and c != 
'\n') {
 
  126            diag.
e(
pos) << 
"Expected end of row.\n";
 
  133                                                                              S, store.num_rows() - 1));
 
  165        diag.
e(
pos) << 
"Expected TRUE or FALSE.\n";
 
  204                diag.
e(
pos) << 
"WARNING: Illegal character " << 
config().
quote << 
" found in unquoted string.\n";
 
  227#define DIGITS(num) for (auto i = 0; i < num; ++i) if (is_dec(c)) push(); else goto invalid; 
  228    if (
'-' == 
c) 
push();
 
  230    if (
'-' == 
c) 
push(); 
else goto invalid;
 
  232    if (
'-' == 
c) 
push(); 
else goto invalid;
 
  245    diag.
e(
pos) << 
"WARNING: Invalid date.\n";
 
  257#define DIGITS(num) for (auto i = 0; i < num; ++i) if (is_dec(c)) push(); else goto invalid; 
  258    if (
'-' == 
c) 
push();
 
  260    if (
'-' == 
c) 
push(); 
else goto invalid;
 
  262    if (
'-' == 
c) 
push(); 
else goto invalid;
 
  264    if (
' ' == 
c) 
push(); 
else goto invalid;
 
  266    if (
':' == 
c) 
push(); 
else goto invalid;
 
  268    if (
':' == 
c) 
push(); 
else goto invalid;
 
  280    diag.
e(
pos) << 
"WARNING: Invalid datetime.\n";
 
  287        case Numeric::N_Int: {
 
  295                diag.
e(
pos) << 
"WARNING: Unexpected characters encountered in an integer.\n";
 
  305        case Numeric::N_Decimal: {
 
  306            auto scale = ty.scale;
 
  315            d = d * 
powi(10, scale);
 
  318                int64_t post_dot = 0;
 
  321                    post_dot = 10 * post_dot + 
c - 
'0';
 
  325                post_dot *= 
powi(10, n);
 
  328                d += d >= 0 ? post_dot : -post_dot;
 
  331                diag.
e(
pos) << 
"WARNING: Unexpected characters encountered in a decimal.\n";
 
  341        case Numeric::N_Float: {
 
  342            std::string float_str;
 
  349            double d = std::strtod(float_str.c_str(), &end);
 
  351                diag.
e(
pos) << 
"WARNING: Unexpected characters encountered in a floating-point number.\n";
 
  355            if ( errno == ERANGE 
and ( d == HUGE_VAL or d == HUGE_VALF or d == HUGE_VALL ) ) {
 
  356                diag.
w(
pos) << 
"WARNING: A floating-point number is larger than the maximum value.\n";
 
  357                d = std::numeric_limits<double>::max();
 
  358            } 
else if ( errno == ERANGE 
and (d == -HUGE_VAL or d == -HUGE_VALF or d == -HUGE_VALL ) ) {
 
  359                diag.
w(
pos) << 
"WARNING: A floating-point number is smaller than the minimum value.\n";
 
  360                d = std::numeric_limits<double>::min();
 
  380        i = 10 * i + 
c - 
'0';
 
#define M_unreachable(MSG)
 
T M_EXPORT powi(const T base, const U exp)
Power function for integral types.
 
bool streq(const char *first, const char *second)
 
The catalog contains all Databases and keeps track of all meta information of the database system.
 
ThreadSafePooledString pool(const char *str) const
Creates an internalized copy of the string str by adding it to the internal StringPool.
 
static Catalog & Get()
Return a reference to the single Catalog instance.
 
Configuration parameters for importing a DSV file.
 
char delimiter
the delimiter separating cells
 
char quote
the quotation mark for strings
 
size_t skip_header() const
 
Tuple tup
intermediate tuple to store values of a row
 
const Config & config() const
 
size_t has_header() const
 
DSVReader(const Table &table, Config cfg, Diagnostic &diag, Scheduler::Transaction *transaction=nullptr)
 
void operator()(std::istream &in, const char *name) override
 
int64_t read_unsigned_int()
 
std::ostream & e(const Position pos)
 
std::ostream & w(const Position pos)
 
static StackMachine compile_store(const Schema &tuple_schema, void *address, const storage::DataLayout &layout, const Schema &layout_schema, std::size_t row_id=0, std::size_t tuple_id=0)
Compile a StackMachine to store a tuple of Schema tuple_schema using a given memory address and a giv...
 
A data type representing a pooled (or internalized) object.
 
An interface for all readers.
 
const Table & table
the table to insert the data into
 
Scheduler::Transaction * transaction
 
void start_time(int64_t time)
sets the start time of the Transaction. Should only be set once and only to a positive number.
 
A Schema represents a sequence of identifiers, optionally with a prefix, and their associated types.
 
void add(entry_type e)
Adds the entry e to this Schema.
 
A table is a sorted set of attributes.
 
virtual const storage::DataLayout & layout() const =0
Returns a reference to the physical data layout.
 
virtual all_iterator begin_all() const =0
 
virtual const ThreadSafePooledString & name() const =0
Returns the name of the Table.
 
virtual hidden_iterator cbegin_hidden() const =0
 
virtual hidden_iterator end_hidden() const =0
 
virtual all_iterator end_all() const =0
 
virtual Store & store() const =0
Returns a reference to the backing store.
 
virtual Attribute & at(std::size_t id)=0
Returns the attribute with the given id.
 
void null(std::size_t idx)
Sets the Value at index idx to NULL.
 
void set(std::size_t idx, Value val)
Assigns the Value val to this Tuple at index idx and clears the respective NULL bit.
 
This class holds a SQL attribute value.
 
A constant: a string literal or a numeric constant.
 
Signals that an argument to a function of method was invalid.
 
Models how data is laid out in a linear address space.