Skip to content

Commit

Permalink
Merge pull request #19415 from richardkchapman/issue33055
Browse files Browse the repository at this point in the history
HPCC-33055 Support KEYED JOIN where rhs may evaluate to a null dataset

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Merged-by: Gavin Halliday <ghalliday@hpccsystems.com>
  • Loading branch information
ghalliday authored Jan 16, 2025
2 parents 08e8efe + 8c27c30 commit 9bfbf99
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
18 changes: 11 additions & 7 deletions roxie/ccd/ccdactivities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2509,15 +2509,19 @@ class CRoxieKeyedActivity : public CRoxieAgentActivity
else
{
IKeyIndexBase *kib = keyArray->queryKeyPart(lastPartNo.partNo);
assertex(kib != NULL);
IKeyIndex *k = kib->queryPart(lastPartNo.fileNo);
if (filechanged)
if (!kib)
tlk.clear();
else
{
tlk.setown(createLocalKeyManager(*keyRecInfo, k, &logctx, hasNewSegmentMonitors(), !logctx.isBlind()));
createSegmentMonitorsPending = true;
IKeyIndex *k = kib->queryPart(lastPartNo.fileNo);
if (filechanged || !tlk)
{
tlk.setown(createLocalKeyManager(*keyRecInfo, k, &logctx, hasNewSegmentMonitors(), !logctx.isBlind()));
createSegmentMonitorsPending = true;
}
else
tlk->setKey(k);
}
else
tlk->setKey(k);
}
}

Expand Down
24 changes: 22 additions & 2 deletions roxie/ccd/ccdserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,11 @@ class CRoxieServerActivity : implements CInterfaceOf<IRoxieServerActivity>, impl
virtual IEngineRowStream *queryConcreteOutputStream(unsigned whichInput) { assertex(whichInput==0); return this; }
virtual IStrandJunction *queryConcreteOutputJunction(unsigned idx) const { assertex(idx==0); return junction; }
virtual IRoxieServerActivity *queryActivity() { return this; }
virtual IIndexReadActivityInfo *queryIndexReadActivity() { return NULL; }
virtual IIndexReadActivityInfo *queryIndexReadActivity()
{
CTXLOG("Activity does not implement queryIndexReadActivity");
return NULL;
}

virtual bool needsAllocator() const { return false; }

Expand Down Expand Up @@ -5527,6 +5531,18 @@ IRoxieServerActivityFactory *createRoxieServerApplyActivityFactory(unsigned _id,

//=================================================================================

static class CDummyIndexReadInfo : public CInterfaceOf<IIndexReadActivityInfo>
{
public:
virtual IKeyArray *getKeySet() const { return nullptr; }
virtual const IResolvedFile *getVarFileInfo() const { return nullptr; }
virtual ITranslatorSet *getTranslators() const { return nullptr; }

virtual void mergeSegmentMonitors(IIndexReadContext *irc) const { }
virtual IRoxieServerActivity *queryActivity() { throwUnexpected(); }; // Should never involve remote agent if keyset has returned nullptr
virtual const RemoteActivityId &queryRemoteId() const { throwUnexpected(); }
} dummyIndexReadInfo;

class CRoxieServerNullActivity : public CRoxieServerActivity
{
public:
Expand All @@ -5540,6 +5556,10 @@ class CRoxieServerNullActivity : public CRoxieServerActivity
return NULL;
}

virtual IIndexReadActivityInfo *queryIndexReadActivity()
{
return &dummyIndexReadInfo;
}
};

IRoxieServerActivity * createRoxieServerNullActivity(IRoxieAgentContext *_ctx, const IRoxieServerActivityFactory *_factory, IProbeManager *_probeManager)
Expand Down Expand Up @@ -21211,7 +21231,7 @@ class CRoxieServerIfActivity : public CRoxieServerActivity
IFinalRoxieInput *in = cond ? inputTrue : inputFalse;
if (in)
return in->queryIndexReadActivity();
return NULL;
return &dummyIndexReadInfo;
}

virtual void reset()
Expand Down
5 changes: 1 addition & 4 deletions testing/regress/ecl/stresstext_if.ecl
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
//version multiPart=true,variant='inplace',conditionVersion=2
//version multiPart=true,variant='inplace',conditionVersion=3
//version multiPart=true,variant='',conditionVersion=2

//The following is processed correctly by the code generator, but not yet supported by roxie
//enable the test once the necessary changes are made in the roxie engine.
//noversion multiPart=true,variant='',conditionVersion=4
//version multiPart=true,variant='',conditionVersion=4

// The settings below may be useful when trying to analyse Roxie keyed join behaviour, as they will
// eliminate some wait time for an agent queue to become available
Expand Down

0 comments on commit 9bfbf99

Please sign in to comment.