SourcePro® 2023.1 |
SourcePro® API Reference Guide |
Represents a table of data that resides in program memory. More...
#include <rw/db/memtable.h>
Additional Inherited Members | |
Public Types inherited from RWDBTable | |
enum | CacheType { Local, All } |
enum | Metadata { None, ColumnList, DefaultValues, IdentityConstraint, PrimaryKey } |
Related Functions inherited from RWDBTable | |
RWDBTable::Metadata | operator& (RWDBTable::Metadata lhs, RWDBTable::Metadata rhs) |
RWDBTable::Metadata & | operator&= (RWDBTable::Metadata &lhs, RWDBTable::Metadata rhs) |
RWDBTable::Metadata | operator^ (RWDBTable::Metadata lhs, RWDBTable::Metadata rhs) |
RWDBTable::Metadata & | operator^= (RWDBTable::Metadata &lhs, RWDBTable::Metadata rhs) |
RWDBTable::Metadata | operator| (RWDBTable::Metadata lhs, RWDBTable::Metadata rhs) |
RWDBTable::Metadata & | operator|= (RWDBTable::Metadata &lhs, RWDBTable::Metadata rhs) |
RWDBTable::Metadata | operator~ (RWDBTable::Metadata md) |
RWDBMemTable is a table of data that resides in program memory. After construction, an RWDBMemTable is no longer associated with a table in the database. An application can modify the data in an RWDBMemTable, but the changes are not propagated back to the database.
RWDBMemTable is designed around the Interface/Implementation paradigm. An RWDBMemTable instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation.
Because an RWDBMemTable resides in memory, it is possible to provide random access to its data. The DB Interface Module provides operator[] for indexing on RWDBMemTable, the result of which is a reference to RWDBRow. RWDBRow inherits indexing operator operator[] from the Essential Tools Module class RWOrdered. The net result is the ability to access RWDBMemTable data with double indexing, as if it were a two-dimensional C++ array.
There are limitations to using RWDBMemTable, as it lacks some of the functionality of an RWDBTable. The differences in functionality come from the lack of a server in memory for selecting, deleting, inserting, and updating memory tables through SQL constructs. This means that selectors, cursors, deleters, inserters, and updaters cannot be created using memory tables. Instead, the actual table in the database must be referenced.
However, an RWDBReader may be produced from RWDBMemTable, allowing access to each row within the memory table, rather than using the overloaded operator operator[] for indexing.
It should also be noted that since memory tables exist within memory, the normal data definition language (DDL) constructs that are associated with tables are also dysfunctional and return invalid results. These include grant(), revoke(), addColumn(), dropColumn(), and so on.
RWDBMemTable::RWDBMemTable | ( | size_t | capacity = 0 | ) |
Constructs an empty RWDBMemTable with given capacity. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable::RWDBMemTable | ( | const RWDBTable & | table, |
size_t | capacity = 0 |
||
) |
Uses a default database connection to construct an RWDBMemTable and populate it with a maximum of capacity rows from table. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable::RWDBMemTable | ( | const RWDBTable & | table, |
const RWDBConnection & | connection, | ||
size_t | capacity = 0 |
||
) |
Uses the supplied connection to construct an RWDBMemTable and populate it with a maximum of capacity rows from table. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable::RWDBMemTable | ( | const RWDBSelectorBase & | sel, |
size_t | capacity = 0 |
||
) |
Uses a default connection to construct an RWDBMemTable and populate it with the maximum of capacity rows from sel. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable::RWDBMemTable | ( | const RWDBSelectorBase & | sel, |
const RWDBConnection & | connection, | ||
size_t | capacity = 0 |
||
) |
Uses the supplied connection to construct an RWDBMemTable and to populate it with the maximum of capacity rows from sel. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable::RWDBMemTable | ( | RWDBReader & | reader, |
size_t | capacity = 0 |
||
) |
Uses the supplied reader to construct an RWDBMemTable, populating it with a maximum of capacity rows copied from reader. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable::RWDBMemTable | ( | const RWDBMemTable & | table | ) |
Copy constructor. Self shares an implementation with table.
size_t RWDBMemTable::entries | ( | ) | const |
Returns the number of rows in self.
RWDBMemTable& RWDBMemTable::operator= | ( | const RWDBMemTable & | table | ) |
Assignment operator. Self shares an implementation with table.
RWDBRow& RWDBMemTable::operator[] | ( | size_t | index | ) |
Returns a reference to the RWDBRow in self at position index. No bounds checking is done.
bool RWDBMemTable::populate | ( | RWDBReader & | reader | ) |
Fills self to capacity, with rows fetched from reader. Rows existing in self before this call are discarded.
bool RWDBMemTable::populate | ( | const RWDBTable & | table | ) |
Fills self to capacity, with rows fetched from table. Rows existing in self before this call are discarded.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |