HPCCFileCache.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2014 HPCC Systems.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef HPCCFILECACHE_HPP_
  14. #define HPCCFILECACHE_HPP_
  15. #include "ws_sql.hpp"
  16. #include "ws_sql_esp.ipp"
  17. #include "dadfs.hpp"
  18. #include "dasess.hpp"
  19. #include "HPCCFile.hpp"
  20. #include "SQLTable.hpp"
  21. #include "fileview.hpp"
  22. #include "fvrelate.hpp"
  23. typedef HPCCFile * HPCCFilePtr;
  24. typedef MapStringTo<HPCCFilePtr> HpccFiles;
  25. class HPCCFileCache : public CInterface, public IInterface
  26. {
  27. public:
  28. IMPLEMENT_IINTERFACE;
  29. static HPCCFileCache * createFileCache(const char * username, const char * passwd);
  30. bool cacheAllHpccFiles(const char * filterby);
  31. bool fetchHpccFilesByTableName(IArrayOf<SQLTable> * sqltables);
  32. static bool updateHpccFileDescription(const char * filename, const char * user, const char * pass, const char * description);
  33. HPCCFile * fetchHpccFileByName(IUserDescriptor *user, const char * filename, bool namevalidated, bool acceptrawfiles=false);
  34. static HPCCFile * fetchHpccFileByName(const char * filename, const char * user, const char * pass, bool namevalidated, bool acceptrawfiles);
  35. const char * cacheHpccFileByName(const char * filename, bool namevalidated = false);
  36. bool isHpccFileCached(const char * filename);
  37. HPCCFilePtr getHpccFileByName(const char * filename);
  38. bool populateTablesResponse(IEspGetDBMetaDataResponse & tablesrespstruct, const char * filterby, bool nestedcolumns);
  39. HPCCFileCache(const char * username, const char * passwd)
  40. {
  41. userdesc.setown(createUserDescriptor());
  42. userdesc->set(username, passwd);
  43. }
  44. virtual ~HPCCFileCache()
  45. {
  46. HashIterator sIter(cache);
  47. for(sIter.first();sIter.isValid();sIter.next())
  48. {
  49. HPCCFilePtr a = *cache.mapToValue(&sIter.query());
  50. delete a;
  51. }
  52. #ifdef _DEBUG
  53. fprintf(stderr, "Leaving filecache");
  54. #endif
  55. }
  56. private:
  57. Owned<IUserDescriptor> userdesc;
  58. HpccFiles cache;
  59. };
  60. #endif /* HPCCFILECACHE_HPP_ */