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 » MOVE NEXTSIBLING vs CARDINALITY and [i] call in a loop

Post new topic  Reply to topic
 MOVE NEXTSIBLING vs CARDINALITY and [i] call in a loop « View previous topic :: View next topic » 
Author Message
Bartez75
PostPosted: Mon Jun 08, 2009 4:04 am    Post subject: MOVE NEXTSIBLING vs CARDINALITY and [i] call in a loop Reply with quote

Voyager

Joined: 26 Oct 2006
Posts: 80
Location: Poland, Wroclaw

Hi
Could anybody tell me what is better to use when looping through message. In my case input message is MRM/XML. Output is MRM/TDS.

There is let say 1000 of Order element in Data.

I can do a loop like that:

Code:

DECLARE i INTEGER 1;
DECLARE refOrder REFERENCE TO InputRoot.MRM.ns:Data.ns:Order[1];
WHILE LASTMOVE(refOrder) DO
   SET OutputRoot.MRM.Order[i].NMCIL=refOrderCIL.id;
   SET OutputRoot.MRM.Order[i].NUBSL=refOrderCIL.ns:Row.slRow;
   MOVE refOrder NEXTSIBLING NAMESPACE * NAME 'Order';               
   SET i=i+1;            
END WHILE;


or I can do it like that:

Code:

DECLARE i INTEGER 1;
DECLARE orderCardinality INTEGER CARDINALITY(InputRoot.MRM.ns:Data.ns:Order[]);
WHILE i <= orderCardinality DO
   SET OutputRoot.MRM.Order[i].NMCIL=InputRoot.MRM.ns:Data.ns:Order[i].id;
   SET OutputRoot.MRM.Order[i].NUBSL=InputRoot.MRM.ns:Data.ns:Order[i].ns:Row.sRow;
   SET i = i + 1;
END WHILE;


There are more fields to map. I just put these 2 to make this example simple.

From my tests the first one (with MOVE NEXTSIBLING) is faster but maybe my test was wrong. Is MOVE NEXTSIBLING a better way of doing it?
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jun 08, 2009 4:12 am    Post subject: Re: MOVE NEXTSIBLING vs CARDINALITY and [i] call in a loop Reply with quote

Grand High Poobah

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

Bartez75 wrote:
Is MOVE NEXTSIBLING a better way of doing it?


I would expect this to be the faster method, but that's based on my (possibly flawed) understanding of how the tree would be navigated.

I'm sure someone with a more authoritative view will be along in a minute.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Jun 08, 2009 4:22 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

It should be long established that using references to navigate trees is better performing.

In order to find the [n+1]'th entry when using indices, Broker must navigate to [1], [2], [3],....[n] and then to [n+1].

When using a reference, it just accesses the relevant pointer stored in the node datastructure.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jun 08, 2009 4:44 am    Post subject: Reply with quote

Grand High Poobah

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

mqjeff wrote:
In order to find the [n+1]'th entry when using indices, Broker must navigate to [1], [2], [3],....[n] and then to [n+1].

When using a reference, it just accesses the relevant pointer stored in the node datastructure.


I'm relieved my understanding is not as flawed as I feared.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Bartez75
PostPosted: Tue Jun 09, 2009 3:16 am    Post subject: Reply with quote

Voyager

Joined: 26 Oct 2006
Posts: 80
Location: Poland, Wroclaw

Thanks for you answer.
I will be closer with references after your explanation
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 » MOVE NEXTSIBLING vs CARDINALITY and [i] call in a loop
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.