Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding a new typesystem: mapstringmapstringdouble #1490

Merged
merged 15 commits into from
Sep 14, 2019
Merged
25 changes: 25 additions & 0 deletions src/query_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,23 @@ enum DbTypes {
VL_MAP_PAIR_VL_STRING_STRING_INT, // ["std::map<std::pair<std::string, std::string>, int>", 4, ["HDF5","SQLite"], ["VL_MAP", ["PAIR", "VL_STRING", "STRING"], "INT"], true]
VL_MAP_PAIR_VL_STRING_VL_STRING_INT, // ["std::map<std::pair<std::string, std::string>, int>", 4, ["HDF5","SQLite"], ["VL_MAP", ["PAIR", "VL_STRING", "VL_STRING"], "INT"], true]

// map<string, map<string, double> >
MAP_STRING_MAP_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["MAP", "STRING", ["MAP", "STRING", "DOUBLE"]], false]
MAP_STRING_MAP_VL_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["MAP", "STRING", ["MAP", "VL_STRING", "DOUBLE"]], false]
MAP_STRING_VL_MAP_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["MAP", "STRING", ["VL_MAP", "STRING", "DOUBLE"]], false]
MAP_STRING_VL_MAP_VL_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["MAP", "STRING", ["VL_MAP", "VL_STRING", "DOUBLE"]], false]
MAP_VL_STRING_MAP_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["MAP", "VL_STRING", ["MAP", "STRING", "DOUBLE"]], false]
MAP_VL_STRING_VL_MAP_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["MAP", "VL_STRING", ["VL_MAP", "STRING", "DOUBLE"]], false]
MAP_VL_STRING_MAP_VL_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["MAP", "VL_STRING", ["MAP", "VL_STRING", "DOUBLE"]], false]
MAP_VL_STRING_VL_MAP_VL_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["MAP", "VL_STRING", ["VL_MAP", "VL_STRING", "DOUBLE"]], false]
VL_MAP_STRING_MAP_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["VL_MAP", "STRING", ["MAP", "STRING", "DOUBLE"]], true]
VL_MAP_VL_STRING_MAP_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["VL_MAP", "VL_STRING", ["MAP", "STRING", "DOUBLE"]], true]
VL_MAP_STRING_VL_MAP_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["VL_MAP", "STRING", ["VL_MAP", "STRING", "DOUBLE"]], true]
VL_MAP_STRING_MAP_VL_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["VL_MAP", "STRING", ["MAP", "VL_STRING", "DOUBLE"]], true]
VL_MAP_STRING_VL_MAP_VL_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["VL_MAP", "STRING", ["VL_MAP", "VL_STRING", "DOUBLE"]], true]
VL_MAP_VL_STRING_MAP_VL_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["VL_MAP", "VL_STRING", ["MAP", "VL_STRING", "DOUBLE"]], true]
VL_MAP_VL_STRING_VL_MAP_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["VL_MAP", "VL_STRING", ["VL_MAP", "STRING", "DOUBLE"]], true]
VL_MAP_VL_STRING_VL_MAP_VL_STRING_DOUBLE, // ["std::map<std::string, std::map<std::string, double>>", 4, ["HDF5", "SQLite"], ["VL_MAP", "VL_STRING", ["VL_MAP", "VL_STRING", "DOUBLE"]], true]
// append new types only:
};

Expand Down Expand Up @@ -1058,6 +1075,14 @@ class Sha1 {
}
}

inline void Update(const std::map<std::string, std::map<std::string, double>>& x) {
katyhuff marked this conversation as resolved.
Show resolved Hide resolved
std::map<std::string, std::map<std::string, double>>::const_iterator it = x.begin();
for(; it != x.end(); ++it) {
hash_.process_bytes(it->first.c_str(), it->first.size());
Update(it->second);
}
}

/// \}

Digest digest() {
Expand Down
11 changes: 11 additions & 0 deletions src/sqlite_back.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ void SqliteBack::Bind(boost::spirit::hold_any v, DbTypes type, SqlStatement::Ptr
MAP_PAIR_STRING_STRING_INT,
std::map<std::pair<std::string CYCLUS_COMMA std::string> CYCLUS_COMMA int > );

CYCLUS_BINDVAL(
MAP_STRING_MAP_STRING_DOUBLE,
std::map<std::string CYCLUS_COMMA std::map<std::string CYCLUS_COMMA double> >);

default: {
throw ValueError("attempted to retrieve unsupported sqlite backend type");
}
Expand Down Expand Up @@ -459,6 +463,10 @@ boost::spirit::hold_any SqliteBack::ColAsVal(SqlStatement::Ptr stmt,
MAP_PAIR_STRING_STRING_INT,
std::map<std::pair<std::string CYCLUS_COMMA std::string> CYCLUS_COMMA int > );

CYCLUS_LOADVAL(
MAP_STRING_MAP_STRING_DOUBLE,
std::map<std::string CYCLUS_COMMA std::map<std::string CYCLUS_COMMA double> >);

default: {
throw ValueError("Attempted to retrieve unsupported backend type");
}}
Expand Down Expand Up @@ -550,6 +558,9 @@ DbTypes SqliteBack::Type(boost::spirit::hold_any v) {
type_map[&typeid(
std::map<std::pair<std::string, std::string>, int > )] =
MAP_PAIR_STRING_STRING_INT;

type_map[&typeid(std::map<std::string, std::map<std::string,double> >)] =
MAP_STRING_MAP_STRING_DOUBLE;
}

const std::type_info* ti = &v.type();
Expand Down