|
@@ -39,7 +39,14 @@
|
|
|
#define MAX_RECORD_SIZE 4096 // default value
|
|
|
|
|
|
enum { HintSpeed = 1, HintSize = 2 };
|
|
|
-enum GraphLocalisation { GraphCoLocal, GraphNonLocal, GraphCoNonLocal, GraphRemote, GraphNoAccess };
|
|
|
+enum GraphLocalisation {
|
|
|
+ GraphNoAccess = 0,
|
|
|
+ GraphCoLocal = 1,
|
|
|
+ GraphNonLocal = 2,
|
|
|
+ GraphCoNonLocal = 3,
|
|
|
+ GraphRemote = 4
|
|
|
+};
|
|
|
+
|
|
|
enum {
|
|
|
EclTextPrio = 1000, // has no dependencies on anything else
|
|
|
TypeInfoPrio = 1200,
|
|
@@ -454,247 +461,6 @@ class ActivityInstance;
|
|
|
class SerializationRow;
|
|
|
class EvalContext;
|
|
|
class InternalResultTracker;
|
|
|
-// A parent extract represents the set of fields etc. which are used from the parent activity,
|
|
|
-// which are local to the point that the executeChildActivity() is called.
|
|
|
-class ParentExtract : public HqlExprAssociation
|
|
|
-{
|
|
|
-public:
|
|
|
- ParentExtract(HqlCppTranslator & _translator, GraphLocalisation _localisation, EvalContext * _container=NULL);
|
|
|
- ~ParentExtract();
|
|
|
-
|
|
|
-//HqlExprAssociation
|
|
|
- virtual AssocKind getKind() { return AssocExtract; }
|
|
|
-
|
|
|
- void beginCreateExtract(BuildCtx & buildctx, bool doDeclare);
|
|
|
- void beginNestedExtract(BuildCtx & clonectx);
|
|
|
- void beginReuseExtract();
|
|
|
- void endCreateExtract(CHqlBoundExpr & boundExtract);
|
|
|
- void endUseExtract(BuildCtx & ctx);
|
|
|
- IHqlExpression * queryExtractName() { return boundExtract.expr; }
|
|
|
-
|
|
|
- bool canEvaluate(IHqlExpression * expr);
|
|
|
- bool canSerializeFields() { return buildctx != NULL; }
|
|
|
- void associateCursors(BuildCtx & declarectx, BuildCtx & evalctx, GraphLocalisation childLocalisation);
|
|
|
- void beginChildActivity(BuildCtx & declareCtx, BuildCtx & startCtx, GraphLocalisation childLocalisation, IHqlExpression * colocal, bool nested, bool ignoreSelf, ActivityInstance * activityRequiringCast);
|
|
|
- void endChildActivity();
|
|
|
-
|
|
|
- void addSerializedExpression(IHqlExpression * value, ITypeInfo * type);
|
|
|
- void buildAssign(IHqlExpression * serializedTarget, IHqlExpression * originalValue);
|
|
|
- AliasKind evaluateExpression(BuildCtx & ctx, IHqlExpression * value, CHqlBoundExpr & tgt, IHqlExpression * colocal, bool evaluateLocally);
|
|
|
-
|
|
|
- void setAllowDestructor() { canDestroyExtract = true; }
|
|
|
- inline GraphLocalisation queryLocalisation() { return localisation; }
|
|
|
-
|
|
|
-protected:
|
|
|
- void ensureAccessible(BuildCtx & ctx, IHqlExpression * expr, const CHqlBoundExpr & bound, CHqlBoundExpr & tgt, IHqlExpression * colocal);
|
|
|
- void gatherActiveRows(BuildCtx & ctx);
|
|
|
-
|
|
|
-protected:
|
|
|
- HqlCppTranslator & translator;
|
|
|
- EvalContext * container;
|
|
|
- SerializationRow * serialization; // fields that are serialized to the children
|
|
|
- SerializationRow * childSerialization; // same serialization, but as it is bound in the child.
|
|
|
-
|
|
|
- CursorArray colocalBoundCursors; // what rows/cursors are available at the point of executeChildGraph()
|
|
|
- CursorArray nonlocalBoundCursors; // what rows/cursors are available at the point of executeChildGraph()
|
|
|
- GraphLocalisation localisation; // what kind of localisation do ALL the children have?
|
|
|
-
|
|
|
- CursorArray inheritedCursors;
|
|
|
- CursorArray localCursors; // does not include colocal
|
|
|
- CursorArray cursorToBind;
|
|
|
- CHqlBoundExpr boundBuilder; // may have wrapper, or be a char[n]
|
|
|
- CHqlBoundExpr boundExtract; // always a reference to a row. for "extract"
|
|
|
- Owned<BuildCtx> buildctx; // may be null if nested extract
|
|
|
- bool canDestroyExtract;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-class CtxCollection : public CInterface
|
|
|
-{
|
|
|
-public:
|
|
|
- CtxCollection(BuildCtx & _declareCtx) : clonectx(_declareCtx), childctx(_declareCtx), declarectx(_declareCtx) {}
|
|
|
-
|
|
|
- void createFunctionStructure(HqlCppTranslator & translator, BuildCtx & ctx, bool canEvaluate, const char * serializeFunc);
|
|
|
-
|
|
|
-public:
|
|
|
- BuildCtx clonectx;
|
|
|
- BuildCtx childctx; // child.onCreate() is called from here..
|
|
|
- BuildCtx declarectx;
|
|
|
-
|
|
|
- //following are always null for nested classes, always created for others.
|
|
|
- Owned<BuildCtx> evalctx;
|
|
|
- Owned<BuildCtx> serializectx;
|
|
|
- Owned<BuildCtx> deserializectx;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-//A potential location for an extract to be created...
|
|
|
-class EvalContext : public HqlExprAssociation
|
|
|
-{
|
|
|
-public:
|
|
|
- EvalContext(HqlCppTranslator & _translator, ParentExtract * _parentExtract, EvalContext * _parent);
|
|
|
-
|
|
|
- virtual AssocKind getKind() { return AssocExtractContext; }
|
|
|
-
|
|
|
- virtual IHqlExpression * createGraphLookup(unique_id_t id, bool isChild);
|
|
|
- virtual AliasKind evaluateExpression(BuildCtx & ctx, IHqlExpression * value, CHqlBoundExpr & tgt, bool evaluateLocally) = 0;
|
|
|
- virtual bool isColocal() { return true; }
|
|
|
- virtual ActivityInstance * queryActivity();
|
|
|
- virtual bool isLibraryContext() { return false; }
|
|
|
-
|
|
|
- virtual void tempCompatiablityEnsureSerialized(const CHqlBoundTarget & tgt) = 0;
|
|
|
- virtual bool getInvariantMemberContext(BuildCtx * ctx, BuildCtx * * declarectx, BuildCtx * * initctx, bool isIndependentMaybeShared, bool invariantEachStart) { return false; }
|
|
|
-
|
|
|
- void ensureContextAvailable() { ensureHelpersExist(); }
|
|
|
- virtual bool evaluateInParent(BuildCtx & ctx, IHqlExpression * expr, bool hasOnStart);
|
|
|
- bool hasParent() { return parent != NULL; }
|
|
|
- bool needToEvaluateLocally(BuildCtx & ctx, IHqlExpression * expr);
|
|
|
-
|
|
|
-public://only used by friends
|
|
|
- virtual void callNestedHelpers(const char * memberName) = 0;
|
|
|
- virtual void ensureHelpersExist() = 0;
|
|
|
- virtual bool insideQueryDepth(unsigned depth) = 0;
|
|
|
- virtual bool isRowInvariant(IHqlExpression * expr) { return false; }
|
|
|
-
|
|
|
- bool insideChildQuery();
|
|
|
-
|
|
|
-protected:
|
|
|
- Owned<ParentExtract> parentExtract; // extract of the parent EvalContext
|
|
|
- HqlCppTranslator & translator;
|
|
|
- EvalContext * parent;
|
|
|
- OwnedHqlExpr colocalMember;
|
|
|
-};
|
|
|
-
|
|
|
-class ClassEvalContext : public EvalContext
|
|
|
-{
|
|
|
- friend class ActivityInstance;
|
|
|
- friend class GlobalClassBuilder;
|
|
|
-public:
|
|
|
- ClassEvalContext(HqlCppTranslator & _translator, ParentExtract * _parentExtract, EvalContext * _parent, BuildCtx & createctx, BuildCtx & startctx);
|
|
|
-
|
|
|
- virtual AliasKind evaluateExpression(BuildCtx & ctx, IHqlExpression * value, CHqlBoundExpr & tgt, bool evaluateLocally);
|
|
|
- virtual bool isRowInvariant(IHqlExpression * expr);
|
|
|
-
|
|
|
- virtual void tempCompatiablityEnsureSerialized(const CHqlBoundTarget & tgt);
|
|
|
- virtual bool getInvariantMemberContext(BuildCtx * ctx, BuildCtx * * declarectx, BuildCtx * * initctx, bool isIndependentMaybeShared, bool invariantEachStart);
|
|
|
-
|
|
|
-protected:
|
|
|
- void cloneAliasInClass(CtxCollection & ctxs, const CHqlBoundExpr & bound, CHqlBoundExpr & tgt);
|
|
|
- IHqlExpression * cloneExprInClass(CtxCollection & ctxs, IHqlExpression * expr);
|
|
|
- void createMemberAlias(CtxCollection & ctxs, BuildCtx & ctx, IHqlExpression * value, CHqlBoundExpr & tgt);
|
|
|
- void doCallNestedHelpers(const char * member, const char * acticity);
|
|
|
- void ensureSerialized(CtxCollection & ctxs, const CHqlBoundTarget & tgt);
|
|
|
-
|
|
|
-protected:
|
|
|
- CtxCollection onCreate;
|
|
|
- CtxCollection onStart;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-class GlobalClassEvalContext : public ClassEvalContext
|
|
|
-{
|
|
|
-public:
|
|
|
- GlobalClassEvalContext(HqlCppTranslator & _translator, ParentExtract * _parentExtract, EvalContext * _parent, BuildCtx & createctx, BuildCtx & startctx);
|
|
|
-
|
|
|
- virtual void callNestedHelpers(const char * memberName);
|
|
|
- virtual IHqlExpression * createGraphLookup(unique_id_t id, bool isChild) { throwUnexpected(); }
|
|
|
- virtual void ensureHelpersExist();
|
|
|
- virtual bool insideQueryDepth(unsigned depth) { return false; }
|
|
|
- virtual bool isColocal() { return false; }
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-class ActivityEvalContext : public ClassEvalContext
|
|
|
-{
|
|
|
- friend class ActivityInstance;
|
|
|
-public:
|
|
|
- ActivityEvalContext(HqlCppTranslator & _translator, ActivityInstance * _activity, ParentExtract * _parentExtract, EvalContext * _parent, IHqlExpression * _colocal, BuildCtx & createctx, BuildCtx & startctx);
|
|
|
-
|
|
|
- virtual void callNestedHelpers(const char * memberName);
|
|
|
- virtual IHqlExpression * createGraphLookup(unique_id_t id, bool isChild);
|
|
|
- virtual void ensureHelpersExist();
|
|
|
- virtual bool insideQueryDepth(unsigned depth);
|
|
|
- virtual bool isColocal() { return (colocalMember != NULL); }
|
|
|
- virtual ActivityInstance * queryActivity();
|
|
|
-
|
|
|
- void createMemberAlias(CtxCollection & ctxs, BuildCtx & ctx, IHqlExpression * value, CHqlBoundExpr & tgt);
|
|
|
-
|
|
|
-protected:
|
|
|
- ActivityInstance * activity;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-class NestedEvalContext : public ClassEvalContext
|
|
|
-{
|
|
|
-public:
|
|
|
- NestedEvalContext(HqlCppTranslator & _translator, const char * _memberName, ParentExtract * _parentExtract, EvalContext * _parent, IHqlExpression * _colocal, BuildCtx & createctx, BuildCtx & startctx);
|
|
|
-
|
|
|
- virtual void callNestedHelpers(const char * memberName);
|
|
|
- virtual IHqlExpression * createGraphLookup(unique_id_t id, bool isChild);
|
|
|
- virtual void ensureHelpersExist();
|
|
|
- virtual bool insideQueryDepth(unsigned depth);
|
|
|
-
|
|
|
- void initContext();
|
|
|
- virtual bool evaluateInParent(BuildCtx & ctx, IHqlExpression * expr, bool hasOnStart);
|
|
|
-
|
|
|
-protected:
|
|
|
- bool helpersExist;
|
|
|
-
|
|
|
-protected:
|
|
|
- StringAttr memberName;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-class MemberEvalContext : public EvalContext
|
|
|
-{
|
|
|
-public:
|
|
|
- MemberEvalContext(HqlCppTranslator & _translator, ParentExtract * _parentExtract, EvalContext * _parent, BuildCtx & _ctx);
|
|
|
-
|
|
|
- virtual void callNestedHelpers(const char * memberName);
|
|
|
- virtual void ensureHelpersExist();
|
|
|
- virtual bool insideQueryDepth(unsigned depth);
|
|
|
- virtual bool isRowInvariant(IHqlExpression * expr);
|
|
|
-
|
|
|
- virtual IHqlExpression * createGraphLookup(unique_id_t id, bool isChild);
|
|
|
- virtual AliasKind evaluateExpression(BuildCtx & ctx, IHqlExpression * value, CHqlBoundExpr & tgt, bool evaluateLocally);
|
|
|
-
|
|
|
- virtual bool getInvariantMemberContext(BuildCtx * ctx, BuildCtx * * declarectx, BuildCtx * * initctx, bool isIndependentMaybeShared, bool invariantEachStart);
|
|
|
- virtual void tempCompatiablityEnsureSerialized(const CHqlBoundTarget & tgt);
|
|
|
-
|
|
|
- void initContext();
|
|
|
-
|
|
|
-protected:
|
|
|
- BuildCtx ctx;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-class LibraryEvalContext : public EvalContext
|
|
|
-{
|
|
|
-public:
|
|
|
- LibraryEvalContext(HqlCppTranslator & _translator);
|
|
|
-
|
|
|
- virtual AliasKind evaluateExpression(BuildCtx & ctx, IHqlExpression * value, CHqlBoundExpr & tgt, bool evaluateLocally);
|
|
|
- virtual bool isColocal() { return false; }
|
|
|
- virtual bool isLibraryContext() { return true; }
|
|
|
-
|
|
|
- virtual void tempCompatiablityEnsureSerialized(const CHqlBoundTarget & tgt);
|
|
|
-
|
|
|
- void associateExpression(BuildCtx & ctx, IHqlExpression * value);
|
|
|
- void ensureContextAvailable() { }
|
|
|
-
|
|
|
-public:
|
|
|
- virtual void callNestedHelpers(const char * memberName) {}
|
|
|
- virtual void ensureHelpersExist() {}
|
|
|
- virtual bool insideQueryDepth(unsigned depth) { return false; }
|
|
|
-
|
|
|
-protected:
|
|
|
- HqlExprArray values;
|
|
|
- HqlExprArray bound;
|
|
|
-};
|
|
|
-
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
typedef CIArrayOf<BuildCtx> BuildCtxArray;
|
|
@@ -967,6 +733,17 @@ public:
|
|
|
|
|
|
class AliasExpansionInfo;
|
|
|
class HashCodeCreator;
|
|
|
+class ParentExtract;
|
|
|
+enum PEtype {
|
|
|
+ PETnone,
|
|
|
+ PETchild, // child query
|
|
|
+ PETremote, // allnodes
|
|
|
+ PETloop, // loop
|
|
|
+ PETnested, // nested class
|
|
|
+ PETcallback, // callback within a function
|
|
|
+ PETlibrary, // a library
|
|
|
+ PETmax };
|
|
|
+
|
|
|
class HQLCPP_API HqlCppTranslator : public CInterface, implements IHqlCppTranslator
|
|
|
{
|
|
|
//MORE: This is in serious need of refactoring....
|
|
@@ -1208,8 +985,8 @@ public:
|
|
|
IHqlExpression * createRowSerializer(BuildCtx & ctx, IHqlExpression * record, _ATOM kind);
|
|
|
|
|
|
AliasKind buildExprInCorrectContext(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt, bool evaluateLocally);
|
|
|
- ParentExtract * createExtractBuilder(BuildCtx & ctx, IHqlExpression * expr, bool doDeclare);
|
|
|
- ParentExtract * createExtractBuilder(BuildCtx & ctx, GraphLocalisation localisation, bool doDeclare);
|
|
|
+ ParentExtract * createExtractBuilder(BuildCtx & ctx, PEtype type, IHqlExpression * expr, bool doDeclare);
|
|
|
+ ParentExtract * createExtractBuilder(BuildCtx & ctx, PEtype type, GraphLocalisation localisation, bool doDeclare);
|
|
|
|
|
|
void buildDefaultRow(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & bound);
|
|
|
void buildNullRow(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & bound);
|
|
@@ -1840,6 +1617,7 @@ public:
|
|
|
EvalContext * queryEvalContext(BuildCtx & ctx) { return (EvalContext *)ctx.queryFirstAssociation(AssocExtractContext); }
|
|
|
inline unsigned nextActivityId() { return ++curActivityId; }
|
|
|
bool insideChildGraph(BuildCtx & ctx);
|
|
|
+ bool insideChildQuery(BuildCtx & ctx);
|
|
|
bool insideRemoteGraph(BuildCtx & ctx);
|
|
|
bool isCurrentActiveGraph(BuildCtx & ctx, IHqlExpression * graphTag);
|
|
|
|
|
@@ -2004,7 +1782,7 @@ protected:
|
|
|
IHqlExpression * optimizeCompoundSource(IHqlExpression * expr, unsigned flags);
|
|
|
IHqlExpression * optimizeGraphPostResource(IHqlExpression * expr, unsigned csfFlags);
|
|
|
bool isInlineOk();
|
|
|
- GraphLocalisation getGraphLocalisation(IHqlExpression * expr);
|
|
|
+ GraphLocalisation getGraphLocalisation(IHqlExpression * expr, bool isInsideChildQuery);
|
|
|
bool isAlwaysCoLocal();
|
|
|
bool isNeverDistributed(IHqlExpression * expr);
|
|
|
|