parallel wip
This commit is contained in:
15
table.cpp
15
table.cpp
@@ -43,9 +43,8 @@ ColDefNode Table::get_column_def(int col_index) {
|
||||
}
|
||||
}
|
||||
|
||||
std::mutex insert_guard;
|
||||
Row& Table::create_empty_row() {
|
||||
std::unique_lock guard(insert_guard);
|
||||
std::unique_lock guard(m_insert_guard);
|
||||
|
||||
m_rows.emplace_back(columns_count(), false);
|
||||
return m_rows.back();
|
||||
@@ -112,20 +111,20 @@ std::string Table::csv_string() {
|
||||
return out_string;
|
||||
}
|
||||
|
||||
int Table::load_csv_string(const std::string &content) {
|
||||
size_t Table::load_csv_string(const std::string &content) {
|
||||
std::vector<ColDefNode> &colDefs = m_col_defs;
|
||||
|
||||
CsvReader csvparser{};
|
||||
int row_cnt = csvparser.parseCSVString(content, colDefs, *this);
|
||||
auto row_cnt = csvparser.parseCSVString(content, colDefs, *this);
|
||||
|
||||
return row_cnt;
|
||||
}
|
||||
|
||||
int Table::load_csv_file(const std::string &filename) {
|
||||
size_t Table::load_csv_file(const std::string &filename) {
|
||||
std::vector<ColDefNode> &colDefs = m_col_defs;
|
||||
|
||||
// allocate enough space
|
||||
int line_size = 128;
|
||||
int line_size = 256;
|
||||
|
||||
std::ifstream in(filename, std::ifstream::ate | std::ifstream::binary);
|
||||
auto file_size = in.tellg();
|
||||
@@ -145,7 +144,7 @@ int Table::load_csv_file(const std::string &filename) {
|
||||
|
||||
// load rows
|
||||
CsvReader csvparser{};
|
||||
int row_cnt = csvparser.parseCSVFile(filename, colDefs, *this);
|
||||
auto row_cnt = csvparser.parseCSVFile(filename, colDefs, *this);
|
||||
|
||||
return row_cnt;
|
||||
}
|
||||
@@ -279,6 +278,8 @@ void Table::reindex_row(Index &index, const ColDefNode &col_def, const Row &old_
|
||||
void Table::index_row(const Row &row) {
|
||||
if (!m_indexes.empty()) {
|
||||
const size_t rowid = get_rowid(row);
|
||||
|
||||
std::unique_lock guard(m_insert_guard);
|
||||
for (auto &idx : m_indexes) {
|
||||
ColDefNode cDef = get_column_def(idx.get_column_name());
|
||||
index_row(idx, cDef, row, rowid);
|
||||
|
||||
Reference in New Issue
Block a user