thcodectx.hpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*##############################################################################
  2. Copyright (C) 2011 HPCC Systems.
  3. All rights reserved. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ############################################################################## */
  14. #ifndef __THCODECTX__
  15. #define __THCODECTX__
  16. #include "eclhelper.hpp"
  17. #include "deftype.hpp"
  18. #include "dadfs.hpp"
  19. #include "thgraph.hpp"
  20. #ifdef _WIN32
  21. #ifdef THORCODECTX_EXPORTS
  22. #define thcodectx_decl __declspec(dllexport)
  23. #else
  24. #define thcodectx_decl __declspec(dllimport)
  25. #endif
  26. #else
  27. #define thcodectx_decl
  28. #endif
  29. interface ILoadedDllEntry;
  30. interface IConstWUResult;
  31. interface IWUResult;
  32. class CJobBase;
  33. class thcodectx_decl CThorCodeContextBase : public CSimpleInterface, implements ICodeContextExt
  34. {
  35. protected:
  36. Linked<IUserDescriptor> userDesc;
  37. ILoadedDllEntry &querySo;
  38. CJobBase &job;
  39. void expandLogicalName(StringBuffer & fullname, const char * logicalName);
  40. IConstWUResult * getResult(const char * name, unsigned sequence);
  41. IWUResult *updateResult(const char *name, unsigned sequence);
  42. public:
  43. IMPLEMENT_IINTERFACE_USING(CSimpleInterface);
  44. CThorCodeContextBase(CJobBase &job, ILoadedDllEntry &_querySo, IUserDescriptor &_userDesc);
  45. // ICodeContext
  46. virtual const char *loadResource(unsigned id);
  47. virtual char *getWuid();
  48. virtual char *getDaliServers();
  49. virtual char *getExpandLogicalName(const char * logicalName);
  50. virtual IUserDescriptor *queryUserDescriptor() { return userDesc; }
  51. virtual unsigned getRecoveringCount() { UNIMPLEMENTED; } // don't know how to implement here!
  52. virtual unsigned getNodes() { assertex(false); return (unsigned)-1; }
  53. virtual unsigned getNodeNum() { assertex(!"getNodeNum should not be called on the master"); return (unsigned)-1; }
  54. virtual char *getFilePart(const char *logicalName, bool create=false) { assertex(false); return NULL; }
  55. virtual unsigned __int64 getFileOffset(const char *logicalName) { assertex(false); return 0; }
  56. virtual char *getJobName();
  57. virtual char *getJobOwner();
  58. virtual char *getClusterName();
  59. virtual unsigned getPriority() const { return 0; }
  60. virtual char *getPlatform() { return strdup("thor"); };
  61. virtual char *getEnv(const char *name, const char *defaultValue) const { return strdup(defaultValue); }
  62. virtual char *getOS()
  63. {
  64. #ifdef _WIN32
  65. return strdup("windows");
  66. #else
  67. return strdup("linux");
  68. #endif
  69. }
  70. virtual unsigned logString(const char *text) const
  71. {
  72. if (text && *text)
  73. {
  74. DBGLOG("USER: %s", text);
  75. return strlen(text);
  76. }
  77. else
  78. return 0;
  79. }
  80. virtual const IContextLogger &queryContextLogger() const
  81. {
  82. return queryDummyContextLogger();
  83. }
  84. virtual void executeGraph(const char * graphName, bool realThor, size32_t parentExtractSize, const void * parentExtract) { UNIMPLEMENTED; }
  85. virtual char *getGroupName(); // thorlib.group()
  86. virtual char *queryIndexMetaData(char const * lfn, char const * xpath) { UNIMPLEMENTED; }
  87. virtual IEngineRowAllocator * getRowAllocator(IOutputMetaData * meta, unsigned activityId) const;
  88. virtual ILocalGraph *resolveLocalQuery(__int64 gid);
  89. virtual IThorChildGraph * resolveChildQuery(__int64 activityId, IHThorArg * colocal);
  90. virtual void getRowXML(size32_t & lenResult, char * & result, IOutputMetaData & info, const void * row, unsigned flags);
  91. virtual IConstWUResult *getExternalResult(const char * wuid, const char *name, unsigned sequence) { throwUnexpected(); }
  92. virtual IConstWUResult *getResultForGet(const char *name, unsigned sequence) { throwUnexpected(); }
  93. virtual const void * fromXml(IEngineRowAllocator * rowAllocator, size32_t len, const char * utf8, IXmlToRowTransformer * xmlTransformer, bool stripWhitespace);
  94. };
  95. #endif