Project: datamanagement
Issue DM-2733: Generalize / Simplify Facade 
Daniel started thinking about simplifying Facade, here is some unfinished code from him {code} /// Unfinished. Planned to be a re-thinking of Facade that collapses some /// genericity and simplifies things using the assumption of running on a /// snapshot. class FacadeSnapshot : public Facade { public: StringMap _map; // Path --> key FacadeSnapshot() { } virtual bool containsDb(std::string const& dbName) const { if (dbName.empty()) { LOGF_DEBUG("Empty database name passed."); throw NoSuchDb(""); } string p = _prefix + "/DBS/" + dbName; bool ret = (_map.find(p) != _map.end()); LOGF_DEBUG("containsDb(%1%): %2%" % dbName % ret); return ret; } virtual bool containsTable(std::string const& dbName, std::string const& tableName) const { if (!containsDb(dbName)) { throw NoSuchDb(dbName); } if (tableName.empty()) { LOGF_DEBUG("Empty table name passed."); throw NoSuchTable(""); } string p = _prefix + "/DBS/" + dbName + "/TABLES/" + tableName; bool ret = (_map.find(p) != _map.end()); LOGF_DEBUG("containsTable returns: %1%" % ret); return ret; } virtual bool tableIsChunked(std::string const& dbName, std::string const& tableName) const { if (!containsTable(dbName, tableName)) { throw NoSuchTable(dbName + "." + tableName); } string p = _prefix + "/DBS/" + dbName + "/TABLES/" + tableName + "/partitioning"; bool ret = (_map.find(p) != _map.end()); LOGF_DEBUG("%1%.%2% %3% chunked." % dbName % tableName % (ret?"is":"is NOT")); return ret; } virtual bool tableIsSubChunked(std::string const& dbName, std::string const& tableName) const { string p = _prefix + "/DBS/" + dbName + "/TABLES/" + tableName + "/partitioning/" + "subChunks"; StringMap::const_iterator m = _map.find(p); bool ret = (m != _map.end()) && (m->second == "1"); LOGF_DEBUG("%1%.%2% %3% subChunked." % dbName % tableName % (ret ? "is" : "is NOT")); return ret; } virtual bool isMatchTable(std::string const& dbName, std::string const& tableName) const { LOGF_DEBUG("isMatchTable(%1%.%2%)" % dbName % tableName); if (!containsTable(dbName, tableName)) { throw NoSuchTable(dbName + "." + tableName); } string p = _prefix + "/DBS/" + dbName + "/TABLES/" + tableName + "/match"; StringMap::const_iterator m = _map.find(p); bool ret = (m != _map.end()) && (m->second == "1"); LOGF_DEBUG("%1%.%2% is %3% a match table" % dbName % tableName % (ret ? "" : "not ")); return ret; } #if 0 virtual std::vector getAllowedDbs() const { }; virtual std::vector getChunkedTables(std::string const& dbName) const; virtual std::vector getSubChunkedTables(std::string const& dbName) const; virtual std::vector getPartitionCols(std::string const& dbName, std::string const& tableName) const; virtual int getChunkLevel(std::string const& dbName, std::string const& tableName) const; virtual std::string getDirTable(std::string const& dbName, std::string const& tableName) const; virtual std::string getDirColName(std::string const& dbName, std::string const& tableName) const; virtual std::vector getSecIndexColNames(std::string const& dbName, std::string const& tableName) const; virtual StripingParams getDbStriping(std::string const& dbName) const; virtual double getOverlap(std::string const& dbName) const; virtual MatchTableParams getMatchTableParams(std::string const& dbName, std::string const& tableName) const; private: #endif }; {code}
Story points: 14