Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Sun Dec 12, 2004 2:43 am Post subject: Sort Challenge II - Horizontal Sorting.
Hi all.
Here is one more sort Challenge. As usual the solution could be in any sort product (Dfsort / Syncsort / CA Sort). The solution will be published on Tuesday (12/14/04).
I have a input file which is sorted on the Key (first 3 characters).
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sun Dec 12, 2004 11:47 am Post subject:
Phantom,
This same question was posted in the yahoo group the other day and I answered it with a DFSORT/ICETOOL solution. Coincidence?
Anyway, I'll play along and send you my DFSORT/ICETOOL solution via private message.
BTW, the input record for DDD is:
DDD ZYS
so the output record for DDD should be:
DDD SYZ
instead of:
DDD XYZ
as you show. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sun Dec 12, 2004 1:36 pm Post subject:
I also just remembered that there was a similar question on other board the other day that I responded to with a DFSORT/ICETOOL solution as well. I guess this is more of a "real" question than merely a made-up challenge. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Sun Dec 12, 2004 11:12 pm Post subject:
Frank,
Quote:
This same question was posted in the mvsquest yahoo group.
Interesting....I'm registered only in MVSFORUMS. Actually my colleague asked me this question. He said he need to do this horizontal sorting for one of his projects request. I'm not sure whether he is registered in the other group.
Anyway, it was nice to see your message. If I'm correct, Its been quite some time since you posted one. Thanks a lot.
I will get back with all the solutions either on Tuesday / Wednesday, depending on the response.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Dec 13, 2004 10:22 am Post subject:
Hmmm ... maybe all of these guys have the same project. Quite possible. I see that a lot on some of the boards (5 guys will all ask the same question in one day).
Quote:
Anyway, it was nice to see your message. If I'm correct, Its been quite some time since you posted one.
Well, I don't post as often on this board as I do on the other 3 boards I participate in, since Kolusu usually handles all the questions I would answer here before I get to work in California. But I have posted reasonably frequently here.
I don't usually post to the Mainframe Challenge topic. It's a good idea. But with all of the "real" questions I get on the other boards and through direct e-mail, I tend to pass on "made-up" questions. I only sent you an answer for this one because I already had the answer. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Wed Dec 15, 2004 6:00 am Post subject:
Hi All,
Its time to release the solutions.
Solution 1: From Frank.
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
AAA OAO
BBB WSS
CCC OWD
DDD ZYS
EEE FGH
FFF ZYS
GGG HKJ
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
* IN->T1: Split each input record that looks like this
* (cba represents random order):
* kkk cba
* into three output records that look like this:
* kkk ccc
* kkk bbb
* kkk aaa
COPY FROM(IN) USING(CTL1)
* Sort by kkk and the first character of cba to get the
* records in the correct order (represented by abc). Then
* join the three records back into one record of the form:
* kkk abc
SPLICE FROM(T1) TO(OUT) ON(1,3,CH) -
WITHEACH WITH(8,1) WITH(9,1) USING(CTL2)
/*
//CTL1CNTL DD *
* Split each record into three records.
OUTFIL FNAMES=T1,
OUTREC=(1,3,7:7,1,7,1,7,1,80:X,/,
1,3,7:8,1,8,1,8,1,/,
1,3,7:9,1,9,1,9,1)
/*
//CTL2CNTL DD *
* Sort by kkk and the first character of cba.
OPTION EQUALS
SORT FIELDS=(1,3,CH,A,7,1,CH,A)
/*
Comments:
This solutions requires 1 Step 1 Temp file & 2 Pass. A Simple, Generic & Efficient Solution
Comments:
Basically same as the first Solution 1 (A Syncsort Version). The only constraint here is you need a latest version of SYNCSORT to work with SPLICE.
Comments:
The Traditional way !!! - w/o SPLICE. This solution requires 1 Step 2 Temp Files & 3 Passes. A simple, Generic & very efficient solution.
Solution 4: From Me (Phantom)
Comments:
Simplest of All. Requires Just 1 Step & 1 Pass. 8) But the only drawback of this is that it is not GENERIC. It won't work if the no. of characters is more than 3. But that wasn't part of challenge though.
Any Comments/Suggestions are Welcome !
If any of you have a different solution please feel free to post.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Dec 17, 2004 1:18 pm Post subject:
Quote:
If any of you have a different solution please feel free to post.
I had this one up my sleeve the whole time, but I couldn't post it until today when the new DFSORT PTFs were available.
Below is a DFSORT solution with one copy pass and only one INREC statement. It uses the new IFTHEN feature available with z/OS DFSORT V1R5 PTF UQ95214 and DFSORT R14 PTF UQ95213.
I ran a performance test with DFSORT of this IFTHEN method vs Phantom's MIN/MAX method using 5 million records and the IFTHEN method ran 3.5 times faster (CPU time).
You could extend this solution to more than 3 characters by coding up the appropriate IFTHEN statements, although the more characters you do the more IFTHEN statements you would need and the more complex it would become to figure out what they were. I think extendability is the main virtue of the SPLICE solution I offered, although it's obviously nowhere near as efficient as this one pass solution with IFTHEN. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Sat Dec 18, 2004 12:01 am Post subject:
Frank,
Code:
I ran a performance test with DFSORT of this IFTHEN method vs Phantom's MIN/MAX method using 5 million records and the IFTHEN method ran 3.5 times faster (CPU time).
You are toooo Bad.....Now you make me Cry
I wanna explore the features of DFSORT !!!!!!!!!!!!!!!..........
Frank, Could you pls forward my CV to ur HR ...Probably I'll join ur team....
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sat Dec 18, 2004 11:33 am Post subject:
Phantom,
Don't cry - convince your management to switch! I'd be glad to send you some documents that might help you convince them if you e-mail me (yaeger@us.ibm.com). _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
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