xale-db 1.0
minimal SQL engine, written in c++
Loading...
Searching...
No Matches
Xale::DataStructure::Table Class Reference

Represents a mutable and persistent dataset (table). More...

#include <Table.h>

Inheritance diagram for Xale::DataStructure::Table:
Inheritance graph
Collaboration diagram for Xale::DataStructure::Table:
Collaboration graph

Public Member Functions

 Table (const std::string &name)
 Construct a new Table with the given name.
const std::string & getName () const override
const std::vector< ColumnDefinition > & getSchema () const override
const std::vector< Row > & getRows () const override
size_t getRowCount () const override
size_t getColumnCount () const override
bool isEmpty () const override
bool isMutable () const override
void addColumn (const ColumnDefinition &column)
 Add a new column to the table schema.
bool insertRow (const Row &row)
 Insert a new row into the table.
size_t updateRows (const std::string &columnName, const FieldValue &value, const std::unordered_map< std::string, FieldValue > &updates)
 Update rows matching a condition.
size_t deleteRows (const std::string &columnName, const FieldValue &value)
 Delete rows matching a condition.
std::vector< RowfindRows (const std::string &columnName, const FieldValue &value) const
 Find rows matching a condition.
std::vector< char > serialize () const
 Serialize the table to a byte vector.

Static Public Member Functions

static Table deserialize (const std::vector< char > &data)
 Deserialize a table from a byte vector.

Detailed Description

Represents a mutable and persistent dataset (table).

Provides methods for schema definition, row manipulation, and serialization.

Constructor & Destructor Documentation

◆ Table()

Xale::DataStructure::Table::Table ( const std::string & name)
explicit

Construct a new Table with the given name.

Parameters
nameName of the table

Member Function Documentation

◆ addColumn()

void Xale::DataStructure::Table::addColumn ( const ColumnDefinition & column)

Add a new column to the table schema.

Parameters
columnColumn definition to add

◆ deleteRows()

size_t Xale::DataStructure::Table::deleteRows ( const std::string & columnName,
const FieldValue & value )

Delete rows matching a condition.

Parameters
columnNameName of the column to match
valueValue to match in the column
Returns
Number of rows deleted

◆ deserialize()

Table Xale::DataStructure::Table::deserialize ( const std::vector< char > & data)
static

Deserialize a table from a byte vector.

Parameters
dataSerialized data
Returns
Deserialized Table object

◆ findRows()

std::vector< Row > Xale::DataStructure::Table::findRows ( const std::string & columnName,
const FieldValue & value ) const

Find rows matching a condition.

Parameters
columnNameName of the column to match
valueValue to match in the column
Returns
Vector of matching rows

◆ getColumnCount()

size_t Xale::DataStructure::Table::getColumnCount ( ) const
overridevirtual

◆ getName()

const std::string & Xale::DataStructure::Table::getName ( ) const
overridevirtual

◆ getRowCount()

size_t Xale::DataStructure::Table::getRowCount ( ) const
overridevirtual

◆ getRows()

const std::vector< Row > & Xale::DataStructure::Table::getRows ( ) const
overridevirtual

◆ getSchema()

const std::vector< ColumnDefinition > & Xale::DataStructure::Table::getSchema ( ) const
overridevirtual

◆ insertRow()

bool Xale::DataStructure::Table::insertRow ( const Row & row)

Insert a new row into the table.

Parameters
rowRow to insert
Returns
True if insertion is successful, false otherwise

◆ isEmpty()

bool Xale::DataStructure::Table::isEmpty ( ) const
overridevirtual

◆ isMutable()

bool Xale::DataStructure::Table::isMutable ( ) const
overridevirtual

◆ serialize()

std::vector< char > Xale::DataStructure::Table::serialize ( ) const

Serialize the table to a byte vector.

Returns
Serialized data

◆ updateRows()

size_t Xale::DataStructure::Table::updateRows ( const std::string & columnName,
const FieldValue & value,
const std::unordered_map< std::string, FieldValue > & updates )

Update rows matching a condition.

Parameters
columnNameName of the column to match
valueValue to match in the column
updatesMap of column names to new values
Returns
Number of rows updated

The documentation for this class was generated from the following files: