#include <ReadStreamSQLite.h>
|
void | checkTableExists () |
|
void | executeSQL (const std::string &sql) |
|
void | openDB () |
|
void | prepareSelectStatement () |
|
Own< RamDomain[]> | readNextTuple () override |
| Read and return the next tuple. More...
|
|
void | throwError (const std::string &message) |
|
void | consumeChar (const std::string &str, char c, size_t &pos) |
| Read past given character, consuming any preceding whitespace. More...
|
|
void | consumeWhiteSpace (const std::string &str, size_t &pos) |
| Advance position in the string until first non-whitespace character. More...
|
|
RamDomain | readADT (const std::string &source, const std::string &adtName, size_t pos=0, size_t *charactersRead=nullptr) |
|
std::string | readAlphanumeric (const std::string &source, size_t &pos) |
| Read the next alphanumeric sequence (corresponding to IDENT). More...
|
|
RamDomain | readRecord (const std::string &source, const std::string &recordTypeName, size_t pos=0, size_t *charactersRead=nullptr) |
| Read a record from a string. More...
|
|
| ReadStream (const std::map< std::string, std::string > &rwOperation, SymbolTable &symTab, RecordTable &recTab) |
|
std::string | readUntil (const std::string &source, const std::string stopChars, const size_t pos, size_t *charactersRead) |
|
| SerialisationStream (RO< SymbolTable > &symTab, RO< RecordTable > &recTab, const std::map< std::string, std::string > &rwOperation) |
|
| SerialisationStream (RO< SymbolTable > &symTab, RO< RecordTable > &recTab, Json types) |
|
| SerialisationStream (RO< SymbolTable > &symTab, RO< RecordTable > &recTab, Json types, std::vector< std::string > relTypes, size_t auxArity=0) |
|
|
static std::string | getFileName (const std::map< std::string, std::string > &rwOperation) |
| Return given filename or construct from relation name. More...
|
|
|
using | RO = std::conditional_t< readOnlyTables, const A, A > |
|
Definition at line 39 of file ReadStreamSQLite.h.
◆ ReadStreamSQLite()
souffle::ReadStreamSQLite::ReadStreamSQLite |
( |
const std::map< std::string, std::string > & |
rwOperation, |
|
|
SymbolTable & |
symbolTable, |
|
|
RecordTable & |
recordTable |
|
) |
| |
|
inline |
◆ ~ReadStreamSQLite()
souffle::ReadStreamSQLite::~ReadStreamSQLite |
( |
| ) |
|
|
inlineoverride |
◆ checkTableExists()
void souffle::ReadStreamSQLite::checkTableExists |
( |
| ) |
|
|
inlineprotected |
Definition at line 137 of file ReadStreamSQLite.h.
141 throwError(
"SQLite error in sqlite3_prepare_v2: ");
144 if (sqlite3_step(tableStatement) == SQLITE_ROW) {
145 int count = sqlite3_column_int(tableStatement, 0);
147 sqlite3_finalize(tableStatement);
151 sqlite3_finalize(tableStatement);
152 throw std::invalid_argument(
References throwError().
◆ executeSQL()
void souffle::ReadStreamSQLite::executeSQL |
( |
const std::string & |
sql | ) |
|
|
inlineprotected |
Definition at line 97 of file ReadStreamSQLite.h.
100 std::stringstream error;
101 error <<
"SQLite error in sqlite3_exec: " << sqlite3_errmsg(
db) <<
"\n";
102 error <<
"SQL error: " << errorMessage <<
"\n";
103 error <<
"SQL: " << sql <<
"\n";
104 sqlite3_free(errorMessage);
105 throw std::invalid_argument(error.str());
110 std::stringstream error;
111 error << message << sqlite3_errmsg(
db) <<
"\n";
◆ getFileName()
static std::string souffle::ReadStreamSQLite::getFileName |
( |
const std::map< std::string, std::string > & |
rwOperation | ) |
|
|
inlinestaticprotected |
Return given filename or construct from relation name.
Default name is [configured path]/[relation name].sqlite
- Parameters
-
rwOperation | map of IO configuration options |
- Returns
- input filename
Definition at line 167 of file ReadStreamSQLite.h.
170 name =
getOr(rwOperation,
"fact-dir",
".") +
"/" + name;
◆ openDB()
void souffle::ReadStreamSQLite::openDB |
( |
| ) |
|
|
inlineprotected |
Definition at line 128 of file ReadStreamSQLite.h.
134 sqlite3_stmt* tableStatement;
135 std::stringstream selectSQL;
◆ prepareSelectStatement()
void souffle::ReadStreamSQLite::prepareSelectStatement |
( |
| ) |
|
|
inlineprotected |
◆ readNextTuple()
Own<RamDomain[]> souffle::ReadStreamSQLite::readNextTuple |
( |
| ) |
|
|
inlineoverrideprotectedvirtual |
Read and return the next tuple.
Returns nullptr if no tuple was readable.
- Returns
Implements souffle::ReadStream.
Definition at line 62 of file ReadStreamSQLite.h.
67 std::string element(
reinterpret_cast<const char*
>(sqlite3_column_text(
selectStatement, column)));
69 if (element.empty()) {
76 case 's': tuple[column] =
symbolTable.unsafeLookup(element);
break;
81 default:
fatal(
"invalid type attribute: `%c`", ty[0]);
84 std::stringstream errorMessage;
85 errorMessage <<
"Error converting number in column " << (column) + 1;
86 throw std::invalid_argument(errorMessage.str());
94 assert(
db &&
"Database connection is closed");
◆ throwError()
void souffle::ReadStreamSQLite::throwError |
( |
const std::string & |
message | ) |
|
|
inlineprotected |
◆ db
sqlite3* souffle::ReadStreamSQLite::db = nullptr |
|
protected |
◆ dbFilename
const std::string souffle::ReadStreamSQLite::dbFilename |
|
protected |
◆ relationName
const std::string souffle::ReadStreamSQLite::relationName |
|
protected |
◆ selectStatement
sqlite3_stmt* souffle::ReadStreamSQLite::selectStatement = nullptr |
|
protected |
The documentation for this class was generated from the following file:
C::mapped_type const & getOr(const C &container, typename C::key_type key, const typename C::mapped_type &defaultValue)
Get value for a given key; if not found, return default value.