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 » Sorting and Removing Duplicates

Post new topic  Reply to topic Goto page 1, 2  Next
 Sorting and Removing Duplicates « View previous topic :: View next topic » 
Author Message
siva1431202
PostPosted: Wed May 04, 2011 3:15 am    Post subject: Sorting and Removing Duplicates Reply with quote

Novice

Joined: 04 May 2011
Posts: 20

If i have some data and i am using in aggregate flow. I am combining two replies coming from two systems.

1)Now I have to sort the data
2)Remove the duplicates

I want to do this using the following Languages

1)ESQL
2)PHP
3)ESQL
4)JAVA.

If any one have some idea please reply me with the logic
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed May 04, 2011 3:54 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

There is an old post around here somewhere that has an ESQL implementation of the quicksort algorithm.

There should be similar that you can find on the internet for PHP or otherwise is part of the PHP language.

then the question of removing duplicates is just a question of seeing if the next element is the same as the current element.

Or you could stick the data into a database and ask the database to sort and remove duplicates for you.

Happy Searching!
Back to top
View user's profile Send private message
siva1431202
PostPosted: Wed May 04, 2011 4:32 am    Post subject: Reply with quote

Novice

Joined: 04 May 2011
Posts: 20

ok...Thank you. But where as here we are not using Database. So can u suggest someother thing to remove duplicates.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed May 04, 2011 4:34 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

I already suggested something to remove duplicates.

Check to see if the next item is the same as the current item, if it is, delete one.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed May 04, 2011 5:11 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

A quick google for 'quicksort'

http://en.wikipedia.org/wiki/Quicksort

Then even better

http://www.javakb.com/Uwe/Forum.aspx/java-programmer/35337/Sorting-and-removing-duplicates

This sort of thing was one of the very early programming tasks I undertook when I was a student Mechanical Engineer in the 1970's.

There are many more examples in these tomes.
http://en.wikipedia.org/wiki/The_Art_of_Computer_Programming. Essential bedtime reading for every aspiring programmer.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
siva1431202
PostPosted: Wed May 04, 2011 6:21 am    Post subject: Reply with quote

Novice

Joined: 04 May 2011
Posts: 20

Ok. THank You. I am trying on the code which you had given.

Because i have to do it using java compute node and Php compute node.

so i am trying to build the logic and syntax based on those examples.
Back to top
View user's profile Send private message
khudania
PostPosted: Wed May 04, 2011 6:39 am    Post subject: Reply with quote

Apprentice

Joined: 30 Nov 2004
Posts: 43

I found this on this forum, this in case you stil want to code in esql.

http://www.mqseries.net/phpBB2/viewtopic.php?t=53074&highlight=
_________________
If the doors of perception were cleansed, everything would appear as it is - infinite
Back to top
View user's profile Send private message
siva1431202
PostPosted: Wed May 04, 2011 7:00 am    Post subject: Reply with quote

Novice

Joined: 04 May 2011
Posts: 20

I had already seen that code and i want to try in java and PHP.

I have the code for sorting array but i want to sort the tree structure in java and PHP.
Back to top
View user's profile Send private message
khudania
PostPosted: Wed May 04, 2011 7:09 am    Post subject: Reply with quote

Apprentice

Joined: 30 Nov 2004
Posts: 43

siva1431202 wrote:
I had already seen that code and i want to try in java and PHP.

I have the code for sorting array but i want to sort the tree structure in java and PHP.


java would be really simple.
Quote:

import java.util.*;
ArrayList arrayList = new ArrayList();
arrayList.add("ACB");
arrayList.add("ABE");
arrayList.add("ABC");
arrayList.add("AB1");

Collections.sort(arrayList);

The resultant arrayList is sorted one.
_________________
If the doors of perception were cleansed, everything would appear as it is - infinite
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 04, 2011 7:11 am    Post subject: Reply with quote

Grand High Poobah

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

khudania wrote:
siva1431202 wrote:
I had already seen that code and i want to try in java and PHP.

I have the code for sorting array but i want to sort the tree structure in java and PHP.


java would be really simple.
Quote:

import java.util.*;
ArrayList arrayList = new ArrayList();
arrayList.add("ACB");
arrayList.add("ABE");
arrayList.add("ABC");
arrayList.add("AB1");

Collections.sort(arrayList);

The resultant arrayList is sorted one.


And how would you apply this to a message tree, as the OP has indicated is the requirement?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed May 04, 2011 7:11 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

khudania wrote:
siva1431202 wrote:
I had already seen that code and i want to try in java and PHP.

I have the code for sorting array but i want to sort the tree structure in java and PHP.


java would be really simple.
Quote:

import java.util.*;
ArrayList arrayList = new ArrayList();
arrayList.add("ACB");
arrayList.add("ABE");
arrayList.add("ABC");
arrayList.add("AB1");

Collections.sort(arrayList);

The resultant arrayList is sorted one.

Oddly enough, the Java Collections interface doesn't provide a version of sort() that accepts an MbElement or MbMessage object...
Back to top
View user's profile Send private message
khudania
PostPosted: Wed May 04, 2011 7:20 am    Post subject: Re: Sorting and Removing Duplicates Reply with quote

Apprentice

Joined: 30 Nov 2004
Posts: 43

siva1431202 wrote:
If i have some data and i am using in aggregate flow. I am combining two replies coming from two systems.

1)Now I have to sort the data

If any one have some idea please reply me with the logic


Siva wants to sort just the data and he has to at least create a java collection object of the that data, sorting part is handled by the sort function.

for eg.

Quote:
arrayList.add("ACB");


ie an array, or any other descendant of collection class.
_________________
If the doors of perception were cleansed, everything would appear as it is - infinite
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 04, 2011 7:25 am    Post subject: Re: Sorting and Removing Duplicates Reply with quote

Grand High Poobah

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

khudania wrote:
Siva wants to sort just the data and he has to at least create a java collection object of the that data, sorting part is handled by the sort function.


So your solution (if I grasp it correctly) is to unload the message tree into a collection object and sort that?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
siva1431202
PostPosted: Wed May 04, 2011 7:29 am    Post subject: Reply with quote

Novice

Joined: 04 May 2011
Posts: 20

So your solution (if I grasp it correctly) is to unload the message tree into a collection object and sort that?


Yes you are right and i have to do it using PHP and JAVA compute nodes.
Back to top
View user's profile Send private message
khudania
PostPosted: Wed May 04, 2011 7:33 am    Post subject: Reply with quote

Apprentice

Joined: 30 Nov 2004
Posts: 43

From what I understand, Siva wants to sort the data(some list) and not the entire message tree and if my understanding is right, this is how the values can be sorted in java.

Siva, for filtering duplicates, use HashSet instead of ArrayList and then add , only the uniques will be added.

Code:

 Set hashSet = new HashSet(); 
 hashSet.add('ABC');
 hashSet.add('ABD');


//and then

arrayList = new ArrayList(hashSet );
Collections.sort(arrayList);

 

_________________
If the doors of perception were cleansed, everything would appear as it is - infinite
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Sorting and Removing Duplicates
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.