Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32780 Extend STD.System.Workunit.WorkunitMessages to return priority and cost #19311

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ecllibrary/std/system/Workunit.ecl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ EXPORT TimeStampRecord := lib_workunitservices.WsTimeStamp;

EXPORT MessageRecord := lib_workunitservices.WsMessage;

EXPORT MessageRecord_v2 := lib_workunitservices.WsMessage_v2;

EXPORT FileReadRecord := lib_workunitservices.WsFileRead;

EXPORT FileWrittenRecord := lib_workunitservices.WsFileWritten;
Expand Down Expand Up @@ -126,7 +128,7 @@ EXPORT dataset(TimeStampRecord) WorkunitTimeStamps(varstring wuid) :=
* @param wuid the name of the workunit
*/

EXPORT dataset(MessageRecord) WorkunitMessages(varstring wuid) :=
EXPORT dataset(MessageRecord_v2) WorkunitMessages(varstring wuid) :=
lib_workunitservices.WorkUnitServices.WorkunitMessages(wuid);

/*
Expand Down
34 changes: 31 additions & 3 deletions plugins/workunitservices/workunitservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,19 @@ static const char * EclDefinition =
" unsigned4 col;"
" string16 source;"
" string20 time;"
" string message{maxlength(1024)};"
" string message{maxlength(1024)};"
" end;\n"
"export WsMessage_v2 := record "
" unsigned4 severity;"
" integer4 code;"
" string32 location;"
" unsigned4 row;"
" unsigned4 col;"
" string16 source;"
" string20 time;"
" unsigned4 priority;"
" real8 cost;"
" string message{maxlength(1024)};"
" end;\n"
"export WsFileRead := record "
" string name{maxlength(256)};"
Expand Down Expand Up @@ -143,7 +155,7 @@ static const char * EclDefinition =
" varstring WUIDonDate(unsigned4 year,unsigned4 month,unsigned4 day,unsigned4 hour, unsigned4 minute) : entrypoint='wsWUIDonDate'; \n"
" varstring WUIDdaysAgo(unsigned4 daysago) : entrypoint='wsWUIDdaysAgo'; \n"
" dataset(WsTimeStamp) WorkunitTimeStamps(const varstring wuid) : context,entrypoint='wsWorkunitTimeStamps'; \n"
" dataset(WsMessage) WorkunitMessages(const varstring wuid) : context,entrypoint='wsWorkunitMessages'; \n"
" dataset(WsMessage_v2) WorkunitMessages(const varstring wuid) : context,entrypoint='wsWorkunitMessages_v2'; \n"
" dataset(WsFileRead) WorkunitFilesRead(const varstring wuid) : context,entrypoint='wsWorkunitFilesRead'; \n"
" dataset(WsFileWritten) WorkunitFilesWritten(const varstring wuid) : context,entrypoint='wsWorkunitFilesWritten'; \n"
" dataset(WsTiming) WorkunitTimings(const varstring wuid) : context,entrypoint='wsWorkunitTimings'; \n"
Expand Down Expand Up @@ -578,7 +590,7 @@ WORKUNITSERVICES_API void wsWorkunitTimeStamps(ICodeContext *ctx, size32_t & __l
__result = mb.detach();
}

WORKUNITSERVICES_API void wsWorkunitMessages( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid )
void wsWorkunitMessagesImpl( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid, bool returnCosts)
{
Owned<IConstWorkUnit> wu = getWorkunit(ctx, wuid);
MemoryBuffer mb;
Expand All @@ -599,6 +611,11 @@ WORKUNITSERVICES_API void wsWorkunitMessages( ICodeContext *ctx, size32_t & __le
fixedAppend(mb, 16, s.str(), s.length());
e.getTimeStamp(s);
fixedAppend(mb, 20, s.str(), s.length());
if (returnCosts)
{
mb.append((unsigned) e.getPriority());
mb.append((double) e.getCost());
}
e.getExceptionMessage(s);
varAppendMax(mb, 1024, s.str(), s.length());
}
Expand All @@ -607,6 +624,17 @@ WORKUNITSERVICES_API void wsWorkunitMessages( ICodeContext *ctx, size32_t & __le
__result = mb.detach();
}


WORKUNITSERVICES_API void wsWorkunitMessages( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid)
{
wsWorkunitMessagesImpl(ctx, __lenResult, __result, wuid, false);
}

WORKUNITSERVICES_API void wsWorkunitMessages_v2( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid)
{
wsWorkunitMessagesImpl(ctx, __lenResult, __result, wuid, true);
}

WORKUNITSERVICES_API void wsWorkunitFilesRead( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid )
{
MemoryBuffer mb;
Expand Down
3 changes: 2 additions & 1 deletion plugins/workunitservices/workunitservices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitList( ICodeContext *ct
WORKUNITSERVICES_API char * wsWUIDonDate(unsigned year,unsigned month,unsigned day,unsigned hour,unsigned minute);
WORKUNITSERVICES_API char * wsWUIDdaysAgo(unsigned daysago);
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitTimeStamps( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid );
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitMessages( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid );
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitMessages( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid);
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitMessages_v2( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid);
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitFilesRead( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid );
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitFilesWritten( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid );
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitTimings( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid );
Expand Down
Loading