ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » REFERENCE Instead of Index

Post new topic  Reply to topic
 REFERENCE Instead of Index « View previous topic :: View next topic » 
Author Message
sandman147
PostPosted: Mon Feb 24, 2014 8:55 am    Post subject: REFERENCE Instead of Index Reply with quote

Apprentice

Joined: 01 Sep 2013
Posts: 42

Example
--------------------------------------------------------------------------
WHILE (iLoopCount<=iRecordCount) DO

SET OutputRoot.MRM.Result[iLoopCount].Data1 = InputRoot.MRM.Object[iLoopCount].Element1;

SET OutputRoot.MRM.Result[iLoopCount].Data2 = InputRoot.MRM.Object[iLoopCount].Element2;

SET OutputRoot.MRM.Result[iLoopCount].Data3 = InputRoot.MRM.Object[iLoopCount].Element3;

SET iLoopCount = iLoopCount + 1;
END WHILE;
---------------------------------------------------------------------------

How can the above be implemented with the help of REFERENCE pointers ?
Back to top
View user's profile Send private message
sandman147
PostPosted: Mon Feb 24, 2014 9:22 am    Post subject: Reply with quote

Apprentice

Joined: 01 Sep 2013
Posts: 42

Does the Implementation go something like this;
--------------------------------------------------------------------------
DECLARE RefIn REFERENCE TO InputRoot.MRM.Object;

WHILE LASTMOVE(RefIn) DO

SET OutputRoot.MRM.Result[iLoopCount].Data1 = RefIn.Element1;
SET OutputRoot.MRM.Result[iLoopCount].Data2 = RefIn.Element2;
SET OutputRoot.MRM.Result[iLoopCount].Data3 = RefIn.Element3;

MOVE RefIn NEXTSIBLING NAME 'Object';

SET iLoopCount = iLoopCount + 1;
END WHILE;
----------------------------------------------------------------------------
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Feb 24, 2014 9:22 am    Post subject: Re: REFERENCE Instead of Index Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

sandman147 wrote:
How can the above be implemented with the help of REFERENCE pointers ?


CREATE LASTCHILD
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Feb 24, 2014 9:23 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

sandman147 wrote:
Does the Implementation go something like this;
--------------------------------------------------------------------------
DECLARE RefIn REFERENCE TO InputRoot.MRM.Object;

WHILE LASTMOVE(RefIn) DO

SET OutputRoot.MRM.Result[iLoopCount].Data1 = RefIn.Element1;
SET OutputRoot.MRM.Result[iLoopCount].Data2 = RefIn.Element2;
SET OutputRoot.MRM.Result[iLoopCount].Data3 = RefIn.Element3;

MOVE RefIn NEXTSIBLING NAME 'Object';

SET iLoopCount = iLoopCount + 1;
END WHILE;
----------------------------------------------------------------------------



_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Gralgrathor
PostPosted: Mon Feb 24, 2014 10:49 am    Post subject: Reply with quote

Master

Joined: 23 Jul 2009
Posts: 297

I'd use FOR in stead of a WHILE loop, though. It seems to be somewhat faster than WHILE/MOVE.
_________________
A measure of wheat for a penny, and three measures of barley for a penny; and see thou hurt not the oil and the wine.
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Mon Feb 24, 2014 10:51 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Gralgrathor wrote:
I'd use FOR in stead of a WHILE loop, though. It seems to be somewhat faster than WHILE/MOVE.


In the specific case posted, I'd be inclined to do the same but for reasons of code clarity & simplicity. Not noticed the performance improvement you claim (which in no way reflectes on the existence or not of said performance improvement of course).
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Gralgrathor
PostPosted: Mon Feb 24, 2014 11:24 am    Post subject: Reply with quote

Master

Joined: 23 Jul 2009
Posts: 297

Vitor wrote:
Not noticed the performance improvement you claim (which in no way reflectes on the existence or not of said performance improvement of course).


You're right, I checked: the increase in performance in the code I rewrote likely resulted from replacing Array[Index].Field with RowRef.Field, not the loop structure per se.
_________________
A measure of wheat for a penny, and three measures of barley for a penny; and see thou hurt not the oil and the wine.
Back to top
View user's profile Send private message Send e-mail
sandman147
PostPosted: Mon Feb 24, 2014 12:24 pm    Post subject: Reply with quote

Apprentice

Joined: 01 Sep 2013
Posts: 42

How about this
---------------------------------------------------------------------------
CREATE LASTCHILD OF OutputRoot DOMAIN 'MRM';
CREATE LASTCHILD OF OutputRoot.MRM NAME 'Result';
DECLARE RefOut REFERENCE TO OutputRoot.MRM.Result;

