#include <ReadStreamJSON.h>
|
RamDomain | readNextElementList (const Json &source, const std::string &recordTypeName) |
|
RamDomain | readNextElementObject (const Json &source, const std::string &recordTypeName) |
|
Own< RamDomain[]> | readNextTuple () override |
|
Own< RamDomain[]> | readNextTupleList () |
|
Own< RamDomain[]> | readNextTupleObject () |
|
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) |
|
|
using | RO = std::conditional_t< readOnlyTables, const A, A > |
|
Definition at line 46 of file ReadStreamJSON.h.
◆ ReadStreamJSON()
souffle::ReadStreamJSON::ReadStreamJSON |
( |
std::istream & |
file, |
|
|
const std::map< std::string, std::string > & |
rwOperation, |
|
|
SymbolTable & |
symbolTable, |
|
|
RecordTable & |
recordTable |
|
) |
| |
|
inline |
◆ readNextElementList()
RamDomain souffle::ReadStreamJSON::readNextElementList |
( |
const Json & |
source, |
|
|
const std::string & |
recordTypeName |
|
) |
| |
|
inlineprotected |
Definition at line 153 of file ReadStreamJSON.h.
153 :
" + recordTypeName);
157 if (source.is_null()) {
161 assert(source.is_array() && "the
input is not json
array");
162 auto&& recordTypes = recordInfo["types"];
163 const size_t recordArity = recordInfo["arity"].long_value();
164 std::vector<RamDomain> recordValues(recordArity);
165 for (size_t i = 0; i < recordArity; ++i) {
166 const std::string& recordType = recordTypes[i].string_value();
167 switch (recordType[0]) {
169 recordValues[i] = symbolTable.unsafeLookup(source[i].string_value());
173 recordValues[i] = readNextElementList(source[i], recordType);
177 recordValues[i] = source[i].int_value();
181 recordValues[i] = source[i].int_value();
185 recordValues[i] = static_cast<RamDomain>(source[i].number_value());
188 default: fatal("invalid
type attribute
");
192 return recordTable.pack(recordValues.data(), recordValues.size());
195 Own<RamDomain[]> readNextTupleObject() {
196 if (pos >= jsonSource.array_items().size()) {
◆ readNextElementObject()
RamDomain souffle::ReadStreamJSON::readNextElementObject |
( |
const Json & |
source, |
|
|
const std::string & |
recordTypeName |
|
) |
| |
|
inlineprotected |
Definition at line 249 of file ReadStreamJSON.h.
252 recordIndex.insert(std::make_pair(param.string_value(), index_pos));
256 if (recordInfo.is_null()) {
257 throw std::invalid_argument(
"Missing record type information: " + recordTypeName);
261 if (source.is_null()) {
265 assert(source.is_object() &&
"the input is not json object");
266 auto&& recordTypes = recordInfo[
"types"];
267 const size_t recordArity = recordInfo[
"arity"].long_value();
268 std::vector<RamDomain> recordValues(recordArity);
269 recordValues.reserve(recordIndex.size());
270 for (
auto readParam : source.object_items()) {
272 if (recordIndex.find(readParam.first) == recordIndex.end()) {
273 fatal(
"invalid parameter: %s", readParam.first);
275 size_t i = recordIndex.at(readParam.first);
276 auto&&
type = recordTypes[
i].string_value();
279 recordValues[
i] =
symbolTable.unsafeLookup(readParam.second.string_value());
287 recordValues[
i] = readParam.second.int_value();
291 recordValues[
i] = readParam.second.int_value();
295 recordValues[
i] =
static_cast<RamDomain>(readParam.second.number_value());
298 default:
fatal(
"invalid type attribute: `%c`",
type[0]);
302 return recordTable.pack(recordValues.data(), recordValues.size());
◆ readNextTuple()
|
inlineoverrideprotectedvirtual |
Implements souffle::ReadStream.
Definition at line 67 of file ReadStreamJSON.h.
74 fatal(
"cannot deserialize json because %s:\n%s", error, source);
84 for (
auto param :
params[
"relation"][
"params"].array_items()) {
85 paramIndex.insert(std::make_pair(param.string_value(), index_pos));
89 fatal(
"the input is neither list nor object format");
◆ readNextTupleList()
Own<RamDomain[]> souffle::ReadStreamJSON::readNextTupleList |
( |
| ) |
|
|
inlineprotected |
Definition at line 104 of file ReadStreamJSON.h.
114 tuple[
i] =
symbolTable.unsafeLookup(jsonObj[
i].string_value());
122 tuple[
i] = jsonObj[
i].int_value();
126 tuple[
i] = jsonObj[
i].int_value();
130 tuple[
i] =
static_cast<RamDomain>(jsonObj[
i].number_value());
133 default:
fatal(
"invalid type attribute: `%c`", ty[0]);
136 std::stringstream errorMessage;
137 if (jsonObj.is_array() &&
i < jsonObj.array_items().size()) {
138 errorMessage <<
"Error converting: " << jsonObj[
i].dump();
140 errorMessage <<
"Invalid index: " <<
i;
142 throw std::invalid_argument(errorMessage.str());
150 auto&& recordInfo =
types[
"records"][recordTypeName];
◆ readNextTupleObject()
Own<RamDomain[]> souffle::ReadStreamJSON::readNextTupleObject |
( |
| ) |
|
|
inlineprotected |
Definition at line 199 of file ReadStreamJSON.h.
204 : jsonObj.object_items()) {
208 fatal(
"invalid parameter: %s",
p.first);
214 tuple[
i] =
symbolTable.unsafeLookup(
p.second.string_value());
222 tuple[
i] =
p.second.int_value();
226 tuple[
i] =
p.second.int_value();
230 tuple[
i] =
static_cast<RamDomain>(
p.second.number_value());
233 default:
fatal(
"invalid type attribute: `%c`", ty[0]);
236 std::stringstream errorMessage;
237 errorMessage <<
"Error converting: " <<
p.second.dump();
238 throw std::invalid_argument(errorMessage.str());
246 auto&& recordInfo =
types[
"records"][recordTypeName];
247 const std::string recordName = recordTypeName.substr(2);
◆ file
std::istream& souffle::ReadStreamJSON::file |
|
protected |
◆ isInitialized
bool souffle::ReadStreamJSON::isInitialized |
|
protected |
◆ jsonSource
Json souffle::ReadStreamJSON::jsonSource |
|
protected |
◆ paramIndex
std::map<const std::string, const size_t> souffle::ReadStreamJSON::paramIndex |
|
protected |
◆ params
Json souffle::ReadStreamJSON::params |
|
protected |
◆ pos
size_t souffle::ReadStreamJSON::pos |
|
protected |
◆ useObjects
bool souffle::ReadStreamJSON::useObjects |
|
protected |
The documentation for this class was generated from the following file:
a horizontalBars(j=m=void 0===a.axisX.type?new c.AutoScaleAxis(c.Axis.units.x, b.normalized.series, o, c.extend({}, a.axisX,{highLow:d, referenceValue:0})):a.axisX.type.call(c, c.Axis.units.x, b.normalized.series, o, c.extend({}, a.axisX,{highLow:d, referenceValue:0})), l=n=void 0===a.axisY.type?new c.StepAxis(c.Axis.units.y, b.normalized.series, o,{ticks:k}):a.axisY.type.call(c, c.Axis.units.y, b.normalized.series, o, a.axisY)) var p