hqlresource.ipp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef __HQLRESOURCE_IPP_
  14. #define __HQLRESOURCE_IPP_
  15. #include "hqlresource.hpp"
  16. //#define TRACE_BALANCED
  17. enum ResourceType {
  18. //Slave specific
  19. RESslavememory,
  20. RESslavesocket,
  21. //Master specific
  22. RESmastermemory,
  23. RESmastersocket,
  24. //General
  25. REShashdist,
  26. RESheavy,
  27. RESactivities,
  28. RESmax
  29. };
  30. class CResourceOptions
  31. {
  32. public:
  33. CResourceOptions(ClusterType _targetClusterType, unsigned _clusterSize, const HqlCppOptions & _translatorOptions, UniqueSequenceCounter & _spillSequence);
  34. IHqlExpression * createResultSpillName();
  35. IHqlExpression * createDiskSpillName();
  36. IHqlExpression * createGlobalSpillName();
  37. void noteGraphsChanged() { state.updateSequence++; }
  38. void setChildQuery(bool value);
  39. void setNewChildQuery(IHqlExpression * graphIdExpr, unsigned numResults);
  40. void setUseGraphResults(bool _useGraphResults)
  41. {
  42. useGraphResults = _useGraphResults;
  43. }
  44. bool useGraphResult(bool linkedFromChild);
  45. bool useGlobalResult(bool linkedFromChild);
  46. public:
  47. UniqueSequenceCounter & spillSequence;
  48. unsigned filteredSpillThreshold;
  49. unsigned minimizeSpillSize;
  50. bool allowThroughSpill;
  51. bool allowThroughResult;
  52. bool cloneFilteredIndex;
  53. bool spillSharedConditionals;
  54. bool shareDontExpand;
  55. bool useGraphResults;
  56. bool noConditionalLinks;
  57. bool minimiseSpills;
  58. bool hoistResourced;
  59. bool isChildQuery; // Is a child query, or a loop inside a child query
  60. bool groupedChildIterators;
  61. bool allowSplitBetweenSubGraphs;
  62. bool preventKeyedSplit;
  63. bool preventSteppedSplit;
  64. bool minimizeSkewBeforeSpill;
  65. bool expandSingleConstRow;
  66. bool createSpillAsDataset;
  67. bool optimizeSharedInputs;
  68. bool combineSiblings;
  69. bool actionLinkInNewGraph;
  70. bool convertCompoundToExecuteWhen;
  71. bool useResultsForChildSpills;
  72. bool alwaysUseGraphResults;
  73. bool newBalancedSpotter;
  74. bool spillMultiCondition;
  75. bool spotThroughAggregate;
  76. bool alwaysReuseGlobalSpills;
  77. bool unlimitedResources = false;
  78. IHqlExpression * graphIdExpr;
  79. unsigned nextResult;
  80. unsigned clusterSize;
  81. ClusterType targetClusterType;
  82. //Used
  83. struct
  84. {
  85. unsigned updateSequence;
  86. } state;
  87. inline bool canSplit() const { return targetClusterType != HThorCluster; }
  88. inline bool checkResources() const { return isThorCluster(targetClusterType) && !isChildQuery; }
  89. inline bool targetRoxie() const { return targetClusterType == RoxieCluster; }
  90. inline bool targetThor() const { return targetClusterType == ThorLCRCluster; }
  91. };
  92. struct CResources : public CInterface
  93. {
  94. public:
  95. CResources(unsigned _clusterSize) { clusterSize = _clusterSize; _clear(resource); }
  96. CResources(const CResources & other) { clusterSize = other.clusterSize; set(other); }
  97. void add(const CResources & other);
  98. bool addExceeds(const CResources & other, const CResources & limit) const;
  99. void clear() { _clear(resource); }
  100. bool exceeds(const CResources & limit) const;
  101. StringBuffer & getExceedsReason(StringBuffer & reasonText, const CResources & other, const CResources & limit) const;
  102. void maximize(const CResources & other);
  103. CResources & set(ResourceType kind, unsigned value) { resource[kind] = value; return *this; }
  104. CResources & set(const CResources & other) { memcpy(&resource, &other.resource, sizeof(resource)); return *this; }
  105. CResources & setLightweight();
  106. CResources & setHeavyweight();
  107. CResources & setManyToManySockets(unsigned num);
  108. CResources & setManyToMasterSockets(unsigned num);
  109. void sub(const CResources & other);
  110. public:
  111. unsigned resource[RESmax];
  112. unsigned clusterSize;
  113. };
  114. enum LinkKind { UnconditionalLink, SequenceLink };
  115. class ResourceGraphInfo;
  116. class ResourceGraphLink : public CInterface
  117. {
  118. public:
  119. ResourceGraphLink(ResourceGraphInfo * _sourceGraph, IHqlExpression * _sourceNode, ResourceGraphInfo * _sinkGraph, IHqlExpression * _sinkNode, LinkKind _kind);
  120. ~ResourceGraphLink();
  121. virtual void changeSourceGraph(ResourceGraphInfo * newGraph);
  122. virtual void changeSinkGraph(ResourceGraphInfo * newGraph);
  123. virtual bool isRedundantLink();
  124. virtual bool isDependency() const { return false; }
  125. virtual IHqlExpression * queryDependency() const { return NULL; }
  126. protected:
  127. void trace(const char * name);
  128. public:
  129. Owned<ResourceGraphInfo> sourceGraph;
  130. Owned<ResourceGraphInfo> sinkGraph;
  131. OwnedHqlExpr sourceNode;
  132. OwnedHqlExpr sinkNode;
  133. byte linkKind;
  134. };
  135. class ResourceGraphDependencyLink : public ResourceGraphLink
  136. {
  137. public:
  138. ResourceGraphDependencyLink(ResourceGraphInfo * _sourceGraph, IHqlExpression * _sourceNode, ResourceGraphInfo * _sinkGraph, IHqlExpression * _sinkNode, IHqlExpression * _dependency);
  139. virtual void changeSourceGraph(ResourceGraphInfo * newGraph);
  140. virtual void changeSinkGraph(ResourceGraphInfo * newGraph);
  141. virtual bool isRedundantLink() { return false; }
  142. virtual bool isDependency() const { return true; }
  143. virtual IHqlExpression * queryDependency() const { return dependency; }
  144. protected:
  145. LinkedHqlExpr dependency;
  146. };
  147. typedef CIArrayOf<ResourceGraphInfo> ResourceGraphArray;
  148. typedef CICopyArrayOf<ResourceGraphLink> GraphLinkArray;
  149. class ResourceGraphInfo : public CInterface
  150. {
  151. public:
  152. ResourceGraphInfo(CResourceOptions * _options);
  153. ~ResourceGraphInfo();
  154. bool addCondition(IHqlExpression * condition);
  155. bool allocateResources(const CResources & value, const CResources & limit);
  156. bool canMergeActionAsSibling(bool sequential) const;
  157. bool containsActiveSinks() const;
  158. bool containsActionSink() const;
  159. unsigned getDepth();
  160. void getMergeFailReason(StringBuffer & reasonText, ResourceGraphInfo * otherGraph, const CResources & limit);
  161. bool hasSameConditions(ResourceGraphInfo & other);
  162. bool isDependentOn(ResourceGraphInfo & other, bool allowDirect);
  163. bool isVeryCheap();
  164. bool mergeInSibling(ResourceGraphInfo & other, const CResources & limit);
  165. bool mergeInSource(ResourceGraphInfo & other, const CResources & limit, bool ignoreConditional);
  166. void removeResources(const CResources & value);
  167. bool isSharedInput(IHqlExpression * expr);
  168. void addSharedInput(IHqlExpression * expr, IHqlExpression * mapped);
  169. IHqlExpression * queryMappedSharedInput(IHqlExpression * expr);
  170. protected:
  171. void display();
  172. void mergeGraph(ResourceGraphInfo & other, bool mergeConditions);
  173. bool evalDependentOn(ResourceGraphInfo & other, bool ignoreSources);
  174. public:
  175. OwnedHqlExpr createdGraph;
  176. CResourceOptions * options;
  177. GraphLinkArray dependsOn; // NB: These do not link....
  178. GraphLinkArray sources;
  179. GraphLinkArray sinks;
  180. HqlExprArray conditions;
  181. HqlExprArray sharedInputs;
  182. HqlExprArray unbalancedExternalSources;
  183. HqlExprArray balancedExternalSources;
  184. CResources resources;
  185. unsigned depth;
  186. unsigned depthSequence;
  187. bool beenResourced:1;
  188. bool isUnconditional:1;
  189. bool mergedConditionSource:1;
  190. bool hasConditionSource:1;
  191. bool hasSequentialSource:1;
  192. bool hasRootActivity:1;
  193. bool isDead:1;
  194. bool startedGeneratingResourced:1;
  195. bool inheritedExpandedDependencies:1;
  196. struct
  197. {
  198. ResourceGraphInfo * other;
  199. unsigned updateSequence;
  200. bool ignoreSources;
  201. bool value;
  202. } cachedDependent;
  203. };
  204. class CChildDependent : public CInterface
  205. {
  206. public:
  207. CChildDependent(IHqlExpression * _original, IHqlExpression * _hoisted, bool _alwaysHoist, bool _isSingleNode, bool _forceHoist)
  208. : original(_original), hoisted(_hoisted), alwaysHoist(_alwaysHoist), isSingleNode(_isSingleNode), forceHoist(_forceHoist)
  209. {
  210. projectedHoisted.set(hoisted);
  211. projected = NULL;
  212. }
  213. public:
  214. IHqlExpression * original;
  215. LinkedHqlExpr hoisted;
  216. LinkedHqlExpr projectedHoisted;
  217. bool forceHoist;
  218. bool alwaysHoist;
  219. bool isSingleNode;
  220. IHqlExpression * projected;
  221. };
  222. class ChildDependentArray : public CIArrayOf<CChildDependent>
  223. {
  224. public:
  225. unsigned findOriginal(IHqlExpression * expr);
  226. };
  227. class CSplitterLink : public CInterface
  228. {
  229. public:
  230. CSplitterLink(IHqlExpression * _source, IHqlExpression * _sink) : source(_source->queryBody()), sink(_sink->queryBody())
  231. {
  232. }
  233. IHqlExpression * queryOther(IHqlExpression * expr) const
  234. {
  235. if (expr->queryBody() == source)
  236. return sink;
  237. else
  238. return source;
  239. }
  240. bool hasSink(IHqlExpression * expr) const { return sink == expr->queryBody(); }
  241. bool hasSource(IHqlExpression * expr) const { return source == expr->queryBody(); }
  242. IHqlExpression * querySource() const { return source; }
  243. IHqlExpression * querySink() const { return sink; }
  244. void mergeSinkLink(CSplitterLink & sinkLink);
  245. private:
  246. LinkedHqlExpr source;
  247. LinkedHqlExpr sink;
  248. };
  249. class EclResourcer;
  250. class CSplitterInfo
  251. {
  252. public:
  253. CSplitterInfo(EclResourcer & _resourcer, bool _preserveBalanced, bool _ignoreExternalDependencies);
  254. ~CSplitterInfo();
  255. void addLink(IHqlExpression * source, IHqlExpression * sink, bool isExternal);
  256. void gatherPotentialSplitters(IHqlExpression * expr, IHqlExpression * sink, ResourceGraphInfo * graph, bool isDependency);
  257. bool isSplitOrBranch(IHqlExpression * expr) const;
  258. bool isBalancedSplitter(IHqlExpression * expr) const;
  259. void restoreBalanced();
  260. private:
  261. CSplitterInfo();
  262. void gatherPotentialDependencySplitters(IHqlExpression * expr, IHqlExpression * sink, ResourceGraphInfo * graph);
  263. public:
  264. EclResourcer & resourcer;
  265. HqlExprCopyArray externalSources;
  266. HqlExprCopyArray sinks;
  267. HqlExprCopyArray dependents;
  268. BoolArray wasBalanced;
  269. unsigned nextBalanceId;
  270. bool preserveBalanced;
  271. bool ignoreExternalDependencies;
  272. };
  273. class SpillerInfo : public NewTransformInfo
  274. {
  275. public:
  276. SpillerInfo(IHqlExpression * _original, CResourceOptions * _options);
  277. IHqlExpression * createSpilledRead(IHqlExpression * spillReason);
  278. IHqlExpression * createSpilledWrite(IHqlExpression * transformed, bool lazy);
  279. bool isUsedFromChild() const { return linkedFromChild; }
  280. IHqlExpression * queryOutputSpillFile() const { return outputToUseForSpill; }
  281. void setPotentialSpillFile(IHqlExpression * expr);
  282. protected:
  283. void addSpillFlags(HqlExprArray & args, bool isRead);
  284. IHqlExpression * createSpillName();
  285. bool useGraphResult();
  286. bool useGlobalResult();
  287. IHqlExpression * wrapRowOwn(IHqlExpression * expr);
  288. protected:
  289. CResourceOptions * options;
  290. HqlExprAttr spillName;
  291. HqlExprAttr spilledDataset;
  292. IHqlExpression * outputToUseForSpill;
  293. bool linkedFromChild; // could reuse a spare byte in the parent class
  294. };
  295. class ResourcerInfo : public SpillerInfo
  296. {
  297. public:
  298. enum { PathUnknown, PathConditional, PathUnconditional };
  299. ResourcerInfo(IHqlExpression * _original, CResourceOptions * _options);
  300. IHqlExpression * createTransformedExpr(IHqlExpression * expr);
  301. bool addCondition(IHqlExpression * condition);
  302. void addProjected(IHqlExpression * projected);
  303. bool alwaysExpand();
  304. unsigned calcNumConditionalUses();
  305. void clearProjected();
  306. bool expandRatherThanSpill(bool noteOtherSpills);
  307. bool expandRatherThanSplit();
  308. bool hasDependency() const;
  309. bool isExternalSpill();
  310. bool neverCommonUp();
  311. bool isSplit();
  312. bool isSpilledWrite();
  313. bool okToSpillThrough();
  314. void noteUsedFromChild(bool _forceHoist);
  315. unsigned numInternalUses();
  316. unsigned numSplitPaths();
  317. void resetBalanced();
  318. void setConditionSource(IHqlExpression * condition, bool isFirst);
  319. inline bool preventMerge()
  320. {
  321. //If we need to create a spill global result, but engine can't split then don't merge
  322. //Only required because hthor doesn't support splitters (or through-workunit results).
  323. return !options->canSplit() && options->useGlobalResult(linkedFromChild);
  324. }
  325. inline bool isUnconditional() { return (pathToExpr == ResourcerInfo::PathUnconditional); }
  326. inline bool isConditionExpr()
  327. {
  328. switch (original->getOperator())
  329. {
  330. case no_if:
  331. case no_choose:
  332. case no_chooseds:
  333. return true;
  334. case no_output:
  335. case no_buildindex:
  336. return isUpdatedConditionally(original);
  337. case no_filter:
  338. return isConditionalFilter;
  339. }
  340. return false;
  341. }
  342. inline bool isResourcedActivity() const
  343. {
  344. return isActivity || containsActivity;
  345. }
  346. void setRootActivity();
  347. bool finishedWalkingSplitters() const
  348. {
  349. return (curBalanceLink == balancedLinks.ordinality());
  350. }
  351. const CSplitterLink * queryCurrentLink() const
  352. {
  353. if (balancedLinks.isItem(curBalanceLink))
  354. return &balancedLinks.item(curBalanceLink);
  355. return NULL;
  356. }
  357. protected:
  358. bool spillSharesSplitter();
  359. IHqlExpression * createAggregation(IHqlExpression * expr);
  360. IHqlExpression * createSpiller(IHqlExpression * transformed, bool reuseSplitter);
  361. IHqlExpression * createSplitter(IHqlExpression * transformed);
  362. public:
  363. Owned<ResourceGraphInfo> graph;
  364. HqlExprAttr pathToSplitter;
  365. HqlExprArray aggregates;
  366. HqlExprArray conditions;
  367. HqlExprAttr splitterOutput;
  368. HqlExprArray projected;
  369. HqlExprAttr projectedExpr;
  370. CIArrayOf<CSplitterLink> balancedLinks;
  371. GraphLinkArray dependsOn; // NB: These do not link....
  372. unsigned numUses;
  373. unsigned numExternalUses;
  374. unsigned conditionSourceCount;
  375. unsigned currentSource;
  376. unsigned curBalanceLink = 0;
  377. unsigned lastPass;
  378. unsigned balancedExternalUses;
  379. unsigned balancedInternalUses;
  380. #ifdef TRACE_BALANCED
  381. unsigned balanceId;
  382. #endif
  383. byte pathToExpr;
  384. bool containsActivity:1;
  385. bool isActivity:1;
  386. bool isRootActivity:1;
  387. bool gatheredDependencies:1;
  388. bool isSpillPoint:1;
  389. bool balanced:1;
  390. bool isAlreadyInScope:1;
  391. bool forceHoist:1;
  392. bool neverSplit:1;
  393. bool isConditionalFilter:1;
  394. bool projectResult:1;
  395. bool visited:1;
  396. bool balancedVisiting:1;
  397. bool removedParallelPullers:1;
  398. };
  399. class EclResourceDependencyGatherer;
  400. class EclResourcer
  401. {
  402. friend class SelectHoistTransformer;
  403. friend class CSplitterInfo;
  404. public:
  405. EclResourcer(IErrorReceiver & _errors, IConstWorkUnit * _wu, const HqlCppOptions & _translatorOptions, CResourceOptions & _options);
  406. ~EclResourcer();
  407. void resourceGraph(IHqlExpression * expr, HqlExprArray & transformed);
  408. void resourceRemoteGraph(IHqlExpression * expr, HqlExprArray & transformed);
  409. void setSequential(bool _sequential) { sequential = _sequential; }
  410. void tagActiveCursors(HqlExprCopyArray * activeRows);
  411. inline unsigned numGraphResults() { return options.nextResult; }
  412. protected:
  413. void changeGraph(IHqlExpression * expr, ResourceGraphInfo * newGraph);
  414. void connectGraphs(ResourceGraphInfo * sourceGraph, IHqlExpression * sourceNode, ResourceGraphInfo * sinkGraph, IHqlExpression * sinkNode, LinkKind linkKind);
  415. ResourceGraphInfo * createGraph();
  416. ResourcerInfo * queryCreateResourceInfo(IHqlExpression * expr);
  417. void removeLink(ResourceGraphLink & link, bool keepExternalUses);
  418. void replaceGraphReferences(IHqlExpression * expr, ResourceGraphInfo * oldGraph, ResourceGraphInfo * newGraph);
  419. void replaceGraphReferences(ResourceGraphInfo * oldGraph, ResourceGraphInfo * newGraph);
  420. //Pass 1
  421. bool findSplitPoints(IHqlExpression * expr, bool isProjected);
  422. void findSplitPoints(HqlExprArray & exprs);
  423. void noteConditionalChildren(BoolArray & alwaysHoistChild);
  424. void deriveUsageCounts(IHqlExpression * expr);
  425. void deriveUsageCounts(const HqlExprArray & exprs);
  426. //Pass 2
  427. void createInitialGraph(IHqlExpression * expr, IHqlExpression * owner, ResourceGraphInfo * ownerGraph, LinkKind linkKind, bool forceNewGraph);
  428. void createInitialGraphs(HqlExprArray & exprs);
  429. void createInitialRemoteGraph(IHqlExpression * expr, IHqlExpression * owner, ResourceGraphInfo * ownerGraph, bool forceNewGraph);
  430. void createInitialRemoteGraphs(HqlExprArray & exprs);
  431. //Pass 3
  432. void markAsUnconditional(IHqlExpression * expr, ResourceGraphInfo * ownerGraph, IHqlExpression * condition);
  433. void markCondition(IHqlExpression * expr, IHqlExpression * condition, bool wasConditional);
  434. void markConditionBranch(unsigned childIndex, IHqlExpression * expr, IHqlExpression * condition, bool wasConditional);
  435. void markConditions(HqlExprArray & exprs);
  436. void markChildDependentsAsUnconditional(ResourcerInfo * info, IHqlExpression * condition);
  437. //Pass 4
  438. void createResourceSplit(IHqlExpression * expr, IHqlExpression * owner, ResourceGraphInfo * ownerNewGraph, ResourceGraphInfo * originalGraph);
  439. void getResources(IHqlExpression * expr, CResources & exprResources);
  440. bool calculateResourceSpillPoints(IHqlExpression * expr, ResourceGraphInfo * graph, CResources & resourcesSoFar, bool hasGoodSpillPoint, bool canSpill);
  441. void insertResourceSpillPoints(IHqlExpression * expr, IHqlExpression * owner, ResourceGraphInfo * ownerOriginalGraph, ResourceGraphInfo * ownerNewGraph);
  442. void resourceSubGraph(ResourceGraphInfo * graph);
  443. void resourceSubGraphs(HqlExprArray & exprs);
  444. //Pass 5
  445. void addDependencies(EclResourceDependencyGatherer & gatherer, IHqlExpression * expr, ResourceGraphInfo * graph, IHqlExpression * activityExpr);
  446. void addDependencies(HqlExprArray & exprs);
  447. //Pass 6
  448. bool queryMergeGraphLink(ResourceGraphLink & link);
  449. void mergeSubGraphs();
  450. void mergeSubGraphs(unsigned pass);
  451. void mergeSiblings();
  452. //Pass 6b
  453. void oldSpotUnbalancedSplitters(IHqlExpression * expr, unsigned whichSource, IHqlExpression * path, ResourceGraphInfo * graph);
  454. void oldSpotUnbalancedSplitters(HqlExprArray & exprs);
  455. //Pass 6c
  456. void spotSharedInputs(IHqlExpression * expr, ResourceGraphInfo * graph);
  457. void spotSharedInputs();
  458. bool allInputsPulledIndependently(IHqlExpression * expr) const;
  459. bool removePassThrough(CSplitterInfo & connections, ResourcerInfo & info);
  460. void removeDuplicateIndependentLinks(CSplitterInfo & connections, ResourcerInfo & info);
  461. void optimizeIndependentLinks(CSplitterInfo & connections, ResourcerInfo & info);
  462. void optimizeConditionalLinks(CSplitterInfo & connections);
  463. IHqlExpression * walkPotentialSplitterLinks(CSplitterInfo & connections, IHqlExpression * expr, const CSplitterLink * link);
  464. IHqlExpression * walkPotentialSplitters(CSplitterInfo & connections, IHqlExpression * expr, const CSplitterLink & link);
  465. void walkPotentialSplitters(CSplitterInfo & connections);
  466. void extractSharedInputs(CSplitterInfo & connections, ResourceGraphInfo & graph);
  467. void spotUnbalancedSplitters(const HqlExprArray & exprs);
  468. //Pass 7
  469. bool optimizeAggregate(IHqlExpression * expr);
  470. void optimizeAggregates();
  471. //Pass 8
  472. IHqlExpression * findPredecessor(IHqlExpression * expr, IHqlExpression * search, IHqlExpression * prev);
  473. IHqlExpression * findPredecessor(ResourcerInfo * search);
  474. void moveExternalSpillPoints();
  475. //Pass 9
  476. IHqlExpression * doCreateResourced(IHqlExpression * expr, ResourceGraphInfo * graph, bool expandInParent, bool defineSideEffect);
  477. IHqlExpression * createResourced(IHqlExpression * expr, ResourceGraphInfo * graph, bool expandInParent, bool defineSideEffect);
  478. void createResourced(HqlExprArray & transformed);
  479. void createResourced(ResourceGraphInfo * graph, HqlExprArray & transformed);
  480. void inheritRedundantDependencies(ResourceGraphInfo * thisGraph);
  481. void display(StringBuffer & out);
  482. void trace();
  483. void doCheckRecursion(ResourceGraphInfo * graph, PointerArray & visited);
  484. void checkRecursion(ResourceGraphInfo * graph, PointerArray & visited);
  485. void checkRecursion(ResourceGraphInfo * graph);
  486. unsigned getMaxDepth() const;
  487. bool checkAlreadyVisited(ResourcerInfo * info);
  488. void nextPass() { thisPass++; }
  489. protected:
  490. Owned<IConstWorkUnit> wu;
  491. CIArrayOf<ResourceGraphInfo> graphs;
  492. CIArrayOf<ResourceGraphLink> links;
  493. ClusterType targetClusterType;
  494. CResources * resourceLimit;
  495. IErrorReceiver * errors;
  496. unsigned thisPass;
  497. bool spilled;
  498. bool insideNeverSplit;
  499. bool insideSteppedNeverSplit;
  500. bool sequential;
  501. CResourceOptions & options;
  502. HqlExprArray rootConditions;
  503. HqlExprCopyArray activeSelectors;
  504. };
  505. #endif