DECLARE RefIn REFERENCE TO InputRoot.MRM.Object;

WHILE LASTMOVE(RefIn) DO

SET RefOut.Data1 = RefIn.Element1;
SET RefOut.Data2 = RefIn.Element2;
SET RefOut.Data3 = RefIn.Element3;

CREATE NEXTSIBLING OF RefOut AS RefOut REPEAT;

MOVE RefIn NEXTSIBLING NAME 'Object';

END WHILE;
------------------------------------------------------------------------------
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Feb 24, 2014 1:13 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

sandman147 wrote:
How about this
---------------------------------------------------------------------------
CREATE LASTCHILD OF OutputRoot DOMAIN 'MRM';
CREATE LASTCHILD OF OutputRoot.MRM NAME 'Result';
DECLARE RefOut REFERENCE TO OutputRoot.MRM.Result;

DECLARE RefIn REFERENCE TO InputRoot.MRM.Object;

WHILE LASTMOVE(RefIn) DO

SET RefOut.Data1 = RefIn.Element1;
SET RefOut.Data2 = RefIn.Element2;
SET RefOut.Data3 = RefIn.Element3;

CREATE NEXTSIBLING OF RefOut AS RefOut REPEAT;

MOVE RefIn NEXTSIBLING NAME 'Object';

END WHILE;
------------------------------------------------------------------------------


Does it work when you test it?

As I indicated above, I'd use CREATE LASTCHILD rather than CREATE NEXTSIBLING but at first glance I'd say they were functionally equivalent to your solution.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
sandman147
PostPosted: Mon Feb 24, 2014 1:27 pm    Post subject: Reply with quote

Apprentice

Joined: 01 Sep 2013
Posts: 42

It works. I will implement these pointers which improve performance from this point forward. Thanks for all the help.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Feb 24, 2014 1:33 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Gralgrathor wrote:
You're right, I checked: the increase in performance in the code I rewrote likely resulted from replacing Array[Index].Field with RowRef.Field, not the loop structure per se.


Most likely. People are often surprised by how much this kind of index addressing costs.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Tue Feb 25, 2014 12:39 am    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

sandman147 wrote:
How about this
---------------------------------------------------------------------------
CREATE LASTCHILD OF OutputRoot DOMAIN 'MRM';
CREATE LASTCHILD OF OutputRoot.MRM NAME 'Result';
DECLARE RefOut REFERENCE TO OutputRoot.MRM.Result;

DECLARE RefIn REFERENCE TO InputRoot.MRM.Object;

WHILE LASTMOVE(RefIn) DO

SET RefOut.Data1 = RefIn.Element1;
SET RefOut.Data2 = RefIn.Element2;
SET RefOut.Data3 = RefIn.Element3;

CREATE NEXTSIBLING OF RefOut AS RefOut REPEAT;

MOVE RefIn NEXTSIBLING NAME 'Object';

END WHILE;

That looks so good.

It is a bit verbose at the beginning to get your references (on the InputRoot and OutputRoot) in place (as can be seen here). At the end you move the input one and create an output one (if required ), good!

Don't hesitate to introduce more references on the part(s) that you need (again) later. And again, all this happens on the Input- and Output-Root!

And Vitor is right, the thing is... WHAT IF your resulting list is empty... you don't have to use CREATE LASTCHILD within the loop, but AT LEAST you need to add code that handles this (case). E.g. you may do it on the line where you "CREATE LASTCHILD OF OutputRoot.MRM NAME 'Result'. Put in a test on the InputRoot WHETHER a MOVE FIRSTCHILD works (yes: not empty, no: empty) and only create a FIRST OutChild, if not empty !
_________________
Just use REFERENCEs


Last edited by mqsiuser on Tue Feb 25, 2014 5:34 am; edited 3 times in total
Back to top
View user's profile Send private message
Esa
PostPosted: Tue Feb 25, 2014 12:50 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

But if you used CREATE LASTCHILD as suggested by Vitor you wouldn't need to remove the last, empty Result element afterwards...
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Tue Feb 25, 2014 12:54 am    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

Esa wrote:
But if you used CREATE LASTCHILD as suggested by Vitor you wouldn't need to remove the last, empty Result element afterwards...


yes, you need to improve on that code (especially on the creation of your out element(s)!)

Either you will see a SUPRISE (in production) OR you intensly think about your EDGE cases (no element, what is about the last element)
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » REFERENCE Instead of Index
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.