indexes WIP
This commit is contained in:
35
table.h
35
table.h
@@ -1,13 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "index.h"
|
||||
#include "parser.h"
|
||||
#include "row.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <iterator> // For std::forward_iterator_tag
|
||||
#include <cstddef> // For std::ptrdiff_t
|
||||
|
||||
|
||||
namespace usql {
|
||||
|
||||
struct Table {
|
||||
//using IndexValue=std::variant<ColNullValue, ColIntegerValue, ColStringValue>;
|
||||
using IndexValue=std::variant<long, std::string>;
|
||||
|
||||
struct Table {
|
||||
|
||||
Table(const Table &other);
|
||||
Table(const std::string& name, const std::vector<ColDefNode>& columns);
|
||||
@@ -21,6 +29,7 @@ namespace usql {
|
||||
Row& create_empty_row();
|
||||
void commit_row(const Row &row);
|
||||
void commit_copy_of_row(const Row &row);
|
||||
Row& get_row(int rowid) { return m_rows[rowid]; };
|
||||
|
||||
static void validate_column(const ColDefNode *col_def, ValueNode *col_val);
|
||||
static void validate_column(const ColDefNode *col_def, ColValue &col_val);
|
||||
@@ -35,11 +44,27 @@ namespace usql {
|
||||
std::string m_name;
|
||||
std::vector<ColDefNode> m_col_defs;
|
||||
std::vector<Row> m_rows;
|
||||
std::vector<Index<IndexValue>> m_indexes;
|
||||
|
||||
static long string_to_long(const std::string &s) ;
|
||||
static double string_to_double(const std::string &s) ;
|
||||
static long string_to_long(const std::string &s);
|
||||
static double string_to_double(const std::string &s);
|
||||
|
||||
void create_row_from_vector(const std::vector<ColDefNode> &colDefs, const std::vector<std::string> &csv_line);
|
||||
};
|
||||
|
||||
}
|
||||
void create_index(const Index<IndexValue>& index);
|
||||
void drop_index(const std::string &column);
|
||||
void index_row(Index<IndexValue> &index, const Row &row, const size_t rowid);
|
||||
void index_row(const Row &row, const size_t rowid);
|
||||
void index_rows(const std::string &index_name);
|
||||
|
||||
Index<IndexValue> * get_index(const std::string &index_name);
|
||||
Index<IndexValue> * get_index_for_column(const std::string &col_name);
|
||||
std::vector<int> index_search(const std::string &col_name, IndexValue key);
|
||||
|
||||
|
||||
typedef std::vector<Row>::iterator iterator;
|
||||
iterator fs_begin() { return m_rows.begin(); }
|
||||
iterator fs_end() { return m_rows.end(); }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user