Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-2733

Generalize / Simplify Facade

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: Qserv
    • Labels:
      None

      Description

      Daniel started thinking about simplifying Facade, here is some unfinished code from him

      /// 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("<empty>");
              }
              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("<empty>");
              }
              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<std::string> getAllowedDbs() const {
          };
          virtual std::vector<std::string> getChunkedTables(std::string const& dbName) const;
          virtual std::vector<std::string> getSubChunkedTables(std::string const& dbName) const;
          virtual std::vector<std::string> 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<std::string> 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
      };

        Attachments

          Container Issues

            Issue Links

              Activity

                People

                • Assignee:
                  salnikov Andy Salnikov
                  Reporter:
                  fritzm Fritz Mueller
                  Reviewers:
                  Jacek Becla, John Gates
                  Watchers:
                  Andy Salnikov, Jacek Becla, John Gates
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Summary Panel