refactorings
This commit is contained in:
3
.vscode/c_cpp_properties.json
vendored
3
.vscode/c_cpp_properties.json
vendored
@@ -10,13 +10,12 @@
|
||||
},
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"${workspaceFolder}/stdlib",
|
||||
"/usr/local/opt/openssl/include",
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"defines": [],
|
||||
"macFrameworkPath": [
|
||||
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks"
|
||||
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
|
||||
],
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
"cStandard": "c11",
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
### WIP
|
||||
compare in row.cpp shoud take into account m_visible
|
||||
|
||||
### TODO
|
||||
- create local_install.sh
|
||||
|
||||
@@ -14,7 +17,6 @@
|
||||
- add drop m_index
|
||||
- support for joining
|
||||
|
||||
- use string_to_double and string_to_long (from Table) everywhere
|
||||
- add const wherever should be
|
||||
- use static methods where posible
|
||||
- use references where pointer cannot be nullptr
|
||||
|
||||
2
main.cpp
2
main.cpp
@@ -117,7 +117,7 @@ void repl() {
|
||||
result->print();
|
||||
|
||||
code += input + "\n";
|
||||
} catch (std::exception &e) {
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ std::vector<std::pair<std::string, std::string>> Settings::m_settings =
|
||||
long Settings::string_to_long(const std::string &intstr) {
|
||||
try {
|
||||
return std::stol(intstr);
|
||||
} catch (std::invalid_argument &e) {
|
||||
} catch (const std::invalid_argument &e) {
|
||||
throw Exception("error parsing as integer: " + intstr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ void Table::commit_row(Row &row) {
|
||||
try {
|
||||
validate_row(row);
|
||||
index_row(row);
|
||||
} catch (Exception &e) {
|
||||
} catch (const Exception &e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -333,8 +333,9 @@ Index * Table::get_index_for_column(const std::string &col_name) {
|
||||
return (it != m_indexes.end()) ? &(*it) : nullptr;
|
||||
}
|
||||
|
||||
bool Table::empty() {
|
||||
bool Table::empty() const {
|
||||
if (m_rows.empty()) return true;
|
||||
|
||||
for (const auto & r : m_rows)
|
||||
if (r.is_visible()) return false;
|
||||
|
||||
|
||||
2
table.h
2
table.h
@@ -59,7 +59,7 @@ struct Table {
|
||||
Index * get_index(const std::string &index_name);
|
||||
Index * get_index_for_column(const std::string &col_name);
|
||||
|
||||
bool empty();
|
||||
bool empty() const;
|
||||
|
||||
struct rows_scanner {
|
||||
explicit rows_scanner(Table *tbl) : m_use_rowids(false), m_table(tbl), m_fscan_itr(tbl->m_rows.begin()) {}
|
||||
|
||||
2
usql.cpp
2
usql.cpp
@@ -11,7 +11,7 @@ std::unique_ptr<Table> USql::execute(const std::string &command) {
|
||||
std::unique_ptr<Node> node = m_parser.parse(command);
|
||||
return execute(*node);
|
||||
|
||||
} catch (std::exception &e) {
|
||||
} catch (const std::exception &e) {
|
||||
return create_stmt_result_table(-1, e.what(), 0);
|
||||
}
|
||||
|
||||
|
||||
2
usql.h
2
usql.h
@@ -87,7 +87,7 @@ private:
|
||||
Table *src_table, Row *src_row,
|
||||
Table *rslt_table,
|
||||
const std::vector<ColDefNode> &rslt_tbl_col_defs, const std::vector<int> &src_table_col_index,
|
||||
bool is_aggregated) ;
|
||||
bool is_aggregated);
|
||||
|
||||
std::pair<bool, std::vector<rowid_t>> probe_index_scan(const Node *where, Table *table) const;
|
||||
std::pair<bool, std::vector<rowid_t>> look_for_usable_index(const Node *where, Table *table) const;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace usql {
|
||||
|
||||
|
||||
|
||||
@@ -82,8 +82,7 @@ std::unique_ptr<ValueNode> USql::pp_function(const std::vector<std::unique_ptr<V
|
||||
return std::make_unique<StringValueNode>(parsed_value->getStringValue());
|
||||
}
|
||||
|
||||
std::unique_ptr<ValueNode>
|
||||
USql::max_function(const std::vector<std::unique_ptr<ValueNode>> &evaluatedPars, const ColDefNode *col_def_node, ColValue *agg_func_value) {
|
||||
std::unique_ptr<ValueNode> USql::max_function(const std::vector<std::unique_ptr<ValueNode>> &evaluatedPars, const ColDefNode *col_def_node, ColValue *agg_func_value) {
|
||||
if (col_def_node->type == ColumnType::integer_type || col_def_node->type == ColumnType::date_type) {
|
||||
if (!evaluatedPars[0]->isNull()) {
|
||||
auto val = evaluatedPars[0]->getIntegerValue();
|
||||
|
||||
Reference in New Issue
Block a user