hqlcpp.ipp 118 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  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 __HQLCPP_IPP_
  15. #define __HQLCPP_IPP_
  16. #include <stdio.h>
  17. #include "jfile.hpp"
  18. #include "hqlcpp.hpp"
  19. #include "hqlstmt.ipp"
  20. #include "hqlcppc.hpp"
  21. #include "hqlres.hpp"
  22. #include "hqlutil.hpp"
  23. #include "hqlwcpp.hpp"
  24. #include "hqltrans.ipp"
  25. #define DEBUG_TIMER(name, time) if (options.addTimingToWorkunit) { timeReporter->addTiming(name, time); }
  26. #define DEBUG_TIMERX(timeReporter, name, time) if (timeReporter) { timeReporter->addTiming(name, time); }
  27. #ifdef _DEBUG
  28. //#define SPOT_POTENTIAL_COMMON_ACTIVITIES
  29. #endif
  30. #define MAX_RECORD_SIZE 4096 // default value
  31. enum { HintSpeed = 1, HintSize = 2 };
  32. enum GraphLocalisation {
  33. GraphNoAccess = 0,
  34. GraphCoLocal = 1,
  35. GraphNonLocal = 2,
  36. GraphCoNonLocal = 3,
  37. GraphRemote = 4
  38. };
  39. enum {
  40. EclTextPrio = 1000, // has no dependencies on anything else
  41. TypeInfoPrio = 1200,
  42. RowMetaPrio = 1500,
  43. XmlTransformerPrio = 1700,
  44. SteppedPrio = 1800,
  45. SegMonitorPrio = 2000,
  46. RecordTranslatorPrio = BuildCtx::NormalPrio,
  47. };
  48. enum ExpressionFormat {
  49. FormatNatural,
  50. FormatBlockedDataset,
  51. FormatLinkedDataset,
  52. FormatArrayDataset,
  53. FormatMax,
  54. };
  55. ExpressionFormat queryNaturalFormat(ITypeInfo * type);
  56. class HqlCppLibraryImplementation;
  57. class HqlCppLibraryInstance;
  58. //===========================================================================
  59. class DatasetReference
  60. {
  61. public:
  62. DatasetReference(IHqlExpression * _ds) : ds(_ds) { side = no_none; }
  63. DatasetReference(IHqlExpression * _ds, node_operator _side, IHqlExpression * seq) : ds(_ds)
  64. {
  65. side = _side;
  66. if (side)
  67. selector.setown(getSelector(side, seq));
  68. }
  69. inline node_operator querySide() const { return side; }
  70. inline IHqlExpression * queryDataset() const { return ds; }
  71. IHqlExpression * getSelector(node_operator op, IHqlExpression * seq) const { return createSelector(op, ds, seq); }
  72. IHqlExpression * querySelector() const;
  73. IHqlExpression * querySelSeq() const;
  74. IHqlExpression * mapCompound(IHqlExpression * expr, IHqlExpression * to) const;
  75. IHqlExpression * mapScalar(IHqlExpression * expr, IHqlExpression * to) const;
  76. protected:
  77. LinkedHqlExpr ds;
  78. node_operator side;
  79. LinkedHqlExpr selector;
  80. };
  81. class LocationArray : public HqlExprArray
  82. {
  83. public:
  84. unsigned findLocation(IHqlExpression * location);
  85. bool queryNewLocation(IHqlExpression * location);
  86. };
  87. //===========================================================================
  88. class HQLCPP_API HqlCppSection : public CInterface
  89. {
  90. public:
  91. HqlCppSection() : stmts(NULL) {}
  92. public:
  93. _ATOM section;
  94. HqlStmts stmts;
  95. };
  96. class HQLCPP_API HqlCppInstance : public CInterface, public IHqlCppInstance
  97. {
  98. public:
  99. HqlCppInstance(IWorkUnit * _workunit, const char * _wupathname);
  100. IMPLEMENT_IINTERFACE
  101. virtual HqlStmts * ensureSection(_ATOM section);
  102. virtual const char * queryLibrary(unsigned idx);
  103. virtual HqlStmts * querySection(_ATOM section);
  104. virtual void flushHints();
  105. virtual void flushResources(const char *filename, ICodegenContextCallback * ctxCallback);
  106. virtual void addResource(const char * type, unsigned len, const void * data, IPropertyTree *manifestEntry=NULL, unsigned id=(unsigned)-1);
  107. virtual void addCompressResource(const char * type, unsigned len, const void * data, IPropertyTree *manifestEntry=NULL, unsigned id=(unsigned)-1);
  108. virtual void addManifest(const char *filename){resources.addManifest(filename);}
  109. virtual void addManifestFromArchive(IPropertyTree *archive){resources.addManifestFromArchive(archive);}
  110. virtual void addWebServiceInfo(IPropertyTree *wsinfo){resources.addWebServiceInfo(wsinfo);}
  111. bool useFunction(IHqlExpression * funcdef);
  112. void useInclude(const char * include);
  113. void useLibrary(const char * libname);
  114. unsigned addStringResource(unsigned len, const char * body);
  115. void addHint(const char * hintXml, ICodegenContextCallback * ctxCallback);
  116. void processIncludes();
  117. void addPlugin(const char *plugin, const char *version, bool inThor);
  118. private:
  119. void addPluginsAsResource();
  120. void appendHintText(const char * xml);
  121. public:
  122. CIArray sections;
  123. Array helpers;
  124. StringAttrArray modules;
  125. StringAttrArray includes;
  126. CIArray extra;
  127. ResourceManager resources;
  128. Owned<IWorkUnit> workunit;
  129. StringAttr wupathname;
  130. Owned<IPropertyTree> plugins;
  131. Owned<IFileIOStream> hintFile;
  132. };
  133. //---------------------------------------------------------------------------
  134. class HqlCppTranslator;
  135. class BoundRow;
  136. interface IHqlCppDatasetCursor : public IInterface
  137. {
  138. virtual void buildCount(BuildCtx & ctx, CHqlBoundExpr & tgt) = 0;
  139. virtual void buildExists(BuildCtx & ctx, CHqlBoundExpr & tgt) = 0;
  140. virtual BoundRow * buildIterateLoop(BuildCtx & ctx, bool needToBreak) = 0;
  141. virtual void buildIterateClass(BuildCtx & ctx, SharedHqlExpr & iter, SharedHqlExpr & row) = 0;
  142. virtual BoundRow * buildSelect(BuildCtx & ctx, IHqlExpression * indexExpr) = 0;
  143. virtual void buildIterateMembers(BuildCtx & declarectx, BuildCtx & initctx) = 0;
  144. };
  145. interface IHqlCppSetCursor : public IInterface
  146. {
  147. virtual void buildCount(BuildCtx & ctx, CHqlBoundExpr & tgt) = 0;
  148. virtual void buildExists(BuildCtx & ctx, CHqlBoundExpr & tgt) = 0;
  149. virtual void buildIsAll(BuildCtx & ctx, CHqlBoundExpr & tgt) = 0;
  150. virtual void buildIterateLoop(BuildCtx & ctx, CHqlBoundExpr & tgt, bool needToBreak) = 0;
  151. // virtual void buildIterateClass(BuildCtx & ctx, HqlExprAttr & iter, CHqlBoundExpr & tgt) = 0;
  152. virtual void buildExprSelect(BuildCtx & ctx, IHqlExpression * indexExpr, CHqlBoundExpr & tgt) = 0;
  153. virtual void buildAssignSelect(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * indexExpr) = 0;
  154. virtual bool isSingleValued() = 0;
  155. };
  156. interface IHqlCppDatasetBuilder : public IInterface
  157. {
  158. public:
  159. virtual void buildDeclare(BuildCtx & ctx) = 0;
  160. virtual BoundRow * buildCreateRow(BuildCtx & ctx) = 0; //NB: Must be called within a addGroup(), or another un-ambiguous child context, may create a filter
  161. virtual BoundRow * buildDeserializeRow(BuildCtx & ctx, IHqlExpression * serializedInput) = 0;
  162. virtual void finishRow(BuildCtx & ctx, BoundRow * selfCursor) = 0;
  163. virtual void buildFinish(BuildCtx & ctx, const CHqlBoundTarget & target) = 0;
  164. virtual void buildFinish(BuildCtx & ctx, CHqlBoundExpr & bound) = 0;
  165. virtual bool buildLinkRow(BuildCtx & ctx, BoundRow * sourceRow) = 0;
  166. virtual bool buildAppendRows(BuildCtx & ctx, IHqlExpression * expr) = 0;
  167. virtual bool isRestricted() = 0;
  168. };
  169. interface IHqlCppSetBuilder : public IInterface
  170. {
  171. public:
  172. virtual void buildDeclare(BuildCtx & ctx) = 0;
  173. virtual IReferenceSelector * buildCreateElement(BuildCtx & ctx) = 0; //NB: Must be called within a addGroup(), or another un-ambiguous child context, may create a filter
  174. virtual void buildFinish(BuildCtx & ctx, const CHqlBoundTarget & target) = 0;
  175. virtual void finishElement(BuildCtx & ctx) = 0;
  176. virtual void setAll(BuildCtx & ctx, IHqlExpression * isAll) = 0;
  177. };
  178. interface IHqlCodeCallback : public IInterface
  179. {
  180. virtual void buildCode(HqlCppTranslator & translator, BuildCtx & ctx) = 0;
  181. };
  182. //---------------------------------------------------------------------------
  183. class CheckedLengthExprAttr : public HqlExprAttr
  184. {
  185. public:
  186. inline void set(IHqlExpression * e) { HqlExprAttr::set(e); check(); }
  187. inline void setown(IHqlExpression * e) { HqlExprAttr::setown(e); check(); }
  188. inline void check()
  189. {
  190. if (get())
  191. {
  192. ITypeInfo * type = get()->queryType();
  193. assertex(type->getTypeCode() == type_int && type->getSize() == 4 && !type->isSigned());
  194. }
  195. }
  196. };
  197. class CHqlBoundTarget;
  198. class HQLCPP_API CHqlBoundExpr
  199. {
  200. public:
  201. void clear() { expr.clear(); length.clear(); }
  202. bool exists() const { return (expr != NULL); }
  203. IHqlExpression * getIsAll() const;
  204. IHqlExpression * getTranslatedExpr() const;
  205. ITypeInfo * queryType() const { return expr->queryType(); }
  206. void set(const CHqlBoundExpr & src) { expr.set(src.expr); length.set(src.length); count.set(src.count); isAll.set(src.isAll); }
  207. void setFromTarget(const CHqlBoundTarget & target);
  208. void setFromTranslated(IHqlExpression * expr);
  209. public:
  210. HqlExprAttr expr;
  211. HqlExprAttr count;
  212. #ifdef _DEBUG
  213. CheckedLengthExprAttr length;
  214. #else
  215. HqlExprAttr length;
  216. #endif
  217. HqlExprAttr isAll;
  218. };
  219. class HQLCPP_API CHqlBoundTarget
  220. {
  221. public:
  222. CHqlBoundTarget() {}
  223. ~CHqlBoundTarget() { validate(); }
  224. bool extractFrom(const CHqlBoundExpr & bound);
  225. bool isFixedSize() const;
  226. IHqlExpression * getTranslatedExpr() const;
  227. ITypeInfo * queryType() const;
  228. ITypeInfo * getType() const { return LINK(queryType()); }
  229. void set(const CHqlBoundTarget& other)
  230. {
  231. length.set(other.length);
  232. count.set(other.count);
  233. expr.set(other.expr);
  234. isAll.set(other.isAll);
  235. }
  236. void validate() const;
  237. public:
  238. HqlExprAttr expr;
  239. HqlExprAttr count; // currently only for link counted rows
  240. HqlExprAttr length;
  241. HqlExprAttr isAll; // if set location to store whether it is all or not
  242. };
  243. class BoundRow;
  244. class BoundRow;
  245. interface IReferenceSelector : public IInterface
  246. {
  247. public:
  248. //code generation
  249. //change these to inline functions
  250. virtual void assignTo(BuildCtx & ctx, const CHqlBoundTarget & target) = 0;
  251. virtual void buildAddress(BuildCtx & ctx, CHqlBoundExpr & target) = 0;
  252. virtual void buildClear(BuildCtx & ctx, int direction) = 0;
  253. virtual void get(BuildCtx & ctx, CHqlBoundExpr & bound) = 0;
  254. virtual void getOffset(BuildCtx & ctx, CHqlBoundExpr & bound) = 0;
  255. virtual void getSize(BuildCtx & ctx, CHqlBoundExpr & bound) = 0;
  256. virtual size32_t getContainerTrailingFixed() = 0;
  257. virtual bool isBinary() = 0;
  258. virtual bool isConditional() = 0;
  259. virtual bool isRoot() = 0;
  260. virtual void modifyOp(BuildCtx & ctx, IHqlExpression * expr, node_operator op) = 0;
  261. virtual void set(BuildCtx & ctx, IHqlExpression * expr) = 0;
  262. virtual void setRow(BuildCtx & ctx, IReferenceSelector * rhs) = 0;
  263. virtual void buildDeserialize(BuildCtx & ctx, IHqlExpression * helper) = 0;
  264. virtual void buildSerialize(BuildCtx & ctx, IHqlExpression * helper) = 0;
  265. //managing the selection
  266. virtual AColumnInfo * queryColumn() = 0;
  267. virtual BoundRow * queryRootRow() = 0;
  268. virtual IHqlExpression * queryExpr() = 0;
  269. virtual ITypeInfo * queryType() = 0;
  270. virtual IReferenceSelector * select(BuildCtx & ctx, IHqlExpression * selectExpr) = 0;
  271. virtual BoundRow * getRow(BuildCtx & ctx) = 0;
  272. };
  273. //---------------------------------------------------------------------------
  274. class HqlCppCaseInfo
  275. {
  276. friend class HqlCppTranslator;
  277. public:
  278. HqlCppCaseInfo(HqlCppTranslator & _translator);
  279. void addPair(IHqlExpression * expr);
  280. void addPairs(HqlExprArray & pairs);
  281. bool buildAssign(BuildCtx & ctx, const CHqlBoundTarget & target);
  282. bool buildReturn(BuildCtx & ctx);
  283. void setCond(IHqlExpression * expr);
  284. void setDefault(IHqlExpression * expr);
  285. protected:
  286. bool canBuildStaticList(ITypeInfo * type) { return isFixedSize(type); }
  287. void buildChop3Map(BuildCtx & ctx, const CHqlBoundTarget & target, CHqlBoundExpr & test, IHqlExpression * temp, unsigned start, unsigned end);
  288. void buildChop3Map(BuildCtx & ctx, const CHqlBoundTarget & target, CHqlBoundExpr & test);
  289. void buildChop2Map(BuildCtx & ctx, const CHqlBoundTarget & target, CHqlBoundExpr & test, unsigned start, unsigned end);
  290. IHqlExpression * buildIndexedMap(BuildCtx & ctx, IHqlExpression * test, unsigned lower, unsigned upper);
  291. void buildLoopChopMap(BuildCtx & ctx, const CHqlBoundTarget & target, CHqlBoundExpr & test);
  292. void buildIntegerSearchMap(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * est);
  293. void buildSwitchCondition(BuildCtx & ctx, CHqlBoundExpr & bound);
  294. void buildSwitchMap(BuildCtx & ctx, const CHqlBoundTarget * target, IHqlExpression * test);
  295. void buildGeneralAssign(BuildCtx & ctx, const CHqlBoundTarget & target);
  296. void buildGeneralReturn(BuildCtx & ctx);
  297. bool canBuildArrayLookup(const CHqlBoundExpr & test);
  298. IHqlExpression * createCompareList();
  299. IHqlExpression * createComparisons();
  300. IHqlExpression * createResultsExpr(IHqlExpression * matchVar, bool canIncludeDefault, bool * includedDefault = NULL);
  301. void generateCompareVar(BuildCtx & ctx, IHqlExpression * target, CHqlBoundExpr & test, IHqlExpression * other);
  302. unsigned getNumPairs();
  303. bool hasLibraryChop();
  304. bool okToAlwaysEvaluateDefault();
  305. void processBranches();
  306. void promoteTypes();
  307. IHqlExpression * queryCreateSimpleResultAssign(IHqlExpression * search, IHqlExpression * resultExpr);
  308. bool queryBuildArrayLookup(BuildCtx & ctx, const CHqlBoundTarget & target, const CHqlBoundExpr & test);
  309. IHqlExpression * queryCompare(unsigned index);
  310. ITypeInfo * queryCompareType();
  311. IHqlExpression * queryReturn(unsigned index);
  312. void removeDuplicates();
  313. void sortPairs();
  314. void updateResultType(IHqlExpression * expr);
  315. protected:
  316. HqlCppTranslator &translator;
  317. HqlExprAttr cond;
  318. HqlExprAttr defaultValue;
  319. HqlExprArray pairs;
  320. HqlExprArray originalPairs;
  321. bool complexCompare;
  322. bool constantCases;
  323. bool constantValues;
  324. OwnedITypeInfo resultType;
  325. OwnedITypeInfo indexType;
  326. OwnedITypeInfo promotedElementType;
  327. };
  328. //===========================================================================
  329. enum
  330. {
  331. MFremote = 1,
  332. MFsingle = 2,
  333. };
  334. class MemberFunction
  335. {
  336. public:
  337. MemberFunction(HqlCppTranslator & translator, BuildCtx & classctx, const char * text, unsigned _flags = 0);
  338. MemberFunction(HqlCppTranslator & translator, BuildCtx & classctx, StringBuffer & text, unsigned _flags = 0);
  339. ~MemberFunction();
  340. inline bool isExecutedOnce() const { return (flags & MFsingle) != 0; }
  341. public:
  342. HqlCppTranslator & translator;
  343. BuildCtx ctx;
  344. unsigned flags;
  345. };
  346. //===========================================================================
  347. class GlobalFileTracker : public CInterface, public IHqlDelayedCodeGenerator
  348. {
  349. public:
  350. GlobalFileTracker(IHqlExpression * _filename, IPropertyTree * _graphNode)
  351. {
  352. filename.set(_filename->queryBody());
  353. graphNode.set(_graphNode);
  354. usageCount = 0;
  355. }
  356. IMPLEMENT_IINTERFACE
  357. //IHqlDelayedCodeGenerator
  358. virtual void generateCpp(StringBuffer & out) { out.append(usageCount); }
  359. bool checkMatch(IHqlExpression * searchFilename);
  360. void writeToGraph();
  361. public:
  362. OwnedHqlExpr filename;
  363. Owned<IPropertyTree> graphNode;
  364. unsigned usageCount;
  365. };
  366. //===========================================================================
  367. class WorkflowItem : public CInterface
  368. {
  369. friend class WorkflowTransformer;
  370. public:
  371. WorkflowItem(unsigned _wfid) : wfid(_wfid) { }
  372. WorkflowItem(IHqlExpression * _function);
  373. IMPLEMENT_IINTERFACE;
  374. bool isFunction() const { return function != NULL; }
  375. IHqlExpression * getFunction() const;
  376. unsigned queryWfid() const { return wfid; }
  377. HqlExprArray & queryExprs() { return exprs; }
  378. private:
  379. LinkedHqlExpr function;
  380. unsigned wfid;
  381. HqlExprArray exprs;
  382. UnsignedArray dependencies;
  383. };
  384. typedef CIArrayOf<WorkflowItem> WorkflowArray;
  385. //---------------------------------------------------------------------------
  386. typedef CIArrayOf<BoundRow> CursorArray;
  387. enum AliasKind { NotFoundAlias, CreateTimeAlias, StartTimeAlias, RuntimeAlias };
  388. class ActivityInstance;
  389. class SerializationRow;
  390. class EvalContext;
  391. class InternalResultTracker;
  392. //---------------------------------------------------------------------------
  393. typedef CIArrayOf<BuildCtx> BuildCtxArray;
  394. struct GeneratedGraphInfo : public CInterface
  395. {
  396. public:
  397. GeneratedGraphInfo(const char * _name, IPropertyTree * _graph) : name(_name), graph(_graph) {}
  398. public:
  399. StringAttr name;
  400. Linked<IPropertyTree> graph;
  401. };
  402. enum SubGraphType { SubGraphRoot, SubGraphRemote, SubGraphChild };
  403. struct SubGraphInfo : public HqlExprAssociation
  404. {
  405. public:
  406. SubGraphInfo(IPropertyTree * _tree, unsigned _id, IHqlExpression * graphTag, SubGraphType _type);
  407. virtual AssocKind getKind() { return AssocSubGraph; }
  408. public:
  409. Linked<IPropertyTree> tree;
  410. unsigned id;
  411. LinkedHqlExpr graphTag;
  412. SubGraphType type;
  413. };
  414. //MORE: This class is far too big and needs restructuring!!!!!
  415. class ColumnToOffsetMap;
  416. class RecordOffsetMap : public MapOf<IHqlExpression *, ColumnToOffsetMap>
  417. {
  418. public:
  419. ColumnToOffsetMap * queryMapping(IHqlExpression * record, unsigned maxRecordSize);
  420. };
  421. class ExprExprMap : public MapOwnedToOwned<IHqlExpression, IHqlExpression>
  422. {
  423. };
  424. class SubStringInfo;
  425. class MetaInstance;
  426. class KeyedJoinInfo;
  427. class HqlMapTransformer;
  428. class TransformBuilder;
  429. struct HqlCppOptions
  430. {
  431. unsigned defaultImplicitKeyedJoinLimit;
  432. unsigned defaultImplicitIndexReadLimit;
  433. unsigned optimizeDiskFlag;
  434. unsigned activitiesPerCpp;
  435. unsigned maxRecordSize;
  436. unsigned maxInlineDepth;
  437. unsigned inlineStringThreshold;
  438. unsigned maxRootMaybeThorActions;
  439. unsigned maxStaticRowSize;
  440. unsigned maxLocalRowSize;
  441. unsigned insertProjectCostLevel;
  442. unsigned dfaRepeatMax;
  443. unsigned dfaRepeatMaxScore;
  444. unsigned debugNlp;
  445. unsigned regexVersion;
  446. unsigned parseDfaComplexity;
  447. unsigned resourceMaxMemory;
  448. unsigned resourceMaxSockets;
  449. unsigned resourceMaxActivities;
  450. unsigned resourceMaxHeavy;
  451. unsigned resourceMaxDistribute;
  452. unsigned filteredReadSpillThreshold;
  453. unsigned topnLimit;
  454. unsigned specifiedClusterSize;
  455. unsigned globalFoldOptions;
  456. unsigned minimizeSpillSize;
  457. unsigned applyInstantEclTransformationsLimit;
  458. unsigned complexClassesThreshold;
  459. unsigned complexClassesActivityFilter;
  460. CompilerType targetCompiler;
  461. bool peephole;
  462. bool foldConstantCast;
  463. bool optimizeBoolReturn;
  464. bool checkRowOverflow;
  465. bool freezePersists;
  466. bool checkRoxieRestrictions;
  467. bool checkThorRestrictions;
  468. bool allowCsvWorkunitRead;
  469. bool evaluateCoLocalRowInvariantInExtract;
  470. bool allowInlineSpill;
  471. bool spanMultipleCpp;
  472. bool optimizeGlobalProjects;
  473. bool optimizeResourcedProjects;
  474. byte notifyOptimizedProjects;
  475. bool checkAsserts;
  476. bool optimizeLoopInvariant;
  477. bool warnOnImplicitJoinLimit;
  478. bool warnOnImplicitReadLimit;
  479. bool commonUpChildGraphs;
  480. bool detectAmbiguousSelector;
  481. bool allowAmbiguousSelector;
  482. bool regressionTest;
  483. bool recreateMapFromIf;
  484. bool addTimingToWorkunit;
  485. bool reduceNetworkTraffic;
  486. bool optimizeProjectsPreservePersists;
  487. bool showMetaText;
  488. bool resourceConditionalActions;
  489. bool resourceSequential;
  490. bool workunitTemporaries;
  491. bool minimizeWorkunitTemporaries;
  492. bool pickBestEngine;
  493. bool groupedChildIterators;
  494. bool convertJoinToLookup;
  495. bool convertJoinToLookupIfSorted;
  496. bool spotCSE;
  497. bool noAllToLookupConversion;
  498. bool optimizeNonEmpty;
  499. bool allowVariableRoxieFilenames;
  500. bool notifyWorkflowCse;
  501. bool performWorkflowCse;
  502. bool foldConstantDatasets;
  503. bool hoistSimpleGlobal;
  504. bool percolateConstants;
  505. bool percolateFilters;
  506. bool usePrefetchForAllProjects;
  507. bool allFilenamesDynamic;
  508. bool optimizeSteppingPostfilter;
  509. bool moveUnconditionalActions;
  510. bool paranoidCheckNormalized;
  511. bool paranoidCheckDependencies;
  512. bool preventKeyedSplit;
  513. bool preventSteppedSplit;
  514. bool canGenerateSimpleAction;
  515. bool minimizeActivityClasses;
  516. bool includeHelperInGraph;
  517. bool supportsLinkedChildRows;
  518. bool minimizeSkewBeforeSpill;
  519. bool createSerializeForUnknownSize;
  520. bool tempDatasetsUseLinkedRows;
  521. bool implicitLinkedChildRows;
  522. bool mainRowsAreLinkCounted;
  523. bool allowSections;
  524. bool autoPackRecords;
  525. bool commonUniqueNameAttributes;
  526. bool sortIndexPayload;
  527. bool foldFilter;
  528. bool finalizeAllRows;
  529. bool finalizeAllVariableRows;
  530. bool optimizeGraph;
  531. bool optimizeChildGraph ;
  532. bool orderDiskFunnel;
  533. bool alwaysAllowAllNodes;
  534. bool slidingJoins;
  535. bool foldOptimized;
  536. bool globalFold;
  537. bool globalOptimize;
  538. bool applyInstantEclTransformations;
  539. bool calculateComplexity;
  540. bool generateLogicalGraph;
  541. bool generateLogicalGraphOnly;
  542. bool globalAutoHoist;
  543. bool useLinkedRawIterator;
  544. bool useLinkedNormalize;
  545. bool expandRepeatAnyAsDfa;
  546. bool unlimitedResources;
  547. bool hasResourceUseMpForDistribute;
  548. bool resourceUseMpForDistribute;
  549. bool allowThroughSpill;
  550. bool minimiseSpills;
  551. bool spillMultiCondition;
  552. bool spotThroughAggregate;
  553. bool hoistResourced;
  554. bool maximizeLexer;
  555. bool foldStored;
  556. bool spotTopN;
  557. bool groupAllDistribute;
  558. bool spotLocalMerge;
  559. bool spotPotentialKeyedJoins;
  560. bool combineTrivialStored;
  561. bool combineAllStored;
  562. bool allowStoredDuplicate;
  563. bool preserveUniqueSelector;
  564. bool allowScopeMigrate;
  565. bool supportFilterProject;
  566. bool normalizeExplicitCasts;
  567. bool optimizeInlineSource;
  568. bool optimizeDiskSource;
  569. bool optimizeIndexSource;
  570. bool optimizeChildSource;
  571. bool reportLocations;
  572. bool debugGeneratedCpp;
  573. bool addFilesnamesToGraph;
  574. bool normalizeLocations;
  575. bool ensureRecordsHaveSymbols;
  576. bool constantFoldNormalize;
  577. bool constantFoldPostNormalize;
  578. bool optimizeGrouping;
  579. bool showMetaInGraph;
  580. bool spotComplexClasses;
  581. bool optimizeString1Compare;
  582. bool optimizeSpillProject;
  583. bool expressionPeephole;
  584. bool optimizeIncrement;
  585. bool supportsMergeDistribute;
  586. bool debugNlpAsHint;
  587. bool forceVariableWuid;
  588. bool okToDeclareAndAssign; // long time ago gcc had problems doing this for very complex functions
  589. bool noteRecordSizeInGraph;
  590. bool convertRealAssignToMemcpy;
  591. bool allowActivityForKeyedJoin;
  592. bool forceActivityForKeyedJoin;
  593. bool addLibraryInputsToGraph;
  594. bool showRecordCountInGraph;
  595. bool serializeRowsetInExtract;
  596. bool optimizeInSegmentMonitor;
  597. bool supportDynamicRows;
  598. bool testIgnoreMaxLength;
  599. bool limitMaxLength;
  600. bool trackDuplicateActivities; // for diagnosing problems with code becoming duplicated
  601. bool showActivitySizeInGraph;
  602. bool addLocationToCpp;
  603. bool alwaysCreateRowBuilder; // allow paranoid check to ensure builders are built everywhere
  604. bool precalculateFieldOffsets; // useful for some queries, can be expensive
  605. bool generateStaticInlineTables;
  606. bool staticRowsUseStringInitializer;
  607. bool convertWhenExecutedToCompound;
  608. bool standAloneExe;
  609. bool enableCompoundCsvRead;
  610. bool optimizeNestedConditional;
  611. bool createImplicitAliases;
  612. bool combineSiblingGraphs;
  613. bool optimizeSharedGraphInputs;
  614. bool supportsShuffleActivity; // Does the target engine support SHUFFLE?
  615. bool implicitShuffle; // convert sort when partially sortted to shuffle (group,sort,ungroup)
  616. bool implicitBuildIndexShuffle; // use shuffle when building indexes?
  617. bool implicitJoinShuffle; // use shuffle for paritially sorted join inputs when possible
  618. bool implicitGroupShuffle; // use shuffle if some sort conditions match when grouping
  619. bool implicitGroupHashAggregate; // convert aggreate(sort(x,a),{..},a,d) to aggregate(group(sort(x,a),a_,{},d))
  620. bool implicitGroupHashDedup;
  621. bool shuffleLocalJoinConditions;
  622. bool projectNestedTables;
  623. };
  624. //Any information gathered while processing the query should be moved into here, rather than cluttering up the translator class
  625. struct HqlCppDerived
  626. {
  627. HqlCppDerived()
  628. {
  629. }
  630. };
  631. interface IDefRecordElement;
  632. class NlpParseContext;
  633. struct EvaluateCompareInfo
  634. {
  635. public:
  636. EvaluateCompareInfo(node_operator _op) { actionIfDiffer = null_stmt; op = _op; isBoolEquality = false; hasDefault = true; alwaysReturns = false; }
  637. EvaluateCompareInfo(const EvaluateCompareInfo & info)
  638. {
  639. target.set(info.target); actionIfDiffer = info.actionIfDiffer; op = info.op; isBoolEquality = info.isBoolEquality;
  640. alwaysReturns = false;
  641. hasDefault = true;
  642. }
  643. bool isEqualityCompare() const { return op == no_eq; }
  644. IHqlExpression * getEqualityReturnValue() { return isBoolEquality ? createConstant(false) : createIntConstant(1); }
  645. CHqlBoundTarget target;
  646. node_operator op;
  647. StmtKind actionIfDiffer;
  648. bool isBoolEquality;
  649. bool hasDefault;
  650. bool alwaysReturns;
  651. };
  652. class AliasExpansionInfo;
  653. class HashCodeCreator;
  654. class ParentExtract;
  655. enum PEtype {
  656. PETnone,
  657. PETchild, // child query
  658. PETremote, // allnodes
  659. PETloop, // loop
  660. PETnested, // nested class
  661. PETcallback, // callback within a function
  662. PETlibrary, // a library
  663. PETmax };
  664. class HQLCPP_API HqlCppTranslator : public CInterface, implements IHqlCppTranslator
  665. {
  666. //MORE: This is in serious need of refactoring....
  667. friend class HqlCppCaseInfo;
  668. friend class ActivityInstance;
  669. friend class SourceBuilder;
  670. friend class DiskReadBuilder;
  671. friend class IndexReadBuilder;
  672. friend class FetchBuilder;
  673. friend class MonitorExtractor;
  674. friend class NlpParseContext;
  675. friend class KeyedJoinInfo;
  676. friend class ChildGraphBuilder;
  677. public:
  678. HqlCppTranslator(IErrorReceiver * _errors, const char * _soName, IHqlCppInstance * _code, ClusterType _targetClusterType, ICodegenContextCallback *_logger);
  679. ~HqlCppTranslator();
  680. IMPLEMENT_IINTERFACE
  681. //interface IHqlCppTranslator
  682. virtual bool buildCpp(IHqlCppInstance & _code, IHqlExpression * expr);
  683. virtual double getComplexity(IHqlCppInstance & _code, IHqlExpression * expr);
  684. virtual bool spanMultipleCppFiles() { return options.spanMultipleCpp; }
  685. virtual unsigned getNumExtraCppFiles() { return activitiesThisCpp ? curCppFile : 0; }
  686. //Statements.
  687. void buildStmt(BuildCtx & ctx, IHqlExpression * expr);
  688. //General
  689. IReferenceSelector * buildReference(BuildCtx & ctx, IHqlExpression * expr);
  690. IReferenceSelector * buildActiveReference(BuildCtx & ctx, IHqlExpression * expr);
  691. //Scalar processing
  692. void buildExpr(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  693. void buildSimpleExpr(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  694. void buildTempExpr(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, ExpressionFormat format=FormatNatural);
  695. void buildTempExpr(BuildCtx & ctx, BuildCtx & declareCtx, CHqlBoundTarget & target, IHqlExpression * expr, ExpressionFormat format, bool ignoreSetAll);
  696. IHqlExpression * buildSimplifyExpr(BuildCtx & ctx, IHqlExpression * expr);
  697. void buildExprEnsureType(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, ITypeInfo * type);
  698. void buildExprViaTypedTemp(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, ITypeInfo * type);
  699. void buildAssign(BuildCtx & ctx, IHqlExpression * target, IHqlExpression * expr);
  700. void buildExprAssign(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  701. void assign(BuildCtx & ctx, const CHqlBoundTarget & target, CHqlBoundExpr & expr);
  702. void buildIncrementAssign(BuildCtx & ctx, IHqlExpression * target, IHqlExpression * value);
  703. void buildIncrementAssign(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * value);
  704. void buildIncrementAssign(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * value);
  705. void buildExprOrAssign(BuildCtx & ctx, const CHqlBoundTarget * target, IHqlExpression * expr, CHqlBoundExpr * tgt);
  706. //Set processing
  707. void buildSetAssign(BuildCtx & ctx, IHqlCppSetBuilder * builder, IHqlExpression * expr);
  708. void buildSetAssignViaBuilder(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * value);
  709. //Row Processing
  710. IReferenceSelector * buildActiveRow(BuildCtx & ctx, IHqlExpression * expr);
  711. IReferenceSelector * buildNewRow(BuildCtx & ctx, IHqlExpression * expr);
  712. IReferenceSelector * buildNewOrActiveRow(BuildCtx & ctx, IHqlExpression * expr, bool isNew);
  713. void buildRowAssign(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr);
  714. void buildRowAssign(BuildCtx & ctx, IReferenceSelector * target, IReferenceSelector * source);
  715. //Dataset processing.
  716. void buildAnyExpr(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  717. void buildDataset(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, ExpressionFormat format);
  718. void doBuildDataset(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, ExpressionFormat format);
  719. void buildDatasetAssign(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  720. void buildDatasetAssign(BuildCtx & ctx, IHqlCppDatasetBuilder * builder, IHqlExpression * expr);
  721. void ensureDatasetFormat(BuildCtx & ctx, ITypeInfo * type, CHqlBoundExpr & tgt, ExpressionFormat format);
  722. BoundRow * buildDatasetIterate(BuildCtx & ctx, IHqlExpression * _expr, bool needToBreak);
  723. IReferenceSelector * buildDatasetIndex(BuildCtx & ctx, IHqlExpression * expr);
  724. IReferenceSelector * buildDatasetIndexViaIterator(BuildCtx & ctx, IHqlExpression * expr);
  725. IHqlExpression * ensureIteratedRowIsLive(BuildCtx & initctx, BuildCtx & searchctx, BuildCtx & iterctx, BoundRow * row, IHqlExpression * dataset, IHqlExpression * rowExpr);
  726. BoundRow * buildOptimizeSelectFirstRow(BuildCtx & ctx, IHqlExpression * expr);
  727. // Helper functions
  728. void ThrowStringException(int code,const char *format, ...) __attribute__((format(printf, 3, 4))); // override the global function to try and add more context information
  729. void buildAddress(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  730. void buildBlockCopy(BuildCtx & ctx, IHqlExpression * tgt, CHqlBoundExpr & src);
  731. void buildClear(BuildCtx & ctx, IHqlExpression * expr);
  732. void buildClear(BuildCtx & ctx, const CHqlBoundTarget & target);
  733. void buildFilter(BuildCtx & ctx, IHqlExpression * expr);
  734. void buildFilteredReturn(BuildCtx & ctx, IHqlExpression * filter, IHqlExpression * value);
  735. void buildCachedExpr(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  736. void buildReturn(BuildCtx & ctx, IHqlExpression * expr, ITypeInfo * type=NULL);
  737. ABoundActivity * buildActivity(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  738. ABoundActivity * buildCachedActivity(BuildCtx & ctx, IHqlExpression * expr, bool isRoot = false);
  739. ABoundActivity * getConditionalActivity(BuildCtx & ctx, IHqlExpression * expr, bool isChild);
  740. void buildRootActivity(BuildCtx & ctx, IHqlExpression * expr);
  741. bool specialCaseBoolReturn(BuildCtx & ctx, IHqlExpression * expr);
  742. void buildCompoundAssign(BuildCtx & ctx, IHqlExpression * left, IReferenceSelector * leftSelector, IHqlExpression * rightScope, IHqlExpression * rightSelector);
  743. void buildCompoundAssign(BuildCtx & ctx, IHqlExpression * left, IHqlExpression * right);
  744. void associateCounter(BuildCtx & ctx, IHqlExpression * counterExpr, const char * name);
  745. // child dataset processing.
  746. IHqlExpression * buildSpillChildDataset(BuildCtx & ctx, IHqlExpression * expr);
  747. IHqlExpression * forceInlineAssignDataset(BuildCtx & ctx, IHqlExpression * expr);
  748. bool canProcessInline(BuildCtx * ctx, IHqlExpression * expr);
  749. bool canIterateInline(BuildCtx * ctx, IHqlExpression * expr);
  750. bool canAssignInline(BuildCtx * ctx, IHqlExpression * expr);
  751. bool canEvaluateInline(BuildCtx * ctx, IHqlExpression * expr);
  752. void buildAssignChildDataset(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  753. void buildChildDataset(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  754. IHqlExpression * bindFunctionCall(_ATOM name, HqlExprArray & args);
  755. IHqlExpression * bindFunctionCall(_ATOM name, IHqlExpression * arg1);
  756. IHqlExpression * bindFunctionCall(_ATOM name, HqlExprArray & args, ITypeInfo * newType);
  757. IHqlExpression * bindFunctionCall(IHqlExpression * function, HqlExprArray & args);
  758. IHqlExpression * bindTranslatedFunctionCall(_ATOM name, HqlExprArray & args);
  759. IHqlExpression * bindTranslatedFunctionCall(IHqlExpression * function, HqlExprArray & args);
  760. void buildFunctionCall(BuildCtx & ctx, _ATOM name, HqlExprArray & args);
  761. void buildTranslatedFunctionCall(BuildCtx & ctx, _ATOM name, HqlExprArray & args);
  762. void callProcedure(BuildCtx & ctx, _ATOM name, HqlExprArray & args);
  763. void expandFunctions(bool expandInline);
  764. IHqlExpression * needFunction(_ATOM name);
  765. bool registerGlobalUsage(IHqlExpression * filename);
  766. IHqlExpression * queryActiveNamedActivity();
  767. IHqlExpression * queryActiveActivityLocation() const;
  768. void reportWarning(unsigned id, const char * msg, ...) __attribute__((format(printf, 3, 4)));
  769. void reportWarning(IHqlExpression * location, unsigned id, const char * msg, ...) __attribute__((format(printf, 4, 5)));
  770. void reportError(IHqlExpression * location, int code,const char *format, ...) __attribute__((format(printf, 4, 5)));
  771. void reportErrorDirect(IHqlExpression * location, int code,const char *msg, bool alwaysAbort);
  772. void addWorkunitException(WUExceptionSeverity severity, unsigned code, const char * msg, IHqlExpression * location);
  773. void useFunction(IHqlExpression * funcdef);
  774. void useLibrary(const char * libname);
  775. void finalizeResources();
  776. unsigned getHints() { return hints; }
  777. inline bool checkForRowOverflow() const { return options.checkRowOverflow; }
  778. inline bool queryEvaluateCoLocalRowInvariantInExtract() const { return options.evaluateCoLocalRowInvariantInExtract; }
  779. inline byte notifyOptimizedProjectsLevel() { return options.notifyOptimizedProjects; }
  780. inline bool generateAsserts() const { return options.checkAsserts; }
  781. inline bool getCheckRoxieRestrictions() const { return options.checkRoxieRestrictions; }
  782. inline bool queryFreezePersists() const { return options.freezePersists; }
  783. inline bool checkIndexReadLimit() const { return options.warnOnImplicitReadLimit; }
  784. inline unsigned getDefaultImplicitIndexReadLimit() const { return options.defaultImplicitIndexReadLimit; }
  785. inline bool queryCommonUpChildGraphs() const { return options.commonUpChildGraphs; }
  786. inline bool insideLibrary() const { return outputLibraryId != NULL; }
  787. inline bool hasDynamicFilename(IHqlExpression * expr) const { return options.allFilenamesDynamic || hasDynamic(expr); }
  788. inline bool canGenerateStringInline(unsigned len) { return ((options.inlineStringThreshold == 0) || (len <= options.inlineStringThreshold)); }
  789. unsigned getOptimizeFlags() const;
  790. unsigned getSourceAggregateOptimizeFlags() const;
  791. inline void addGlobalOnWarning(IHqlExpression * setMetaExpr) { warningProcessor.addGlobalOnWarning(setMetaExpr); }
  792. ClusterType getTargetClusterType() { return targetClusterType; }
  793. inline bool targetRoxie() { return targetClusterType == RoxieCluster; }
  794. inline bool targetHThor() { return targetClusterType == HThorCluster; }
  795. inline bool targetThor() { return isThorCluster(targetClusterType); }
  796. inline IErrorReceiver * queryErrors() { return errors; }
  797. inline WarningProcessor & queryWarningProcessor() { return warningProcessor; }
  798. void pushMemberFunction(MemberFunction & func);
  799. void popMemberFunction();
  800. unsigned getConsistentUID(IHqlExpression * ptr);
  801. bool insideOnCreate(BuildCtx & ctx);
  802. bool tempRowRequiresFinalize(IHqlExpression * record) const;
  803. void convertBoundDatasetToFirstRow(IHqlExpression * expr, CHqlBoundExpr & bound);
  804. void convertBoundRowToDataset(BuildCtx & ctx, CHqlBoundExpr & bound, const BoundRow * row, ExpressionFormat preferredFormat);
  805. //Be very careful before calling this.......
  806. //Either isIndependentMaybeShared is set - which case the item inserted into the initctx can have no dependencies
  807. //or isIndependentMaybeShared is false, and the code that is inserted is never implicitly shared.
  808. bool getInvariantMemberContext(BuildCtx & ctx, BuildCtx * * declarectx, BuildCtx * * initctx, bool isIndependentMaybeShared, bool invariantEachStart);
  809. public:
  810. BoundRow * bindSelf(BuildCtx & ctx, IHqlExpression * dataset, const char * builder);
  811. BoundRow * bindSelf(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * expr, IHqlExpression * builder);
  812. BoundRow * bindTableCursor(BuildCtx & ctx, IHqlExpression * dataset, const char * bound, bool isLinkCounted, node_operator no_side, IHqlExpression * selSeq);
  813. BoundRow * bindTableCursor(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * bound, node_operator no_side, IHqlExpression * selSeq);
  814. BoundRow * bindCsvTableCursor(BuildCtx & ctx, IHqlExpression * dataset, const char * name, node_operator side, IHqlExpression * selSeq, bool translateVirtuals, _ATOM encoding);
  815. BoundRow * bindCsvTableCursor(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * bound, node_operator side, IHqlExpression * selSeq, bool translateVirtuals, _ATOM encoding);
  816. BoundRow * bindXmlTableCursor(BuildCtx & ctx, IHqlExpression * dataset, const char * name, node_operator side, IHqlExpression * selSeq, bool translateVirtuals);
  817. BoundRow * bindXmlTableCursor(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * bound, node_operator side, IHqlExpression * selSeq, bool translateVirtuals);
  818. BoundRow * createTableCursor(IHqlExpression * dataset, IHqlExpression * bound, node_operator side, IHqlExpression * selSeq);
  819. BoundRow * createTableCursor(IHqlExpression * dataset, const char * name, bool isLinkCounted, node_operator side, IHqlExpression * selSeq);
  820. BoundRow * bindRow(BuildCtx & ctx, IHqlExpression * expr, IHqlExpression * bound);
  821. BoundRow * bindRow(BuildCtx & ctx, IHqlExpression * expr, const char * name);
  822. BoundRow * bindConstantRow(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & bound);
  823. BoundRow * bindSelectorAsSelf(BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * expr);
  824. BoundRow * bindSelectorAsRootRow(BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * expr);
  825. void bindRows(BuildCtx & ctx, node_operator side, IHqlExpression * selSeq, IHqlExpression * rowsid, IHqlExpression * dataset, const char * numText, const char * rowsText, bool mainRowsAreLinkCounted);
  826. BoundRow * bindTableCursorOrRow(BuildCtx & ctx, IHqlExpression * expr, const char * name);
  827. BoundRow * recreateTableCursor(IHqlExpression * dataset, BoundRow * row, node_operator side, IHqlExpression * selSeq);
  828. BoundRow * rebindTableCursor(BuildCtx & ctx, IHqlExpression * dataset, BoundRow * row, node_operator no_side, IHqlExpression * selSeq);
  829. void finishSelf(BuildCtx & ctx, BoundRow * self, BoundRow * target);
  830. void ensureRowAllocated(BuildCtx & ctx, const char * builder);
  831. void ensureRowAllocated(BuildCtx & ctx, BoundRow * row);
  832. inline BoundRow * bindTableCursor(BuildCtx & ctx, IHqlExpression * dataset, const char * bound, node_operator side, IHqlExpression * selSeq)
  833. { return bindTableCursor(ctx, dataset, bound, false, side, selSeq); }
  834. inline BoundRow * bindTableCursor(BuildCtx & ctx, IHqlExpression * dataset, const char * bound)
  835. { return bindTableCursor(ctx, dataset, bound, false, no_none, NULL); }
  836. inline BoundRow * bindTableCursor(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * bound)
  837. { return bindTableCursor(ctx, dataset, bound, no_none, NULL); }
  838. IHqlExpression * getRtlFieldKey(IHqlExpression * expr, IHqlExpression * ownerRecord);
  839. unsigned buildRtlField(StringBuffer * instanceName, IHqlExpression * fieldKey);
  840. unsigned buildRtlType(StringBuffer & instanceName, ITypeInfo * type);
  841. unsigned buildRtlRecordFields(StringBuffer & instanceName, IHqlExpression * record, IHqlExpression * rowRecord);
  842. unsigned expandRtlRecordFields(StringBuffer & fieldListText, IHqlExpression * record, IHqlExpression * rowRecord);
  843. unsigned buildRtlIfBlockField(StringBuffer & instanceName, IHqlExpression * ifblock, IHqlExpression * rowRecord);
  844. unsigned getRtlFieldInfo(StringBuffer & fieldInfoName, IHqlExpression * field, IHqlExpression * rowRecord);
  845. void buildMetaInfo(MetaInstance & instance);
  846. IHqlExpression * buildMetaParameter(IHqlExpression * arg);
  847. void buildMetaForRecord(StringBuffer & name, IHqlExpression * record);
  848. void buildMetaForSerializedRecord(StringBuffer & name, IHqlExpression * record, bool isGrouped);
  849. BoundRow * createBoundRow(IHqlExpression * dataset, IHqlExpression * bound);
  850. void getRecordSize(BuildCtx & ctx, IHqlExpression * dataset, CHqlBoundExpr & bound);
  851. BoundRow * resolveSelectorDataset(BuildCtx & ctx, IHqlExpression * dataset);
  852. BoundRow * resolveDatasetRequired(BuildCtx & ctx, IHqlExpression * expr);
  853. ColumnToOffsetMap * queryRecordOffsetMap(IHqlExpression * record);
  854. IHqlExpression * queryRecord(BuildCtx & ctx, IHqlExpression * expr);
  855. RecordOffsetMap & queryRecordMap() { return recordMap; }
  856. unsigned getDefaultMaxRecordSize() { return options.maxRecordSize; }
  857. void buildReturnRecordSize(BuildCtx & ctx, BoundRow * cursor);
  858. bool isFixedRecordSize(IHqlExpression * record);
  859. bool recordContainsIfBlock(IHqlExpression * record);
  860. unsigned getFixedRecordSize(IHqlExpression * record);
  861. unsigned getMaxRecordSize(IHqlExpression * record);
  862. IHqlExpression * getRecordSize(IHqlExpression * dataset);
  863. unsigned getCsvMaxLength(IHqlExpression * csvAttr);
  864. IHqlExpression * createRecordInheritMaxLength(HqlExprArray & fields, IHqlExpression * donor);
  865. void ensureRowSerializer(StringBuffer & serializerName, BuildCtx & ctx, IHqlExpression * record, _ATOM kind);
  866. void ensureRowPrefetcher(StringBuffer & prefetcherName, BuildCtx & ctx, IHqlExpression * record);
  867. IHqlExpression * createRowSerializer(BuildCtx & ctx, IHqlExpression * record, _ATOM kind);
  868. AliasKind buildExprInCorrectContext(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, bool evaluateLocally);
  869. ParentExtract * createExtractBuilder(BuildCtx & ctx, PEtype type, IHqlExpression * graphId, IHqlExpression * expr, bool doDeclare);
  870. ParentExtract * createExtractBuilder(BuildCtx & ctx, PEtype type, IHqlExpression * graphId, GraphLocalisation localisation, bool doDeclare);
  871. void buildDefaultRow(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & bound);
  872. void buildNullRow(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & bound);
  873. void buildTransformBody(BuildCtx & ctx, IHqlExpression * transform, IHqlExpression * left, IHqlExpression * right, IHqlExpression * self, IHqlExpression * selSeq);
  874. BoundRow * buildTransformCursors(BuildCtx & ctx, IHqlExpression * transform, IHqlExpression * left, IHqlExpression * right, IHqlExpression * self, IHqlExpression * selSeq);
  875. void doBuildTransformBody(BuildCtx & ctx, IHqlExpression * transform, BoundRow * selfCursor);
  876. void noteXpathUsed(const char * xpath);
  877. void noteXpathUsed(IHqlExpression * expr);
  878. HqlCppOptions const & queryOptions() const { return options; }
  879. ITimeReporter * queryTimeReporter() const { return timeReporter; }
  880. void updateClusterType();
  881. bool buildCode(IHqlExpression * exprlist, const char * embeddedLibraryName, bool isEmbeddedLibrary);
  882. inline StringBuffer & generateExprCpp(StringBuffer & out, IHqlExpression * expr)
  883. {
  884. return ::generateExprCpp(out, expr, options.targetCompiler);
  885. }
  886. inline StringBuffer & generateTypeCpp(StringBuffer & out, ITypeInfo * type, const char * name)
  887. {
  888. return ::generateTypeCpp(out, type, name, options.targetCompiler);
  889. }
  890. void setTargetClusterType(ClusterType clusterType);
  891. void checkAbort();
  892. public:
  893. //various helper functions.
  894. IHqlExpression * addBigLiteral(const char *lit, unsigned litLen);
  895. IHqlExpression * addLiteral(const char * text);
  896. IHqlExpression * addDataLiteral(const char *lit, unsigned litLen);
  897. IHqlExpression * addStringLiteral(const char *lit);
  898. IHqlExpression * associateLocalFailure(BuildCtx & ctx, const char * exceptionName);
  899. IHqlExpression * convertBoundStringToChar(const CHqlBoundExpr & bound);
  900. void createTempFor(BuildCtx & ctx, ITypeInfo * exprType, CHqlBoundTarget & target, typemod_t modifier, ExpressionFormat format);
  901. void createTempFor(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundTarget & target);
  902. BoundRow * declareTempRow(BuildCtx & ctx, BuildCtx & codectx, IHqlExpression * expr);
  903. BoundRow * createRowBuilder(BuildCtx & ctx, BoundRow * targetRow);
  904. void finalizeTempRow(BuildCtx & ctx, BoundRow * targetRow, BoundRow * rowBuilder);
  905. BoundRow * declareTempAnonRow(BuildCtx & ctx, BuildCtx & codectx, IHqlExpression * record);
  906. BoundRow * declareLinkedRow(BuildCtx & ctx, IHqlExpression * expr, bool isMember);
  907. BoundRow * declareStaticRow(BuildCtx & ctx, IHqlExpression * expr);
  908. void expandTranslated(IHqlExpression * expr, CHqlBoundExpr & tgt);
  909. IHqlExpression * getBoundCount(const CHqlBoundExpr & bound);
  910. IHqlExpression * getBoundLength(const CHqlBoundExpr & bound);
  911. IHqlExpression * getBoundSize(const CHqlBoundExpr & bound);
  912. IHqlExpression * getBoundSize(ITypeInfo * type, IHqlExpression * length, IHqlExpression * data);
  913. IHqlExpression * getElementPointer(IHqlExpression * source);
  914. IHqlExpression * getIndexedElementPointer(IHqlExpression * source, IHqlExpression * index);
  915. IHqlExpression * getIndexedElementPointer(IHqlExpression * source, unsigned index);
  916. IHqlExpression * getListLength(BuildCtx & ctx, IHqlExpression * expr);
  917. void getRecordECL(IHqlExpression * record, StringBuffer & eclText);
  918. void ensureHasAddress(BuildCtx & ctx, CHqlBoundExpr & tgt);
  919. void normalizeBoundExpr(BuildCtx & ctx, CHqlBoundExpr & bound);
  920. bool allowEmbeddedCpp();
  921. void checkPipeAllowed();
  922. IWorkUnit * wu() { return code->workunit; }
  923. void useInclude(const char * name) { code->useInclude(name); }
  924. HqlCppInstance * queryCode() const { return code; }
  925. unsigned curSubGraphId(BuildCtx & ctx);
  926. unsigned cppIndexNextActivity(bool isChildActivity);
  927. void buildAssignToTemp(BuildCtx & ctx, IHqlExpression * variable, IHqlExpression * expr); // create a bound target for the variable and assign
  928. void queryAddResultDependancy(ABoundActivity & whoAmIActivity, IHqlExpression * seq, IHqlExpression * name);
  929. void associateRemoteResult(ActivityInstance & instance, IHqlExpression * seq, IHqlExpression * name);
  930. IHqlCppSetCursor * createSetSelector(BuildCtx & ctx, IHqlExpression * expr);
  931. IHqlCppSetBuilder * createTempSetBuilder(ITypeInfo * type, IHqlExpression * allVar);
  932. IHqlCppSetBuilder * createInlineSetBuilder(ITypeInfo * type, IHqlExpression * allVar, IHqlExpression * size, IHqlExpression * address);
  933. IHqlCppDatasetCursor * createDatasetSelector(BuildCtx & ctx, IHqlExpression * expr);
  934. IHqlCppDatasetBuilder * createBlockedDatasetBuilder(IHqlExpression * record);
  935. IHqlCppDatasetBuilder * createSingleRowTempDatasetBuilder(IHqlExpression * record, BoundRow * row);
  936. IHqlCppDatasetBuilder * createInlineDatasetBuilder(IHqlExpression * record, IHqlExpression * size, IHqlExpression * address);
  937. IHqlCppDatasetBuilder * createChoosenDatasetBuilder(IHqlExpression * record, IHqlExpression * maxCount);
  938. IHqlCppDatasetBuilder * createLimitedDatasetBuilder(IHqlExpression * record, IHqlExpression * maxCount);
  939. IHqlCppDatasetBuilder * createLinkedDatasetBuilder(IHqlExpression * record, IHqlExpression * choosenLimit = NULL);
  940. IReferenceSelector * createSelfSelect(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr, IHqlExpression * rootSelector);
  941. IReferenceSelector * createReferenceSelector(BoundRow * cursor, IHqlExpression * path);
  942. IReferenceSelector * createReferenceSelector(BoundRow * cursor);
  943. IHqlExpression * convertBetweenCountAndSize(const CHqlBoundExpr & bound, bool getLength);
  944. void assignBound(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * rhs); // assign rhs to
  945. void assignBoundToTemp(BuildCtx & ctx, IHqlExpression * lhs, IHqlExpression * rhs);
  946. bool expandFunctionPrototype(StringBuffer & s, IHqlExpression * funcdef);
  947. void expandFunctionPrototype(BuildCtx & ctx, IHqlExpression * funcdef);
  948. void buildFunctionDefinition(IHqlExpression * funcdef);
  949. void assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & target, CHqlBoundExpr & expr);
  950. void assignCastUnknownLength(BuildCtx & ctx, const CHqlBoundTarget & target, CHqlBoundExpr & pure);
  951. void assignSwapInt(BuildCtx & ctx, ITypeInfo * to, const CHqlBoundTarget & target, CHqlBoundExpr & pure);
  952. void buildAssignViaTemp(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  953. void buildRecordSerializeExtract(BuildCtx & ctx, IHqlExpression * memoryRecord);
  954. void doBuildSetAssignAndCast(BuildCtx & ctx, IHqlCppSetBuilder * builder, IHqlExpression * value);
  955. IHqlExpression * createWrapperTemp(BuildCtx & ctx, ITypeInfo * type, typemod_t modifier);
  956. void doBuildExprAssign(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  957. void doBuildBoolAssign(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  958. void doBuildChoose(BuildCtx & ctx, const CHqlBoundTarget * target, IHqlExpression * expr);
  959. void buildExprAssignViaType(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr, ITypeInfo * type);
  960. void buildExprAssignViaString(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr, unsigned len);
  961. void doBuildAssignAddSets(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * value);
  962. void doBuildAssignAggregate(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  963. void doBuildAssignAll(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  964. void doBuildAssignAnd(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr, bool invert);
  965. void doBuildAssignCall(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * src);
  966. void doBuildAssignCast(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * src);
  967. void doBuildAssignCatch(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  968. void doBuildAssignChoose(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  969. void doBuildAssignCompare(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  970. void doBuildAssignConcat(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  971. void doBuildAssignCount(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  972. void doBuildAssignDivide(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  973. void doBuildAssignEventExtra(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  974. void doBuildAssignEventName(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  975. void doBuildAssignFailMessage(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  976. void doBuildAssignFormat(_ATOM func, BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  977. void doBuildAssignGetResult(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  978. void doBuildAssignGetGraphResult(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  979. void doBuildAssignHashCrc(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  980. void doBuildAssignHashElement(BuildCtx & ctx, HashCodeCreator & creator, IHqlExpression * elem);
  981. void doBuildAssignHashElement(BuildCtx & ctx, HashCodeCreator & creator, IHqlExpression * elem, IHqlExpression * record);
  982. void doBuildAssignHashMd5(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  983. void doBuildAssignIdToBlob(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  984. void doBuildAssignIf(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  985. void doBuildAssignIn(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  986. void doBuildAssignInCreateSet(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  987. void doBuildAssignInStored(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  988. void doBuildAssignIndex(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  989. void doBuildAssignList(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  990. void doBuildAssignLoopCounter(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  991. void doBuildAssignOr(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  992. void doBuildAssignOrder(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  993. void doBuildAssignUnicodeOrder(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  994. void doBuildAssignRegexFindReplace(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  995. void doBuildAssignSubString(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  996. void doBuildAssignToXml(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  997. void doBuildAssignTrim(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  998. void doBuildAssignWhich(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  999. void doBuildAssignWuid(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  1000. void doBuildCaseInfo(IHqlExpression * expr, HqlCppCaseInfo & info);
  1001. void doBuildInCaseInfo(IHqlExpression * expr, HqlCppCaseInfo & info, IHqlExpression * normalizedValues = NULL);
  1002. void doBuildAssignToFromUnicode(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  1003. void buildAssignLinkedDataset(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  1004. void buildAssignSerializedDataset(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr);
  1005. void buildLinkedDataset(BuildCtx & ctx, ITypeInfo * type, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1006. void buildSerializedDataset(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1007. void buildDatasetAssignAggregate(BuildCtx & ctx, IHqlCppDatasetBuilder * target, IHqlExpression * expr);
  1008. void buildDatasetAssignInlineTable(BuildCtx & ctx, IHqlCppDatasetBuilder * target, IHqlExpression * expr);
  1009. void buildDatasetAssignJoin(BuildCtx & ctx, IHqlCppDatasetBuilder * target, IHqlExpression * expr);
  1010. void buildDatasetAssignProject(BuildCtx & ctx, IHqlCppDatasetBuilder * target, IHqlExpression * expr);
  1011. void buildDatasetAssignTempTable(BuildCtx & ctx, IHqlCppDatasetBuilder * target, IHqlExpression * expr);
  1012. void buildDatasetAssignXmlProject(BuildCtx & ctx, IHqlCppDatasetBuilder * target, IHqlExpression * expr);
  1013. BoundRow * buildDatasetIterateSelectN(BuildCtx & ctx, IHqlExpression * expr, bool needToBreak);
  1014. BoundRow * buildDatasetIterateChoosen(BuildCtx & ctx, IHqlExpression * expr, bool needToBreak);
  1015. BoundRow * buildDatasetIterateLimit(BuildCtx & ctx, IHqlExpression * expr, bool needToBreak);
  1016. BoundRow * buildDatasetIterateProject(BuildCtx & ctx, IHqlExpression * expr, bool needToBreak);
  1017. BoundRow * buildDatasetIterateUserTable(BuildCtx & ctx, IHqlExpression * expr, bool needToBreak);
  1018. BoundRow * buildDatasetIterateSpecialTempTable(BuildCtx & ctx, IHqlExpression * expr, bool needToBreak);
  1019. BoundRow * buildDatasetIterateStreamedCall(BuildCtx & ctx, IHqlExpression * expr, bool needToBreak);
  1020. void doBuildDatasetLimit(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, ExpressionFormat format);
  1021. bool doBuildDatasetInlineTable(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, ExpressionFormat format);
  1022. void doBuildCheckDatasetLimit(BuildCtx & ctx, IHqlExpression * expr, const CHqlBoundExpr & bound);
  1023. void doBuildRowAssignAggregate(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr);
  1024. void doBuildRowAssignAggregateClear(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr);
  1025. void doBuildRowAssignAggregateNext(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr, bool isSingleExists, IHqlExpression * guard);
  1026. void doBuildRowAssignNullRow(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr);
  1027. void doBuildRowAssignProject(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr);
  1028. void doBuildRowAssignUserTable(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr);
  1029. void doBuildRowAssignProjectRow(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr);
  1030. void doBuildRowAssignCreateRow(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr);
  1031. void doBuildRowAssignSerializeRow(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr);
  1032. IReferenceSelector * doBuildRowDeserializeRow(BuildCtx & ctx, IHqlExpression * expr);
  1033. IReferenceSelector * doBuildRowFromXML(BuildCtx & ctx, IHqlExpression * expr);
  1034. IReferenceSelector * doBuildRowIdToBlob(BuildCtx & ctx, IHqlExpression * expr, bool isNew);
  1035. IReferenceSelector * doBuildRowIf(BuildCtx & ctx, IHqlExpression * expr);
  1036. IReferenceSelector * doBuildRowMatchAttr(BuildCtx & ctx, IHqlExpression * expr);
  1037. IReferenceSelector * doBuildRowMatchRow(BuildCtx & ctx, IHqlExpression * expr, bool isNew);
  1038. IReferenceSelector * doBuildRowSelectTop(BuildCtx & ctx, IHqlExpression * expr);
  1039. IReferenceSelector * doBuildRowViaTemp(BuildCtx & ctx, IHqlExpression * expr);
  1040. IReferenceSelector * doBuildRowCreateRow(BuildCtx & ctx, IHqlExpression * expr);
  1041. IReferenceSelector * doBuildRowNull(BuildCtx & ctx, IHqlExpression * expr);
  1042. void buildConstRow(IHqlExpression * record, IHqlExpression * rowData, CHqlBoundExpr & bound);
  1043. bool doBuildRowConstantNull(IHqlExpression * expr, CHqlBoundExpr & bound);
  1044. bool doBuildRowConstantTransform(IHqlExpression * transform, CHqlBoundExpr & bound);
  1045. void doBuildRowIfBranch(BuildCtx & initctx, BuildCtx & ctx, BoundRow * targetRow, IHqlExpression * branchExpr);
  1046. void doBuildReturnCompare(BuildCtx & ctx, IHqlExpression * expr, node_operator op, bool isBoolEquality);
  1047. void buildReturnOrder(BuildCtx & ctx, IHqlExpression *sortList, const DatasetReference & dataset);
  1048. unique_id_t buildGraphLoopSubgraph(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * selSeq, IHqlExpression * rowsid, IHqlExpression * body, IHqlExpression * counter, unique_id_t containerId, bool multiInstance);
  1049. unique_id_t buildRemoteSubgraph(BuildCtx & ctx, IHqlExpression * dataset, unique_id_t containerId);
  1050. void doBuildCall(BuildCtx & ctx, const CHqlBoundTarget * tgt, IHqlExpression * expr, CHqlBoundExpr * result);
  1051. IHqlExpression * doBuildInternalFunction(IHqlExpression * funcdef);
  1052. IHqlExpression * doBuildCharLength(BuildCtx & ctx, IHqlExpression * expr);
  1053. void doBuildHashMd5Element(BuildCtx & ctx, IHqlExpression * elem, CHqlBoundExpr & state);
  1054. AliasKind doBuildAliasValue(BuildCtx & ctx, IHqlExpression * value, CHqlBoundExpr & tgt);
  1055. void pushCluster(BuildCtx & ctx, IHqlExpression * cluster);
  1056. void popCluster(BuildCtx & ctx);
  1057. void noteResultAccessed(BuildCtx & ctx, IHqlExpression * seq, IHqlExpression * name);
  1058. void noteResultDefined(BuildCtx & ctx, ActivityInstance * activityInstance, IHqlExpression * seq, IHqlExpression * name, bool alwaysExecuted);
  1059. //Expressions:
  1060. void doBuildExprAbs(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1061. void doBuildExprAdd(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1062. void doBuildExprAggregate(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1063. void doBuildExprAlias(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr * tgt);
  1064. void doBuildExprAll(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1065. void doBuildExprBlobToId(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1066. void doBuildExprArith(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1067. void doBuildExprCall(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1068. void doBuildExprCast(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1069. void doBuildExprCast(BuildCtx & ctx, ITypeInfo * type, CHqlBoundExpr & pure, CHqlBoundExpr & tgt);
  1070. void doBuildExprCompare(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1071. void doBuildExprCompareElement(BuildCtx & ctx, node_operator comp_op, IHqlExpression * lhs, IHqlExpression * rhs, CHqlBoundExpr & tgt);
  1072. void doBuildExprCount(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1073. void doBuildExprCounter(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1074. void doBuildExprCppBody(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr * tgt);
  1075. void doBuildExprDivide(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1076. void doBuildExprEvaluate(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1077. void doBuildExprExists(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1078. void doBuildExprFailCode(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1079. void doBuildExprField(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1080. void doBuildExprFileLogicalName(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1081. void doBuildExprFilepos(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1082. void doBuildExprFormat(_ATOM func, BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1083. void doBuildExprGetGraphResult(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, ExpressionFormat format);
  1084. void doBuildExprGetResult(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1085. void doBuildExprIdToBlob(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1086. void doBuildExprIf(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1087. void doBuildExprIndex(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1088. void doBuildExprIsValid(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1089. void doBuildExprList(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1090. void doBuildExprConstList(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1091. void doBuildExprDynList(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1092. void doBuildExprNegate(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1093. void doBuildExprNot(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1094. void doBuildExprOffsetOf(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1095. void doBuildExprOrdered(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1096. void doBuildExprRank(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1097. void doBuildExprRanked(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1098. void doBuildExprRegexFindReplace(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & bound);
  1099. void doBuildExprRound(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1100. void doBuildExprSelect(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1101. void doBuildExprSizeof(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1102. void doBuildExprSubString(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1103. void doBuildExprSysFunc(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, IAtom * funcName);
  1104. void doBuildExprTransfer(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1105. void doBuildExprTrim(BuildCtx & ctx, IHqlExpression * target, CHqlBoundExpr & tgt);
  1106. void doBuildExprTrunc(BuildCtx & ctx, IHqlExpression * target, CHqlBoundExpr & tgt);
  1107. void doBuildExprToFromUnicode(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1108. void doBuildExprKeyUnicode(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1109. void doBuildExprWuid(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1110. void doBuildExprXmlText(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1111. void doBuildExprXmlUnicode(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1112. bool doBuildExprInfiniteSubString(BuildCtx & ctx, SubStringInfo & info, CHqlBoundExpr & tgt);
  1113. bool doBuildExprSpecialSubString(BuildCtx & ctx, SubStringInfo & info, CHqlBoundExpr & tgt);
  1114. void doBuildExprAnySubString(BuildCtx & ctx, SubStringInfo & info, CHqlBoundExpr & tgt);
  1115. bool doBuildExprSetCompare(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1116. void doBuildExprSetCompareAll(BuildCtx & ctx, IHqlExpression * set, CHqlBoundExpr & tgt, bool invert);
  1117. void doBuildExprSetCompareNone(BuildCtx & ctx, IHqlExpression * set, CHqlBoundExpr & tgt, bool invert);
  1118. void doBuildAggregateList(BuildCtx & ctx, const CHqlBoundTarget * target, IHqlExpression * expr, CHqlBoundExpr * tgt);
  1119. bool doBuildAggregateMinMaxList(BuildCtx & ctx, const CHqlBoundTarget * target, IHqlExpression * expr, IHqlExpression * list, CHqlBoundExpr * tgt, node_operator compareOp);
  1120. void buildWorkflow(WorkflowArray & workflow);
  1121. void buildWorkflowItem(BuildCtx & ctx, IHqlStmt * switchStmt, unsigned wfid, IHqlExpression * expr);
  1122. void buildWorkflowPersistCheck(BuildCtx & ctx, IHqlExpression * expr);
  1123. IHqlExpression * cvtGetEnvToCall(IHqlExpression * expr);
  1124. //Statements
  1125. void doBuildStmtApply(BuildCtx & ctx, IHqlExpression * expr);
  1126. void doBuildStmtAssert(BuildCtx & ctx, IHqlExpression * expr);
  1127. void doBuildStmtAssign(BuildCtx & ctx, IHqlExpression * target, IHqlExpression * expr);
  1128. void doBuildStmtAssignModify(BuildCtx & ctx, IHqlExpression * target, IHqlExpression * expr, node_operator op);
  1129. void doBuildStmtCall(BuildCtx & ctx, IHqlExpression * expr);
  1130. void doBuildStmtCluster(BuildCtx & ctx, IHqlExpression * expr);
  1131. void doBuildStmtEnsureResult(BuildCtx & ctx, IHqlExpression * expr);
  1132. void doBuildStmtFail(BuildCtx & ctx, IHqlExpression * expr);
  1133. void doBuildStmtIf(BuildCtx & ctx, IHqlExpression * expr);
  1134. void doBuildStmtNotify(BuildCtx & ctx, IHqlExpression * expr);
  1135. void doBuildStmtOutput(BuildCtx & ctx, IHqlExpression * expr);
  1136. void doBuildStmtSetResult(BuildCtx & ctx, IHqlExpression * expr);
  1137. void doBuildStmtSkip(BuildCtx & ctx, IHqlExpression * expr, bool * canReachFollowing);
  1138. void doBuildStmtUpdate(BuildCtx & ctx, IHqlExpression * expr);
  1139. void doBuildStmtWait(BuildCtx & ctx, IHqlExpression * expr);
  1140. bool buildNWayInputs(CIArrayOf<ABoundActivity> & inputs, BuildCtx & ctx, IHqlExpression * input);
  1141. //Activities.
  1142. ABoundActivity * doBuildActivityAction(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1143. ABoundActivity * doBuildActivityAggregate(BuildCtx & ctx, IHqlExpression * expr);
  1144. ABoundActivity * doBuildActivityApply(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1145. ABoundActivity * doBuildActivityAssert(BuildCtx & ctx, IHqlExpression * expr);
  1146. ABoundActivity * doBuildActivityCacheAlias(BuildCtx & ctx, IHqlExpression * expr);
  1147. ABoundActivity * doBuildActivityCallSideEffect(BuildCtx & ctx, IHqlExpression * expr);
  1148. ABoundActivity * doBuildActivityCase(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1149. ABoundActivity * doBuildActivityCatch(BuildCtx & ctx, IHqlExpression * expr);
  1150. ABoundActivity * doBuildActivityChildAggregate(BuildCtx & ctx, IHqlExpression * expr);
  1151. ABoundActivity * doBuildActivityChildDataset(BuildCtx & ctx, IHqlExpression * expr);
  1152. ABoundActivity * doBuildActivityChildGroupAggregate(BuildCtx & ctx, IHqlExpression * expr);
  1153. ABoundActivity * doBuildActivityChildNormalize(BuildCtx & ctx, IHqlExpression * expr);
  1154. ABoundActivity * doBuildActivityChooseSets(BuildCtx & ctx, IHqlExpression * expr);
  1155. ABoundActivity * doBuildActivityChooseSetsEx(BuildCtx & ctx, IHqlExpression * expr);
  1156. ABoundActivity * doBuildActivityCloned(BuildCtx & ctx, IHqlExpression * expr);
  1157. ABoundActivity * doBuildActivityCombine(BuildCtx & ctx, IHqlExpression * expr);
  1158. ABoundActivity * doBuildActivityCombineGroup(BuildCtx & ctx, IHqlExpression * expr);
  1159. ABoundActivity * doBuildActivityCompoundSelectNew(BuildCtx & ctx, IHqlExpression * expr);
  1160. ABoundActivity * doBuildActivityConcat(BuildCtx & ctx, IHqlExpression * expr);
  1161. ABoundActivity * doBuildActivityCountTransform(BuildCtx & ctx, IHqlExpression * expr);
  1162. ABoundActivity * doBuildActivityCreateRow(BuildCtx & ctx, IHqlExpression * expr, bool isDataset);
  1163. ABoundActivity * doBuildActivityXmlRead(BuildCtx & ctx, IHqlExpression * expr);
  1164. ABoundActivity * doBuildActivityDedup(BuildCtx & ctx, IHqlExpression * expr);
  1165. ABoundActivity * doBuildActivityDefineSideEffect(BuildCtx & ctx, IHqlExpression * expr);
  1166. ABoundActivity * doBuildActivityDenormalize(BuildCtx & ctx, IHqlExpression * expr);
  1167. ABoundActivity * doBuildActivityDiskAggregate(BuildCtx & ctx, IHqlExpression * expr);
  1168. ABoundActivity * doBuildActivityDiskGroupAggregate(BuildCtx & ctx, IHqlExpression * expr);
  1169. ABoundActivity * doBuildActivityDiskNormalize(BuildCtx & ctx, IHqlExpression * expr);
  1170. ABoundActivity * doBuildActivityDiskRead(BuildCtx & ctx, IHqlExpression * expr);
  1171. ABoundActivity * doBuildActivityDistribute(BuildCtx & ctx, IHqlExpression * expr);
  1172. ABoundActivity * doBuildActivityDistribution(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1173. ABoundActivity * doBuildActivitySectionInput(BuildCtx & ctx, IHqlExpression * expr);
  1174. ABoundActivity * doBuildActivityEnth(BuildCtx & ctx, IHqlExpression * expr);
  1175. ABoundActivity * doBuildActivityExecuteWhen(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1176. ABoundActivity * doBuildActivityForceLocal(BuildCtx & ctx, IHqlExpression * expr);
  1177. ABoundActivity * doBuildActivityFetch(BuildCtx & ctx, IHqlExpression * expr);
  1178. ABoundActivity * doBuildActivityFilter(BuildCtx & ctx, IHqlExpression * expr);
  1179. ABoundActivity * doBuildActivityFilterGroup(BuildCtx & ctx, IHqlExpression * expr);
  1180. ABoundActivity * doBuildActivityGetGraphResult(BuildCtx & ctx, IHqlExpression * expr);
  1181. ABoundActivity * doBuildActivityGetGraphLoopResult(BuildCtx & ctx, IHqlExpression * expr);
  1182. ABoundActivity * doBuildActivityGraphLoop(BuildCtx & ctx, IHqlExpression * expr);
  1183. ABoundActivity * doBuildActivityGroup(BuildCtx & ctx, IHqlExpression * expr);
  1184. ABoundActivity * doBuildActivityIf(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1185. ABoundActivity * doBuildActivityIndexAggregate(BuildCtx & ctx, IHqlExpression * expr);
  1186. ABoundActivity * doBuildActivityIndexGroupAggregate(BuildCtx & ctx, IHqlExpression * expr);
  1187. ABoundActivity * doBuildActivityIndexNormalize(BuildCtx & ctx, IHqlExpression * expr);
  1188. ABoundActivity * doBuildActivityIndexRead(BuildCtx & ctx, IHqlExpression * expr);
  1189. ABoundActivity * doBuildActivityInlineTable(BuildCtx & ctx, IHqlExpression * expr);
  1190. ABoundActivity * doBuildActivityIterate(BuildCtx & ctx, IHqlExpression * expr);
  1191. ABoundActivity * doBuildActivityJoin(BuildCtx & ctx, IHqlExpression * expr);
  1192. ABoundActivity * doBuildActivityJoinOrDenormalize(BuildCtx & ctx, IHqlExpression * expr);
  1193. ABoundActivity * doBuildActivityKeyDiff(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1194. ABoundActivity * doBuildActivityKeyedJoinOrDenormalize(BuildCtx & ctx, IHqlExpression * expr);
  1195. ABoundActivity * doBuildActivityKeyedDistribute(BuildCtx & ctx, IHqlExpression * expr);
  1196. ABoundActivity * doBuildActivityKeyPatch(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1197. ABoundActivity * doBuildActivityLibraryInstance(BuildCtx & ctx, IHqlExpression * expr);
  1198. ABoundActivity * doBuildActivityLibrarySelect(BuildCtx & ctx, IHqlExpression * expr);
  1199. ABoundActivity * doBuildActivityLimit(BuildCtx & ctx, IHqlExpression * expr);
  1200. ABoundActivity * doBuildActivityLinkedRawChildDataset(BuildCtx & ctx, IHqlExpression * expr);
  1201. ABoundActivity * doBuildActivityLoop(BuildCtx & ctx, IHqlExpression * expr);
  1202. ABoundActivity * doBuildActivityMerge(BuildCtx & ctx, IHqlExpression * expr);
  1203. ABoundActivity * doBuildActivityMetaActivity(BuildCtx & ctx, IHqlExpression * expr);
  1204. ABoundActivity * doBuildActivityNonEmpty(BuildCtx & ctx, IHqlExpression * expr);
  1205. ABoundActivity * doBuildActivityNWayMerge(BuildCtx & ctx, IHqlExpression * expr);
  1206. ABoundActivity * doBuildActivityNWayMergeJoin(BuildCtx & ctx, IHqlExpression * expr);
  1207. ABoundActivity * doBuildActivityNormalize(BuildCtx & ctx, IHqlExpression * expr);
  1208. ABoundActivity * doBuildActivityNormalizeChild(BuildCtx & ctx, IHqlExpression * expr);
  1209. ABoundActivity * doBuildActivityNormalizeGroup(BuildCtx & ctx, IHqlExpression * expr);
  1210. ABoundActivity * doBuildActivityNormalizeLinkedChild(BuildCtx & ctx, IHqlExpression * expr);
  1211. ABoundActivity * doBuildActivityNull(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1212. ABoundActivity * doBuildActivityOutput(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1213. ABoundActivity * doBuildActivityOutputIndex(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1214. ABoundActivity * doBuildActivityOutputWorkunit(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1215. ABoundActivity * doBuildActivityParse(BuildCtx & ctx, IHqlExpression * expr);
  1216. ABoundActivity * doBuildActivityPipeThrough(BuildCtx & ctx, IHqlExpression * expr);
  1217. ABoundActivity * doBuildActivityPrefetchProject(BuildCtx & ctx, IHqlExpression * expr);
  1218. ABoundActivity * doBuildActivityProject(BuildCtx & ctx, IHqlExpression * expr);
  1219. ABoundActivity * doBuildActivityProcess(BuildCtx & ctx, IHqlExpression * expr);
  1220. ABoundActivity * doBuildActivityRawChildDataset(BuildCtx & ctx, IHqlExpression * expr);
  1221. ABoundActivity * doBuildActivityRegroup(BuildCtx & ctx, IHqlExpression * expr);
  1222. ABoundActivity * doBuildActivityRemote(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1223. ABoundActivity * doBuildActivityReturnResult(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1224. ABoundActivity * doBuildActivityRollup(BuildCtx & ctx, IHqlExpression * expr);
  1225. ABoundActivity * doBuildActivityRollupGroup(BuildCtx & ctx, IHqlExpression * expr);
  1226. ABoundActivity * doBuildActivityRowsetIndex(BuildCtx & ctx, IHqlExpression * expr);
  1227. ABoundActivity * doBuildActivityRowsetRange(BuildCtx & ctx, IHqlExpression * expr);
  1228. ABoundActivity * doBuildActivityRowsetRange(BuildCtx & ctx, IHqlExpression * expr, IHqlExpression * rowset, IHqlExpression * inputSelection);
  1229. ABoundActivity * doBuildActivitySample(BuildCtx & ctx, IHqlExpression * expr);
  1230. ABoundActivity * doBuildActivitySection(BuildCtx & ctx, IHqlExpression * expr);
  1231. ABoundActivity * doBuildActivitySelectNew(BuildCtx & ctx, IHqlExpression * expr);
  1232. ABoundActivity * doBuildActivitySelectNth(BuildCtx & ctx, IHqlExpression * expr);
  1233. ABoundActivity * doBuildActivitySequentialParallel(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1234. ABoundActivity * doBuildActivitySerialize(BuildCtx & ctx, IHqlExpression * expr);
  1235. ABoundActivity * doBuildActivitySetGraphResult(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1236. ABoundActivity * doBuildActivitySetGraphLoopResult(BuildCtx & ctx, IHqlExpression * expr);
  1237. ABoundActivity * doBuildActivitySetResult(BuildCtx & ctx, IHqlExpression * expr, bool isRoot);
  1238. ABoundActivity * doBuildActivitySideEffect(BuildCtx & ctx, IHqlExpression * expr, bool isRoot, bool expandChildren);
  1239. ABoundActivity * doBuildActivitySpill(BuildCtx & ctx, IHqlExpression * expr);
  1240. ABoundActivity * doBuildActivitySplit(BuildCtx & ctx, IHqlExpression * expr);
  1241. ABoundActivity * doBuildActivityHTTP(BuildCtx & ctx, IHqlExpression * expr, bool isSink, bool isRoot);
  1242. ABoundActivity * doBuildActivitySOAP(BuildCtx & ctx, IHqlExpression * expr, bool isSink, bool isRoot);
  1243. ABoundActivity * doBuildActivitySort(BuildCtx & ctx, IHqlExpression * expr);
  1244. ABoundActivity * doBuildActivityStreamedCall(BuildCtx & ctx, IHqlExpression * expr);
  1245. ABoundActivity * doBuildActivitySub(BuildCtx & ctx, IHqlExpression * expr);
  1246. ABoundActivity * doBuildActivityTable(BuildCtx & ctx, IHqlExpression * expr);
  1247. ABoundActivity * doBuildActivityFirstN(BuildCtx & ctx, IHqlExpression * expr);
  1248. ABoundActivity * doBuildActivityTempTable(BuildCtx & ctx, IHqlExpression * expr);
  1249. ABoundActivity * doBuildActivityWorkunitRead(BuildCtx & ctx, IHqlExpression * expr);
  1250. ABoundActivity * doBuildActivityXmlParse(BuildCtx & ctx, IHqlExpression * expr);
  1251. void doBuildTempTableFlags(BuildCtx & ctx, IHqlExpression * expr, bool isConstant);
  1252. void doBuildXmlEncode(BuildCtx & ctx, const CHqlBoundTarget * tgt, IHqlExpression * expr, CHqlBoundExpr * result);
  1253. IHqlExpression * doBuildOrderElement(BuildCtx & ctx, IHqlExpression * left, IHqlExpression * right);
  1254. void doBuildFilterAnd(BuildCtx & ctx, IHqlExpression * expr);
  1255. void doBuildFilterAndRange(BuildCtx & ctx, unsigned first, unsigned last, HqlExprArray & conds);
  1256. void doBuildFilterToTarget(BuildCtx & ctx, const CHqlBoundTarget & isOk, HqlExprArray & conds, bool invert);
  1257. void doBuildFilterNextAndRange(BuildCtx & ctx, unsigned & curIndex, unsigned maxIterations, HqlExprArray & conds);
  1258. bool canBuildOptimizedCount(BuildCtx & ctx, IHqlExpression * dataset, CHqlBoundExpr & tgt);
  1259. bool canEvaluateInContext(BuildCtx & ctx, IHqlExpression * expr);
  1260. void gatherActiveCursors(BuildCtx & ctx, HqlExprCopyArray & activeRows);
  1261. IHqlStmt * buildFilterViaExpr(BuildCtx & ctx, IHqlExpression * expr);
  1262. void doBuildPureSubExpr(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1263. void doBuildTempExprConcat(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1264. void buildConcatFArgs(HqlExprArray & args, BuildCtx & ctx, const HqlExprArray & values, ITypeInfo * argType);
  1265. void doBuildVarLengthConcatF(BuildCtx & ctx, const CHqlBoundTarget & target, const HqlExprArray & values);
  1266. bool doBuildFixedLengthConcatF(BuildCtx & ctx, const CHqlBoundTarget & target, const HqlExprArray & values);
  1267. void doBuildCastViaTemp(BuildCtx & ctx, ITypeInfo * to, CHqlBoundExpr & pure, CHqlBoundExpr & tgt);
  1268. void doBuildCastViaString(BuildCtx & ctx, ITypeInfo * to, const CHqlBoundExpr & pure, CHqlBoundExpr & tgt);
  1269. void bindAndPush(BuildCtx & ctx, IHqlExpression * value);
  1270. IHqlExpression * createFormatCall(_ATOM func, IHqlExpression * expr);
  1271. void createOrderList(BuildCtx & ctx, IHqlExpression * expr, IHqlExpression * ascdesc, CHqlBoundExpr & tgt);
  1272. bool ensurePushed(BuildCtx & ctx, const CHqlBoundExpr & pure);
  1273. void ensureSimpleExpr(BuildCtx & ctx, CHqlBoundExpr & tgt);
  1274. IHqlExpression * ensureSimpleTranslatedExpr(BuildCtx & ctx, IHqlExpression * expr);
  1275. void ensureContextAvailable(BuildCtx & ctx);
  1276. IHqlExpression * getConstWuid(IHqlExpression * expr);
  1277. IHqlExpression * getFirstCharacter(IHqlExpression * source);
  1278. bool hasAddress(BuildCtx & ctx, IHqlExpression * expr);
  1279. unsigned processHint(IHqlExpression * expr);
  1280. IHqlExpression * convertOrToAnd(IHqlExpression * expr);
  1281. bool childrenRequireTemp(BuildCtx & ctx, IHqlExpression * expr, bool includeChildren);
  1282. bool requiresTemp(BuildCtx & ctx, IHqlExpression * expr, bool includeChildren);
  1283. bool requiresTempAfterFirst(BuildCtx & ctx, IHqlExpression * expr);
  1284. void tidyupExpr(BuildCtx & ctx, CHqlBoundExpr & bound);
  1285. void doStringTranslation(BuildCtx & ctx, ICharsetInfo * tgtset, ICharsetInfo * srcset, unsigned tgtlen, IHqlExpression * srclen, IHqlExpression * target, IHqlExpression * src);
  1286. void cacheOptions();
  1287. void overrideOptionsForLibrary();
  1288. void overrideOptionsForQuery();
  1289. void doExpandAliases(BuildCtx & ctx, IHqlExpression * expr, AliasExpansionInfo & info);
  1290. void expandAliases(BuildCtx & ctx, IHqlExpression * expr);
  1291. void expandAliasScope(BuildCtx & ctx, IHqlExpression * expr);
  1292. IHqlExpression * queryExpandAliasScope(BuildCtx & ctx, IHqlExpression * expr);
  1293. void addDependency(BuildCtx & ctx, ABoundActivity * element, ABoundActivity * dependent, _ATOM kind, const char * label=NULL, int controlId = 0);
  1294. void addFileDependency(IHqlExpression * name, ABoundActivity * whoAmI);
  1295. void doBuildClearAggregateRecord(BuildCtx & ctx, IHqlExpression * record, IHqlExpression * self, IHqlExpression * transform);
  1296. void doBuildAggregateClearFunc(BuildCtx & ctx, IHqlExpression * expr);
  1297. void doBuildAggregateFirstFunc(BuildCtx & ctx, IHqlExpression * expr);
  1298. void doBuildAggregateNextFunc(BuildCtx & ctx, IHqlExpression * expr);
  1299. void doBuildAggregateMergeFunc(BuildCtx & ctx, IHqlExpression * expr, bool & requiresOrderedMerge);
  1300. void doBuildAggregateProcessTransform(BuildCtx & ctx, BoundRow * selfRow, IHqlExpression * expr, IHqlExpression * alreadyDoneExpr);
  1301. void doBuildFuncIsSameGroup(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * sortlist);
  1302. void processUserAggregateTransform(IHqlExpression * expr, IHqlExpression * transform, SharedHqlExpr & firstTransform, SharedHqlExpr & nextTransform);
  1303. void doBuildUserAggregateFuncs(BuildCtx & ctx, IHqlExpression * expr, bool & requiresOrderedMerge);
  1304. void doBuildUserAggregateProcessTransform(BuildCtx & ctx, BoundRow * selfRow, IHqlExpression * expr, IHqlExpression * transform, IHqlExpression * alreadyDoneExpr);
  1305. void doBuildUserMergeAggregateFunc(BuildCtx & ctx, IHqlExpression * expr, IHqlExpression * mergeTransform);
  1306. IHqlExpression * getUserAggregateMergeTransform(IHqlExpression * expr, bool & requiresOrderedMerge);
  1307. void doBuildDistributionClearFunc(BuildCtx & ctx, IHqlExpression * dataset, HqlExprArray & fields);
  1308. void doBuildDistributionNextFunc(BuildCtx & ctx, IHqlExpression * dataset, HqlExprArray & fields);
  1309. void doBuildDistributionFunc(BuildCtx & funcctx, unsigned numFields, const char * action);
  1310. void doBuildDistributionDestructFunc(BuildCtx & funcctx, unsigned numFields);
  1311. void doBuildDistributionSerializeFunc(BuildCtx & funcctx, unsigned numFields);
  1312. void doBuildDistributionMergeFunc(BuildCtx & funcctx, unsigned numFields);
  1313. void doBuildDistributionGatherFunc(BuildCtx & funcctx, unsigned numFields);
  1314. void doBuildParseTransform(BuildCtx & classctx, IHqlExpression * expr);
  1315. void doBuildParseValidators(BuildCtx & classctx, IHqlExpression * expr);
  1316. void doBuildMatched(BuildCtx & ctx, const CHqlBoundTarget * target, IHqlExpression * expr, CHqlBoundExpr * bound);
  1317. void doBuildMatchAttr(BuildCtx & ctx, const CHqlBoundTarget * target, IHqlExpression * expr, CHqlBoundExpr * bound);
  1318. void doBuildParseSearchText(BuildCtx & classctx, IHqlExpression * dataset, IHqlExpression * search, type_t searchType, ITypeInfo * transferType);
  1319. void doBuildParseSearchText(BuildCtx & classctx, IHqlExpression * expr);
  1320. void doBuildParseCompiled(BuildCtx & classctx, MemoryBuffer & buffer);
  1321. void doBuildParseExtra(BuildCtx & classctx, IHqlExpression * expr);
  1322. void compileParseSearchPattern(IHqlExpression * expr);
  1323. void gatherExplicitMatched(IHqlExpression * expr);
  1324. void doBuildNewRegexFindReplace(BuildCtx & ctx, const CHqlBoundTarget * target, IHqlExpression * expr, CHqlBoundExpr * bound);
  1325. IHqlExpression * doBuildRegexCompileInstance(BuildCtx & ctx, IHqlExpression * pattern, bool unicode, bool caseSensitive);
  1326. IHqlExpression * doBuildRegexFindInstance(BuildCtx & ctx, IHqlExpression * compiled, IHqlExpression * search, bool cloneSearch);
  1327. IHqlExpression * doCreateGraphLookup(BuildCtx & declarectx, BuildCtx & resolvectx, unique_id_t id, const char * activity, bool isChild);
  1328. IHqlExpression * buildGetLocalResult(BuildCtx & ctx, IHqlExpression * expr, bool preferLinkedRows);
  1329. IHqlExpression * queryOptimizedExists(BuildCtx & ctx, IHqlExpression * expr, IHqlExpression * dataset);
  1330. void doBuildAssignAggregateLoop(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr, IHqlExpression * dataset, IHqlExpression * doneFirstVar);
  1331. void validateExprScope(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * expr, const char * opName, const char * argName);
  1332. void buildActivityFramework(ActivityInstance * instance);
  1333. void buildActivityFramework(ActivityInstance * instance, bool alwaysExecuted); // called for all actions
  1334. void buildCompareClass(BuildCtx & ctx, const char * name, IHqlExpression * sortList, const DatasetReference & dataset);
  1335. void buildCompareClass(BuildCtx & ctx, const char * name, IHqlExpression * orderExpr, IHqlExpression * datasetLeft, IHqlExpression * datasetRight, IHqlExpression * selSeq);
  1336. void buildCompareMemberLR(BuildCtx & ctx, const char * name, IHqlExpression * orderExpr, IHqlExpression * datasetLeft, IHqlExpression * datasetRight, IHqlExpression * selSeq);
  1337. void buildCompareMember(BuildCtx & ctx, const char * name, IHqlExpression * cond, const DatasetReference & dataset);
  1338. void buildOrderedCompare(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * sorts, CHqlBoundExpr & bound, IHqlExpression * leftDataset, IHqlExpression * rightDataset);
  1339. void buildCompareEqClass(BuildCtx & ctx, const char * name, IHqlExpression * sortList, const DatasetReference & dataset);
  1340. void buildCompareEqClass(BuildCtx & ctx, const char * name, IHqlExpression * orderExpr, IHqlExpression * datasetLeft, IHqlExpression * datasetRight, IHqlExpression * selSeq);
  1341. void buildCompareEqMemberLR(BuildCtx & ctx, const char * name, IHqlExpression * orderExpr, IHqlExpression * datasetLeft, IHqlExpression * datasetRight, IHqlExpression * selSeq);
  1342. void buildCompareEqMember(BuildCtx & ctx, const char * name, IHqlExpression * cond, const DatasetReference & dataset);
  1343. void buildNaryCompareClass(BuildCtx & ctx, const char * name, IHqlExpression * expr, IHqlExpression * datasetLeft, IHqlExpression * selSeq, IHqlExpression * rowsid);
  1344. void buildNaryCompareMember(BuildCtx & ctx, const char * name, IHqlExpression * expr, IHqlExpression * datasetLeft, IHqlExpression * selSeq, IHqlExpression * rowsid);
  1345. void buildConnectInputOutput(BuildCtx & ctx, ActivityInstance * instance, ABoundActivity * table, unsigned outputIndex, unsigned inputIndex, const char * label = NULL, bool nWay = false);
  1346. void buildConnectOrders(BuildCtx & ctx, ABoundActivity * slaveActivity, ABoundActivity * masterActivity);
  1347. void buildDedupFilterFunction(BuildCtx & ctx, HqlExprArray & equalities, HqlExprArray & conds, IHqlExpression * dataset, IHqlExpression * selSeq);
  1348. void buildDedupSerializeFunction(BuildCtx & ctx, const char * funcName, IHqlExpression * srcDataset, IHqlExpression * tgtDataset, HqlExprArray & srcValues, HqlExprArray & tgtValues, IHqlExpression * selSeq);
  1349. void buildHashClass(BuildCtx & ctx, const char * name, IHqlExpression * orderExpr, const DatasetReference & dataset);
  1350. void buildHashOfExprsClass(BuildCtx & ctx, const char * name, IHqlExpression * cond, const DatasetReference & dataset, bool compareToSelf);
  1351. void buildInstancePrefix(ActivityInstance * instance);
  1352. void buildInstanceSuffix(ActivityInstance * instance);
  1353. void buildIterateTransformFunction(BuildCtx & ctx, IHqlExpression * boundDataset, IHqlExpression * transform, IHqlExpression * counter, IHqlExpression * selSeq);
  1354. void buildProcessTransformFunction(BuildCtx & ctx, IHqlExpression * expr);
  1355. void buildRollupTransformFunction(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * transform, IHqlExpression * selSeq );
  1356. void buildClearRecord(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * record, int direction);
  1357. void buildClearRecordMember(BuildCtx & ctx, const char * name, IHqlExpression * dataset);
  1358. IHqlExpression * getSerializedLayoutFunction(IHqlExpression * record, unsigned numKeyedFields);
  1359. void buildSerializedLayoutMember(BuildCtx & ctx, IHqlExpression * record, const char * name, unsigned numKeyedFields);
  1360. IHqlExpression * getClearRecordFunction(IHqlExpression * record, int direction=0);
  1361. void doBuildSequenceFunc(BuildCtx & ctx, IHqlExpression * expr, bool ignoreInternal);
  1362. void buildSetResultInfo(BuildCtx & ctx, IHqlExpression * originalExpr, IHqlExpression * value, ITypeInfo * type, bool isPersist, bool associateResult);
  1363. void buildTransformXml(BuildCtx & ctx, IHqlExpression * expr, HqlExprArray & assigns, IHqlExpression * parentSelector);
  1364. void buildHTTPtoXml(BuildCtx & ctx);
  1365. void buildSOAPtoXml(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * transform, IHqlExpression * selSeq);
  1366. void buildRecordEcl(BuildCtx & subctx, IHqlExpression * dataset, const char * methodName);
  1367. void doTransform(BuildCtx & ctx, IHqlExpression * transform, BoundRow * self);
  1368. void doUpdateTransform(BuildCtx & ctx, IHqlExpression * transform, BoundRow * self, BoundRow * previous, bool alwaysNextRow);
  1369. void doInlineTransform(BuildCtx & ctx, IHqlExpression * transform, BoundRow * targetRow);
  1370. void doUserTransform(BuildCtx & ctx, IHqlExpression * transform, BoundRow * self);
  1371. IHqlExpression * createOrderFromSortList(const DatasetReference & dataset, IHqlExpression * sortList, IHqlExpression * leftSelect, IHqlExpression * rightSelect);
  1372. void buildSkewThresholdMembers(BuildCtx & ctx, IHqlExpression * expr);
  1373. void doCompareLeftRight(BuildCtx & ctx, const char * funcname, const DatasetReference & datasetLeft, const DatasetReference & datasetRight, HqlExprArray & left, HqlExprArray & right);
  1374. void buildSlidingMatchFunction(BuildCtx & ctx, HqlExprArray & leftEq, HqlExprArray & rightEq, HqlExprArray & slidingMatches, const char * funcname, unsigned childIndex, const DatasetReference & datasetL, const DatasetReference & datasetR);
  1375. void doBuildIndexOutputTransform(BuildCtx & ctx, IHqlExpression * record, SharedHqlExpr & rawRecord);
  1376. void buildKeyedJoinExtra(ActivityInstance & instance, IHqlExpression * expr, KeyedJoinInfo * joinKey);
  1377. void buildKeyJoinIndexReadHelper(ActivityInstance & instance, IHqlExpression * expr, KeyedJoinInfo * joinKey);
  1378. void buildKeyJoinFetchHelper(ActivityInstance & instance, IHqlExpression * expr, KeyedJoinInfo * joinKey);
  1379. void doBuildJoinRowLimitHelper(ActivityInstance & instance, IHqlExpression * rowlimit, IHqlExpression * filename, bool generateImplicitLimit);
  1380. IHqlExpression * createFailMessage(const char * prefix, IHqlExpression * limit, IHqlExpression * filename, unique_id_t id);
  1381. IHqlExpression * createFailAction(const char * prefix, IHqlExpression * limit, IHqlExpression * filename, unique_id_t id);
  1382. void buildJoinMatchFunction(BuildCtx & ctx, const char * name, IHqlExpression * left, IHqlExpression * right, IHqlExpression * match, IHqlExpression * selSeq);
  1383. void associateBlobHelper(BuildCtx & ctx, IHqlExpression * ds, const char * name);
  1384. IHqlExpression * getBlobRowSelector(BuildCtx & ctx, IHqlExpression * expr);
  1385. void buildXmlSerialize(BuildCtx & subctx, IHqlExpression * expr, IHqlExpression * selector, HqlExprArray * assigns, unsigned pass, unsigned & expectedIndex);
  1386. void buildXmlSerialize(BuildCtx & subctx, IHqlExpression * expr, IHqlExpression * selector, HqlExprArray * assigns);
  1387. void buildXmlSerialize(BuildCtx & ctx, IHqlExpression * dataset, const char * funcname, bool isMeta);
  1388. void buildXmlSerializeScalar(BuildCtx & ctx, IHqlExpression * selected, IHqlExpression * name);
  1389. void buildXmlSerializeSet(BuildCtx & ctx, IHqlExpression * field, IHqlExpression * value);
  1390. void buildXmlSerializeSetValues(BuildCtx & ctx, IHqlExpression * value, IHqlExpression * itemName, bool includeAll);
  1391. void buildXmlSerializeDataset(BuildCtx & ctx, IHqlExpression * field, IHqlExpression * value, HqlExprArray * assigns);
  1392. void buildXmlSerializeBeginNested(BuildCtx & ctx, IHqlExpression * name, bool doIndent);
  1393. void buildXmlSerializeEndNested(BuildCtx & ctx, IHqlExpression * name);
  1394. void buildXmlSerializeUsingMeta(BuildCtx & ctx, IHqlExpression * dataset, const char * self);
  1395. void buildSetXmlSerializer(StringBuffer & helper, ITypeInfo * valueType);
  1396. void buildMetaMember(BuildCtx & ctx, IHqlExpression * datasetOrRecord, bool isGrouped, const char * name);
  1397. void buildMetaSerializerClass(BuildCtx & ctx, IHqlExpression * record, const char * serializerName);
  1398. void buildMetaDeserializerClass(BuildCtx & ctx, IHqlExpression * record, const char * deserializerName);
  1399. bool buildMetaPrefetcherClass(BuildCtx & ctx, IHqlExpression * record, const char * prefetcherName);
  1400. void buildLibraryInstanceExtract(BuildCtx & ctx, HqlCppLibraryInstance * libraryInstance);
  1401. void buildLibraryGraph(BuildCtx & graphctx, IHqlExpression * expr, const char * graphName);
  1402. ActivityInstance * queryCurrentActivity(BuildCtx & ctx);
  1403. unique_id_t queryCurrentActivityId(BuildCtx & ctx);
  1404. IHqlExpression * getCurrentActivityId(BuildCtx & ctx); // can be variable
  1405. void associateSkipReturnMarker(BuildCtx & ctx, IHqlExpression * value, BoundRow * self);
  1406. IHqlExpression * createClearRowCall(BuildCtx & ctx, BoundRow * self);
  1407. EvalContext * queryEvalContext(BuildCtx & ctx) { return (EvalContext *)ctx.queryFirstAssociation(AssocExtractContext); }
  1408. inline unsigned nextActivityId() { return ++curActivityId; }
  1409. bool insideChildGraph(BuildCtx & ctx);
  1410. bool insideChildQuery(BuildCtx & ctx);
  1411. bool insideRemoteGraph(BuildCtx & ctx);
  1412. bool isCurrentActiveGraph(BuildCtx & ctx, IHqlExpression * graphTag);
  1413. void buildXmlReadChildrenIterator(BuildCtx & subctx, const char * iterTag, IHqlExpression * rowName, SharedHqlExpr & subRowExpr);
  1414. void buildXmlReadTransform(IHqlExpression * dataset, StringBuffer & className, bool & usesContents);
  1415. void doBuildXmlReadMember(ActivityInstance & instance, IHqlExpression * expr, const char * functionName, bool & usesContents);
  1416. void ensureSerialized(const CHqlBoundTarget & variable, BuildCtx & serializectx, BuildCtx & deserializectx, const char * inBufferName, const char * outBufferName);
  1417. void ensureRowAllocator(StringBuffer & allocatorName, BuildCtx & ctx, IHqlExpression * record, IHqlExpression * activityId);
  1418. IHqlExpression * createRowAllocator(BuildCtx & ctx, IHqlExpression * record);
  1419. void beginExtract(BuildCtx & ctx, ParentExtract * extractBuilder);
  1420. void endExtract(BuildCtx & ctx, ParentExtract * extractBuilder);
  1421. IDefRecordElement * createMetaRecord(IHqlExpression * record);
  1422. public:
  1423. void doBuildBoolFunction(BuildCtx & ctx, const char * name, bool value);
  1424. void doBuildBoolFunction(BuildCtx & ctx, const char * name, IHqlExpression * value);
  1425. void doBuildSignedFunction(BuildCtx & ctx, const char * name, IHqlExpression * value);
  1426. void doBuildSizetFunction(BuildCtx & ctx, const char * name, size32_t value);
  1427. void doBuildUnsignedFunction(BuildCtx & ctx, const char * name, unsigned value);
  1428. void doBuildUnsignedFunction(BuildCtx & ctx, const char * name, IHqlExpression * value);
  1429. void doBuildUnsignedFunction(BuildCtx & ctx, const char * name, const char * value);
  1430. void doBuildUnsigned64Function(BuildCtx & ctx, const char * name, IHqlExpression * value);
  1431. void doBuildVarStringFunction(BuildCtx & ctx, const char * name, IHqlExpression * value);
  1432. void doBuildDataFunction(BuildCtx & ctx, const char * name, IHqlExpression * value);
  1433. void doBuildStringFunction(BuildCtx & ctx, const char * name, IHqlExpression * value);
  1434. void doBuildFunction(BuildCtx & ctx, ITypeInfo * type, const char * name, IHqlExpression * value);
  1435. void doBuildFunctionReturn(BuildCtx & ctx, ITypeInfo * type, IHqlExpression * value);
  1436. void doBuildUserFunctionReturn(BuildCtx & ctx, ITypeInfo * type, IHqlExpression * value);
  1437. void addFilenameConstructorParameter(ActivityInstance & instance, const char * name, IHqlExpression * expr);
  1438. void buildFilenameFunction(ActivityInstance & instance, BuildCtx & classctx, const char * name, IHqlExpression * expr, bool isDynamic);
  1439. void buildRefFilenameFunction(ActivityInstance & instance, BuildCtx & classctx, const char * name, IHqlExpression * dataset);
  1440. void createAccessFunctions(StringBuffer & helperFunc, BuildCtx & declarectx, unsigned prio, const char * interfaceName, const char * object);
  1441. void beginNestedClass(BuildCtx & classctx, const char * member, const char * bases, const char * memberExtra = NULL, ParentExtract * extract = NULL);
  1442. void endNestedClass();
  1443. void buildEncryptHelper(BuildCtx & ctx, IHqlExpression * encryptAttr, const char * funcname = NULL);
  1444. void buildFormatCrcFunction(BuildCtx & ctx, const char * name, IHqlExpression * dataset, IHqlExpression * expr, unsigned payloadDelta);
  1445. void buildLimitHelpers(BuildCtx & ctx, IHqlExpression * expr, IHqlExpression * filename, unique_id_t id);
  1446. void buildLimitHelpers(BuildCtx & ctx, IHqlExpression * rowLimit, IHqlExpression * failAction, bool isSkip, IHqlExpression * filename, unique_id_t id);
  1447. void doGenerateMetaDestruct(BuildCtx & ctx, IHqlExpression * selector, IHqlExpression * record);
  1448. void generateMetaRecordSerialize(BuildCtx & ctx, IHqlExpression * dataset, const char * serializerName, const char * deserializerName, const char * prefetcherName);
  1449. void filterExpandAssignments(BuildCtx & ctx, TransformBuilder * builder, HqlExprArray & assigns, IHqlExpression * expr);
  1450. protected:
  1451. IWUResult * createWorkunitResult(int sequence, IHqlExpression * nameExpr);
  1452. void noteFilename(ActivityInstance & instance, const char * name, IHqlExpression * expr, bool isDynamic);
  1453. bool checkGetResultContext(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1454. void buildGetResultInfo(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr * boundTarget, const CHqlBoundTarget * targetAssign);
  1455. void buildGetResultSetInfo(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr * boundTarget, const CHqlBoundTarget * targetAssign);
  1456. void buildExpiryHelper(BuildCtx & ctx, IHqlExpression * expireAttr);
  1457. void buildUpdateHelper(BuildCtx & ctx, ActivityInstance & instance, IHqlExpression * input, IHqlExpression * updateAttr);
  1458. void buildClusterHelper(BuildCtx & ctx, IHqlExpression * expr);
  1459. void precalculateFieldOffsets(BuildCtx & ctx, IHqlExpression * expr, BoundRow * cursor);
  1460. IHqlExpression * optimizeIncrementAssign(BuildCtx & ctx, IHqlExpression * value);
  1461. void doBuildEvalOnce(BuildCtx & ctx, const CHqlBoundTarget * target, IHqlExpression * expr, CHqlBoundExpr * bound);
  1462. void doBuildAssignCompareRow(BuildCtx & ctx, EvaluateCompareInfo & info, IHqlExpression * left, IHqlExpression * right);
  1463. void doBuildAssignCompareTable(BuildCtx & ctx, EvaluateCompareInfo & info, IHqlExpression * left, IHqlExpression * right);
  1464. void doBuildAssignCompareElement(BuildCtx & ctx, EvaluateCompareInfo & info, IHqlExpression * left, IHqlExpression * right, bool isFirst, bool isLast);
  1465. void doBuildAssignCompare(BuildCtx & ctx, EvaluateCompareInfo & target, HqlExprArray & leftValues, HqlExprArray & rightValues, bool isFirst, bool isOuter);
  1466. void expandRowOrder(IHqlExpression * selector, IHqlExpression * record, HqlExprArray & values, bool isRow);
  1467. void expandSimpleOrder(IHqlExpression * left, IHqlExpression * right, HqlExprArray & leftValues, HqlExprArray & rightValues);
  1468. void expandOrder(IHqlExpression * expr, HqlExprArray & leftValues, HqlExprArray & rightValues, SharedHqlExpr & defaultValue);
  1469. void optimizeOrderValues(HqlExprArray & leftValues, HqlExprArray & rightValues, bool isEqualityCompare);
  1470. IHqlExpression * querySimpleOrderSelector(IHqlExpression * expr);
  1471. unsigned doBuildThorChildSubGraph(BuildCtx & ctx, IHqlExpression * expr, SubGraphType kind, unsigned thisId=0, IHqlExpression * represents=NULL);
  1472. unsigned doBuildThorSubGraph(BuildCtx & ctx, IHqlExpression * expr, SubGraphType kind, unsigned thisId=0, IHqlExpression * represents=NULL);
  1473. void doBuildThorGraph(BuildCtx & ctx, IHqlExpression * expr);
  1474. IHqlExpression * createResultName(IHqlExpression * name, bool isPersist);
  1475. bool isFixedWidthDataset(IHqlExpression * dataset);
  1476. IHqlExpression * normalizeGlobalIfCondition(BuildCtx & ctx, IHqlExpression * expr);
  1477. void substituteClusterSize(HqlExprArray & exprs);
  1478. void throwCannotCast(ITypeInfo * from, ITypeInfo * to);
  1479. void splitFuzzyCondition(IHqlExpression * condition, IHqlExpression * atmostCond, SharedHqlExpr & fuzzy, SharedHqlExpr & hard);
  1480. void ensureSerialized(BuildCtx & ctx, const CHqlBoundTarget & variable);
  1481. void doBuildExprRowDiff(BuildCtx & ctx, const CHqlBoundTarget & target, IHqlExpression * expr, IHqlExpression * leftSelector, IHqlExpression * rightRecord, IHqlExpression * rightSelector, StringBuffer & selectorText, bool isCount);
  1482. void doBuildExprRowDiff(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
  1483. void doFilterAssignment(BuildCtx & ctx, TransformBuilder * builder, HqlExprArray & assigns, IHqlExpression * expr);
  1484. void doFilterAssignments(BuildCtx & ctx, TransformBuilder * builder, HqlExprArray & assigns, IHqlExpression * expr);
  1485. void generateSerializeAssigns(BuildCtx & ctx, IHqlExpression * record, IHqlExpression * selector, IHqlExpression * selfSelect, IHqlExpression * leftSelect, const DatasetReference & srcDataset, const DatasetReference & tgtDataset, HqlExprArray & srcSelects, HqlExprArray & tgtSelects, bool needToClear);
  1486. void generateSerializeFunction(BuildCtx & ctx, const char * funcName, bool serialize, const DatasetReference & srcDataset, const DatasetReference & tgtDataset, HqlExprArray & srcSelects, HqlExprArray & tgtSelects);
  1487. void generateSerializeKey(BuildCtx & ctx, node_operator side, const DatasetReference & dataset, HqlExprArray & sorts, bool isGlobal, bool generateCompares, bool canReuseLeft); //NB: sorts are ats.xyz
  1488. void generateSortCompare(BuildCtx & nestedctx, BuildCtx & ctx, node_operator index, const DatasetReference & dataset, HqlExprArray & sorts, bool canRemoveSort, IHqlExpression * noSortAttr, bool canReuseLeft, bool isLightweight, bool isLocal);
  1489. void addSchemaField(IHqlExpression *field, MemoryBuffer &schema, IHqlExpression *selector);
  1490. void addSchemaFields(IHqlExpression * record, MemoryBuffer &schema, IHqlExpression *selector);
  1491. void addSchemaResource(int seq, const char * name, IHqlExpression * record);
  1492. void addSchemaResource(int seq, const char * name, unsigned len, const char * schemaXml);
  1493. void doAddSchemaFields(IHqlExpression * record, MemoryBuffer &schema, IHqlExpression *selector);
  1494. IWUResult * createDatasetResultSchema(IHqlExpression * sequenceExpr, IHqlExpression * name, IHqlExpression * record, bool createTransformer, bool isFile);
  1495. void buildReturnCsvValue(BuildCtx & ctx, IHqlExpression * _expr);
  1496. void buildCsvListFunc(BuildCtx & classctx, const char * func, IHqlExpression * value, const char * defaultValue);
  1497. void buildCsvParameters(BuildCtx & subctx, IHqlExpression * csvAttr, IHqlExpression * record, bool isReading);
  1498. unsigned buildCsvReadTransform(BuildCtx & subctx, IHqlExpression * dataset, bool newInterface, IHqlExpression * csvAttr);
  1499. void buildCsvReadTransform(BuildCtx & subctx, IHqlExpression * expr, IHqlExpression * selector, unsigned & numFields);
  1500. void buildCsvReadTransformer(IHqlExpression * dataset, StringBuffer & instanceName, IHqlExpression * optCsvAttr);
  1501. void buildCsvWriteScalar(BuildCtx & ctx, IHqlExpression * expr, _ATOM encoding);
  1502. void buildCsvWriteTransform(BuildCtx & subctx, IHqlExpression * dataset, _ATOM encoding);
  1503. void buildCsvWriteTransform(BuildCtx & subctx, IHqlExpression * expr, IHqlExpression * selector, _ATOM encoding);
  1504. void buildCsvWriteMembers(ActivityInstance * instance, IHqlExpression * dataset, IHqlExpression * csvAttr);
  1505. void buildXmlWriteMembers(ActivityInstance * instance, IHqlExpression * dataset, IHqlExpression * xmlAttr);
  1506. //ThorHole helper functions...
  1507. IHqlExpression * doBuildDatabaseLoader(BuildCtx & ctx, IHqlExpression * expr);
  1508. void doReportWarning(IHqlExpression * location, unsigned id, const char * msg);
  1509. void optimizePersists(HqlExprArray & exprs);
  1510. void optimizePersists(WorkflowArray & workflow);
  1511. void allocateSequenceNumbers(HqlExprArray & exprs);
  1512. void convertLogicalToActivities(WorkflowArray & array);
  1513. void flattenDatasets(WorkflowArray & array);
  1514. void spotGlobalCSE(WorkflowArray & array);
  1515. IHqlExpression * spotGlobalCSE(IHqlExpression * _expr);
  1516. void spotGlobalCSE(HqlExprArray & exprs);
  1517. IHqlExpression * extractGlobalCSE(IHqlExpression * expr);
  1518. void processCppBodyDirectives(IHqlExpression * expr);
  1519. void markThorBoundaries(WorkflowArray & array);
  1520. bool transformGraphForGeneration(IHqlExpression * exprlist, WorkflowArray & exprs);
  1521. void processEmbeddedLibraries(HqlExprArray & exprs, HqlExprArray & internalLibraries, bool isLibrary);
  1522. void pickBestEngine(WorkflowArray & array);
  1523. void pickBestEngine(HqlExprArray & exprs);
  1524. IHqlExpression * separateLibraries(IHqlExpression * query, HqlExprArray & internalLibraries);
  1525. void doBuildSerialize(BuildCtx & ctx, _ATOM name, IHqlExpression * length, CHqlBoundExpr & bound, const char * bufferName);
  1526. void modifyOutputLocations(HqlExprArray & exprs);
  1527. IHqlExpression * getDefaultOutputAttr(IHqlExpression * expr);
  1528. IHqlExpression * calculatePersistInputCrc(BuildCtx & ctx, IHqlExpression * expr);
  1529. IHqlExpression * calculatePersistInputCrc(BuildCtx & ctx, DependenciesUsed & dependencies);
  1530. bool ifRequiresAssignment(BuildCtx & ctx, IHqlExpression * expr);
  1531. void logGraphEdge(IPropertyTree * subGraph, unsigned __int64 source, unsigned __int64 target, unsigned sourceIndex, unsigned targetIndex, const char * label, bool nWay);
  1532. void beginGraph(BuildCtx & ctx, const char * graphName = NULL);
  1533. void clearGraph();
  1534. void endGraph();
  1535. double getComplexity(WorkflowArray & exprs);
  1536. double getComplexity(HqlExprArray & exprs);
  1537. double getComplexity(IHqlExpression * expr, ClusterType cluster);
  1538. bool prepareToGenerate(IHqlExpression * exprlist, WorkflowArray & exprs, bool isEmbeddedLibrary);
  1539. IHqlExpression * getResourcedGraph(IHqlExpression * expr, IHqlExpression * graphIdExpr);
  1540. IHqlExpression * getResourcedChildGraph(BuildCtx & ctx, IHqlExpression * expr, IHqlExpression * graphIdExpr, unsigned numResults, node_operator graphKind);
  1541. IHqlExpression * optimizeCompoundSource(IHqlExpression * expr, unsigned flags);
  1542. IHqlExpression * optimizeGraphPostResource(IHqlExpression * expr, unsigned csfFlags);
  1543. bool isInlineOk();
  1544. GraphLocalisation getGraphLocalisation(IHqlExpression * expr, bool isInsideChildQuery);
  1545. bool isAlwaysCoLocal();
  1546. bool isNeverDistributed(IHqlExpression * expr);
  1547. void ensureWorkUnitUpdated();
  1548. bool getDebugFlag(const char * name, bool defValue);
  1549. void initOptions();
  1550. void postProcessOptions();
  1551. public:
  1552. IHqlExpression * convertToPhysicalIndex(IHqlExpression * tableExpr);
  1553. IHqlExpression * buildIndexFromPhysical(IHqlExpression * expr);
  1554. //MORE: At some point the global getUniqueId() should be killed so there are only local references.
  1555. inline unsigned __int64 getUniqueId() { return ::getUniqueId(); } //{ return ++nextUid; }
  1556. inline StringBuffer & getUniqueId(StringBuffer & target) { return appendUniqueId(target, getUniqueId()); }
  1557. inline unsigned curGraphSequence() const { return activeGraphName ? graphSeqNumber : 0; }
  1558. public:
  1559. void traceExpression(const char * title, IHqlExpression * expr, unsigned level=500);
  1560. void traceExpressions(const char * title, HqlExprArray & exprs, unsigned level=500);
  1561. void traceExpressions(const char * title, WorkflowArray & exprs);
  1562. void checkNormalized(IHqlExpression * expr);
  1563. void checkNormalized(WorkflowArray & array);
  1564. void checkNormalized(HqlExprArray & exprs);
  1565. void checkNormalized(BuildCtx & ctx, IHqlExpression * expr);
  1566. protected:
  1567. HqlCppInstance * code;
  1568. IHqlScope * internalScope;
  1569. unsigned hints;
  1570. RecordOffsetMap recordMap; // no_record -> offset information
  1571. ExprExprMap physicalIndexCache;
  1572. unsigned litno;
  1573. StringAttr soName;
  1574. IErrorReceiver * errors;
  1575. HqlCppOptions options;
  1576. HqlCppDerived derived;
  1577. bool checkedEmbeddedCpp;
  1578. bool cachedAllowEmbeddedCpp;
  1579. bool checkedPipeAllowed;
  1580. unsigned numExtraFiles;
  1581. unsigned activitiesThisCpp;
  1582. unsigned curCppFile;
  1583. Linked<ICodegenContextCallback> ctxCallback;
  1584. ClusterType targetClusterType;
  1585. bool contextAvailable;
  1586. unsigned maxSequence;
  1587. StringAttr activeGraphName;
  1588. unsigned startCursorSet;
  1589. bool requireTable;
  1590. BuildCtx * activeGraphCtx;
  1591. HqlExprArray metas;
  1592. Owned<IPropertyTree> graph;
  1593. unsigned graphSeqNumber;
  1594. StringAttr graphLabel;
  1595. NlpParseContext * nlpParse; // Not linked so it can try and stay opaque.
  1596. bool xmlUsesContents;
  1597. CIArrayOf<GlobalFileTracker> globalFiles;
  1598. CIArrayOf<InternalResultTracker> internalResults;
  1599. HqlCppLibraryImplementation * outputLibrary; // not linked to opaque
  1600. OwnedHqlExpr outputLibraryId;
  1601. unsigned curActivityId;
  1602. unsigned holeUniqueSequence;
  1603. unsigned nextUid;
  1604. unsigned nextTypeId;
  1605. unsigned nextFieldId;
  1606. HqlExprArray internalFunctions;
  1607. HqlExprArray internalFunctionExternals;
  1608. #ifdef SPOT_POTENTIAL_COMMON_ACTIVITIES
  1609. LocationArray savedActivityLocations;
  1610. HqlExprArray savedActivities;
  1611. #endif
  1612. struct
  1613. {
  1614. HqlExprArray activityExprs;
  1615. HqlExprArray activityNorms;
  1616. UnsignedArray activityIds;
  1617. UnsignedArray activityCrcs;
  1618. } tracking;
  1619. //The following are only ok to access the top value - but not to build a parent tree.
  1620. //the activities cannot be assumed to be generated in a stackwise manner.
  1621. //e.g, could generate a a.b a.c (while a.b is still active) (because of strength reduction).
  1622. CIArrayOf<ABoundActivity> activeActivities;
  1623. CIArrayOf<GeneratedGraphInfo> graphs;
  1624. HqlExprArray activityExprStack; //only used for improving the error reporting
  1625. PointerArray recordIndexCache;
  1626. Owned<ITimeReporter> timeReporter;
  1627. WarningProcessor warningProcessor;
  1628. };
  1629. //===========================================================================
  1630. class HQLCPP_API HqlQueryInstance : public CInterface, implements IHqlQueryInstance
  1631. {
  1632. public:
  1633. HqlQueryInstance();
  1634. IMPLEMENT_IINTERFACE
  1635. StringBuffer & queryDllName(StringBuffer & out);
  1636. protected:
  1637. unique_id_t instance;
  1638. };
  1639. //===========================================================================
  1640. class ChildGraphBuilder : public CInterface
  1641. {
  1642. public:
  1643. ChildGraphBuilder(HqlCppTranslator & _translator);
  1644. IHqlExpression * addDataset(IHqlExpression * expr);
  1645. void buildStmt(BuildCtx & ctx, IHqlExpression * expr);
  1646. unique_id_t buildGraphLoopBody(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * selSeq, IHqlExpression * rowsid, IHqlExpression * body, IHqlExpression * counter, unique_id_t containerId, bool multiInstance);
  1647. unique_id_t buildLoopBody(BuildCtx & ctx, IHqlExpression * dataset, IHqlExpression * selSeq, IHqlExpression * rowsid, IHqlExpression * body, IHqlExpression * filter, IHqlExpression * again, IHqlExpression * counter, unique_id_t containerId, bool multiInstance);
  1648. unique_id_t buildRemoteGraph(BuildCtx & ctx, IHqlExpression * ds, unique_id_t containerId);
  1649. void generateGraph(BuildCtx & ctx);
  1650. void generatePrefetchGraph(BuildCtx & _ctx, OwnedHqlExpr * retGraphExpr, OwnedHqlExpr * retResultsExpr);
  1651. bool isDatasetPresent(IHqlExpression * expr);
  1652. unsigned queryLoopConditionResult() const { return loopAgainResult; }
  1653. protected:
  1654. void createBuilderAlias(BuildCtx & ctx, ParentExtract * extractBuilder);
  1655. protected:
  1656. HqlCppTranslator & translator;
  1657. unsigned id;
  1658. OwnedHqlExpr idExpr;
  1659. StringBuffer instanceName;
  1660. OwnedHqlExpr instanceExpr;
  1661. OwnedHqlExpr resultInstanceExpr;
  1662. OwnedHqlExpr represents;
  1663. unsigned loopAgainResult;
  1664. HqlExprArray results;
  1665. unsigned numResults;
  1666. };
  1667. //===========================================================================
  1668. class CompoundBuilder
  1669. {
  1670. public:
  1671. CompoundBuilder(node_operator _op);
  1672. void addOperand(IHqlExpression * arg);
  1673. IHqlExpression * getCompound();
  1674. protected:
  1675. node_operator op;
  1676. HqlExprAttr compound;
  1677. HqlExprAttr first;
  1678. };
  1679. class LoopInvariantHelper
  1680. {
  1681. public:
  1682. LoopInvariantHelper() { active = NULL; }
  1683. ~LoopInvariantHelper() { finished(); }
  1684. bool getBestContext(BuildCtx & ctx, IHqlExpression * expr);
  1685. protected:
  1686. void finished();
  1687. protected:
  1688. IHqlStmt * active;
  1689. };
  1690. //===========================================================================
  1691. void cvtChooseListToPairs(HqlExprArray & target, IHqlExpression * from, unsigned base);
  1692. void cvtIndexListToPairs(HqlExprArray & target, IHqlExpression * from);
  1693. void cvtInListToPairs(HqlExprArray & target, IHqlExpression * from, bool valueIfMatch);
  1694. HQLCPP_API IHqlExpression * splitLongString(IHqlExpression * expr);
  1695. void createTempFor(ITypeInfo * exprType, CHqlBoundTarget & target, const char * prefix);
  1696. void checkSelectFlags(IHqlExpression * expr);
  1697. extern HQLCPP_API IHqlExpression * getPointer(IHqlExpression * source);
  1698. extern IHqlExpression * adjustIndexBaseToZero(IHqlExpression * index);
  1699. extern IHqlExpression * adjustIndexBaseToOne(IHqlExpression * index);
  1700. extern IHqlExpression * multiplyValue(IHqlExpression * expr, unsigned __int64 value);
  1701. extern bool isComplexSet(ITypeInfo * type, bool isConstant);
  1702. extern bool isComplexSet(IHqlExpression * expr);
  1703. extern bool isConstantSet(IHqlExpression * expr);
  1704. extern bool canProcessInline(BuildCtx * ctx, IHqlExpression * expr);
  1705. extern bool canIterateInline(BuildCtx * ctx, IHqlExpression * expr);
  1706. extern bool canAssignInline(BuildCtx * ctx, IHqlExpression * expr);
  1707. extern bool canEvaluateInline(BuildCtx * ctx, IHqlExpression * expr);
  1708. extern bool canAssignNotEvaluateInline(BuildCtx * ctx, IHqlExpression * expr);
  1709. extern bool isNonLocal(IHqlExpression * expr);
  1710. extern bool alwaysEvaluatesToBound(IHqlExpression * expr);
  1711. extern void buildClearPointer(BuildCtx & ctx, IHqlExpression * expr);
  1712. extern IHqlExpression * getVirtualReplacement(IHqlExpression * expr, IHqlExpression * virtualDef, IHqlExpression * dataset);
  1713. extern IHqlExpression * convertWrapperToPointer(IHqlExpression * expr);
  1714. extern IHqlExpression * createVariable(ITypeInfo * type);
  1715. extern void getMappedFields(HqlExprArray & aggregateFields, IHqlExpression * transform, HqlExprArray & recordFields, IHqlExpression * newSelector);
  1716. extern IHqlExpression * queryBlobHelper(BuildCtx & ctx, IHqlExpression * select);
  1717. inline bool isInPayload() { return true; } // placeholder - otherwise records in non payload can't be keyed sometimes.
  1718. extern bool filterIsTableInvariant(IHqlExpression * expr);
  1719. //NB: Watch out about calling this - if expression can be evaluated in a context; may not mean it is the correct context to evaluate it in
  1720. // e.g., if same LEFT selector is in current context and parent.
  1721. extern bool mustEvaluateInContext(BuildCtx & ctx, IHqlExpression * expr);
  1722. extern const char * boolToText(bool value);
  1723. extern GraphLocalisation queryActivityLocalisation(IHqlExpression * expr);
  1724. extern void checkDependencyConsistency(WorkflowArray & workflow);
  1725. extern bool isGraphIndependent(IHqlExpression * expr, IHqlExpression * graph);
  1726. extern IHqlExpression * adjustBoundIntegerValues(IHqlExpression * left, IHqlExpression * right, bool subtract);
  1727. extern bool isNullAssign(const CHqlBoundTarget & target, IHqlExpression * expr);
  1728. inline SubGraphInfo * queryActiveSubGraph(BuildCtx & ctx)
  1729. {
  1730. return static_cast<SubGraphInfo *>(ctx.queryFirstAssociation(AssocSubGraph));
  1731. }
  1732. #endif