Bläddra i källkod

Fix: gh-739 - Implement WHEN activities

HThor needs to implement TAKwhen_action and TAKwhen_dataset activities.
Implemented single activity which handles both.

Signed-off-by: William Whitehead <william.whitehead@lexisnexis.com>
William Whitehead 13 år sedan
förälder
incheckning
43547c4ea6
4 ändrade filer med 50 tillägg och 6 borttagningar
  1. 6 5
      ecl/eclagent/eclgraph.cpp
  2. 31 0
      ecl/hthor/hthor.cpp
  3. 2 1
      ecl/hthor/hthor.hpp
  4. 11 0
      ecl/hthor/hthor.ipp

+ 6 - 5
ecl/eclagent/eclgraph.cpp

@@ -41,7 +41,7 @@
 
 //---------------------------------------------------------------------------
 
-static IHThorActivity * createActivity(IAgentContext & agent, unsigned activityId, unsigned subgraphId, unsigned graphId, ThorActivityKind kind, bool isLocal, bool isGrouped, IHThorArg & arg, IPropertyTree * node)
+static IHThorActivity * createActivity(IAgentContext & agent, unsigned activityId, unsigned subgraphId, unsigned graphId, ThorActivityKind kind, bool isLocal, bool isGrouped, IHThorArg & arg, IPropertyTree * node, EclGraphElement * graphElement)
 {
     switch (kind)
     {
@@ -201,12 +201,13 @@ static IHThorActivity * createActivity(IAgentContext & agent, unsigned activityI
         return createRowResultActivity(agent, activityId, subgraphId, (IHThorRowResultArg &)arg, kind);
     case TAKdatasetresult:          
         return createDatasetResultActivity(agent, activityId, subgraphId, (IHThorDatasetResultArg &)arg, kind);
+    case TAKwhen_dataset:
+    case TAKwhen_action:
+        return createWhenActionActivity(agent, activityId, subgraphId, (IHThorWhenActionArg &)arg, kind, graphElement);
     case TAKsequential:
     case TAKparallel:
     case TAKemptyaction:
     case TAKifaction:
-    case TAKwhen_dataset:
-    case TAKwhen_action:
         return createDummyActivity(agent, activityId, subgraphId, arg, kind);
     case TAKhashdedup:
         return createHashDedupActivity(agent, activityId, subgraphId, (IHThorHashDedupArg &)arg, kind);
@@ -447,7 +448,7 @@ void EclGraphElement::createActivity(IAgentContext & agent, EclSubGraph * owner)
         else
         {
             arg.setown(createHelper(agent, owner));
-            activity.setown(::createActivity(agent, id, subgraph->id, resultsGraph ? resultsGraph->id : 0, TAKnull, false, false, *arg, node));
+            activity.setown(::createActivity(agent, id, subgraph->id, resultsGraph ? resultsGraph->id : 0, TAKnull, false, false, *arg, node, this));
         }
         break;
     case TAKlibrarycall:
@@ -465,7 +466,7 @@ void EclGraphElement::createActivity(IAgentContext & agent, EclSubGraph * owner)
                 }
             }
             arg.setown(createHelper(agent, owner));
-            activity.setown(::createActivity(agent, id, subgraph->id, resultsGraph ? resultsGraph->id : 0, kind, isLocal, isGrouped, *arg, node));
+            activity.setown(::createActivity(agent, id, subgraph->id, resultsGraph ? resultsGraph->id : 0, kind, isLocal, isGrouped, *arg, node, this));
 
             ForEachItemIn(i2, branches)
             {

+ 31 - 0
ecl/hthor/hthor.cpp

@@ -43,6 +43,7 @@
 #include "thorxmlwrite.hpp"
 #include "jsmartsock.hpp"
 #include "thorstep.hpp"
+#include "eclagent.ipp"
 
 #define EMPTY_LOOP_LIMIT 1000
 
@@ -5907,6 +5908,35 @@ const void *CHThorDummyActivity::nextInGroup()
 
 //=====================================================================================================
 
+CHThorWhenActionActivity::CHThorWhenActionActivity(IAgentContext &_agent, unsigned _activityId, unsigned _subgraphId, IHThorArg &_arg, ThorActivityKind _kind, EclGraphElement * _graphElement)
+                         : CHThorSimpleActivityBase(_agent, _activityId, _subgraphId, _arg, _kind), graphElement(_graphElement)
+{
+}
+
+void CHThorWhenActionActivity::ready()
+{
+    CHThorSimpleActivityBase::ready();
+    graphElement->executeDependentActions(agent, NULL, WhenParallelId);
+}
+
+void CHThorWhenActionActivity::execute()
+{
+    graphElement->executeDependentActions(agent, NULL, 1);
+}
+
+const void * CHThorWhenActionActivity::nextInGroup()
+{
+    return input->nextInGroup();
+}
+
+void CHThorWhenActionActivity::done()
+{
+    graphElement->executeDependentActions(agent, NULL, WhenSuccessId);
+    CHThorSimpleActivityBase::done();
+}
+
+//=====================================================================================================
+
 CHThorMultiInputActivity::CHThorMultiInputActivity(IAgentContext &_agent, unsigned _activityId, unsigned _subgraphId, IHThorArg &_arg, ThorActivityKind _kind) : CHThorSimpleActivityBase(_agent, _activityId, _subgraphId, _arg, _kind)
 {
 }
@@ -9621,6 +9651,7 @@ extern HTHOR_API IHThorActivity *createDummyActivity(IAgentContext &_agent, unsi
     return new CHThorDummyActivity(_agent, _activityId, _subgraphId, arg, kind);
 }
 
+MAKEFACTORY_EXTRA(WhenAction,EclGraphElement *)
 MAKEFACTORY_EXTRA(LibraryCall, IPropertyTree *)
 MAKEFACTORY(ChildNormalize)
 MAKEFACTORY(ChildAggregate)

+ 2 - 1
ecl/hthor/hthor.hpp

@@ -38,7 +38,7 @@
 void HTHOR_API setHThorRowManager(roxiemem::IRowManager * manager); // do not call after the first use (unless you have thought very very hard about this)
 
 class PointerArray;
-
+class EclGraphElement;
 
 inline const void * nextUngrouped(ISimpleInputBase * input)
 {
@@ -159,6 +159,7 @@ extern HTHOR_API IHThorActivity *createChildIteratorActivity(IAgentContext &, un
 extern HTHOR_API IHThorActivity *createRowResultActivity(IAgentContext &, unsigned _activityId, unsigned _subgraphId, IHThorRowResultArg &arg, ThorActivityKind kind);
 extern HTHOR_API IHThorActivity *createDatasetResultActivity(IAgentContext &, unsigned _activityId, unsigned _subgraphId, IHThorDatasetResultArg &arg, ThorActivityKind kind);
 extern HTHOR_API IHThorActivity *createDummyActivity(IAgentContext &_agent, unsigned _activityId, unsigned _subgraphId, IHThorArg &arg, ThorActivityKind kind);
+extern HTHOR_API IHThorActivity *createWhenActionActivity(IAgentContext &_agent, unsigned _activityId, unsigned _subgraphId, IHThorArg &arg, ThorActivityKind kind, EclGraphElement * _graphElement);
 extern HTHOR_API IHThorActivity *createChildNormalizeActivity(IAgentContext &_agent, unsigned _activityId, unsigned _subgraphId, IHThorChildNormalizeArg &arg, ThorActivityKind kind);
 extern HTHOR_API IHThorActivity *createChildAggregateActivity(IAgentContext &_agent, unsigned _activityId, unsigned _subgraphId, IHThorChildAggregateArg &arg, ThorActivityKind kind);
 extern HTHOR_API IHThorActivity *createChildGroupAggregateActivity(IAgentContext &_agent, unsigned _activityId, unsigned _subgraphId, IHThorChildGroupAggregateArg &arg, ThorActivityKind kind);

+ 11 - 0
ecl/hthor/hthor.ipp

@@ -1674,6 +1674,17 @@ public:
     virtual void execute();
 };
 
+class CHThorWhenActionActivity : public CHThorSimpleActivityBase
+{
+    EclGraphElement * graphElement;
+public:
+    CHThorWhenActionActivity(IAgentContext &_agent, unsigned _activityId, unsigned _subgraphId, IHThorArg &_arg, ThorActivityKind _kind, EclGraphElement * _graphElement);
+
+    virtual void execute();
+    virtual const void *nextInGroup();
+    virtual void ready();
+    virtual void done();
+};
 
 class CHThorDummyActivity : public CHThorSimpleActivityBase
 {