Message 96

Sort Merge

X-Added: With Flames (bblib $Revision: 1.4 $)
Return-path: <cynews+@port.fac.cs.cmu.edu>
X-Andrew-Authenticated-as: 0;andrew.cmu.edu;Network-Mail
Received: from po0.andrew.cmu.edu via trymail for bb+academic.cs.15-721@andrew.cmu.edu
          ID </afs/andrew.cmu.edu/usr0/bb/Mailbox/cvp4aMm00UdY4N2k5L>;
          Mon, 22 Oct 2001 12:30:16 -0400 (EDT)
Received: from mx3.andrew.cmu.edu (MX3.ANDREW.CMU.EDU [128.2.10.113])
        by po0.andrew.cmu.edu (8.9.3/8.9.3) with ESMTP id MAA06407
        for <bb+academic.cs.15-721@ams.andrew.cmu.edu>; Mon, 22 Oct 2001 12:30:16 -0400 (EDT)
Received: from port.fac.cs.cmu.edu (PORT.FAC.CS.CMU.EDU [128.2.209.118])
        by mx3.andrew.cmu.edu (8.12.0.Beta16/8.12.0.Beta16) with SMTP id f9MGUEbT006547
        for <post+academic.cs.15-721@andrew.cmu.edu>; Mon, 22 Oct 2001 12:30:15 -0400
Received: from GS188.SP.CS.CMU.EDU ([128.2.203.205]) via cynntpd
        by port.fac.cs.cmu.edu; Mon, 22 Oct 01 12:29:34 EDT
From: Flavio Lerda <flerda@gs188.sp.cs.cmu.edu>
Subject: Sort Merge
Date: Mon, 22 Oct 2001 12:29:34 -0400
Path: not-for-mail
Message-ID: <20011022.122934.630668850.31003@gs188.sp.cs.cmu.edu>
User-Agent: Pan/0.9.7 (Unix)
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
To: "cyrus.academic.cs.15-721" <post+academic.cs.15-721@andrew.cmu.edu>
Sender: cynews+@port.fac.cs.cmu.edu

Hi,
  I have a question about the output of the sort merge example. The
"official" solution outputs the number twice, while my solution outputs
them only once. Is that okay? The problem seems to be that when a record
is created, the output of the key (a number) mistakenly overwrites part
of the filling (basically the null terminator of the first field goes
over the second field). When the join is done the tuple are concatenated
by my code with two memcpy so the layout is something like:

key1 fill1 key2 fill2

so the print out only prints key1 (remember that fill1 -- and fill2 --
starts with a null character).

However the code provided for the solution seems to do the following:

key1 key2 fill1 kill2

so it actually prints both keys (before reaching the null character in
fill1).

I ust would like to know if that's the case and if I should change my
code (it's not such a big change in the code but it looks useless except
for obtaining the same results of the solution).

thanks
-Flavio Lerda

PS: Instrumenting the code of SMTester.C I get the following for my
program:

------------ Test 1 ---------------
   1 [ 32 32 32 49 0 32 32 32 32 32 32 49 0 32 32 32 ]
   1 [ 32 32 32 49 0 32 32 32 32 32 32 49 0 32 32 32 ]
   1 [ 32 32 32 49 0 32 32 32 32 32 32 49 0 32 32 32 ]
   1 [ 32 32 32 49 0 32 32 32 32 32 32 49 0 32 32 32 ]
   6 [ 32 32 32 54 0 32 32 32 32 32 32 54 0 32 32 32 ]
   6 [ 32 32 32 54 0 32 32 32 32 32 32 54 0 32 32 32 ]
  13 [ 32 32 49 51 0 32 32 32 32 32 49 51 0 32 32 32 ]
  13 [ 32 32 49 51 0 32 32 32 32 32 49 51 0 32 32 32 ]
  99 [ 32 32 57 57 0 32 32 32 32 32 57 57 0 32 32 32 ]
-------- Test 1 completed --------

and 

------------ Test 1 ---------------
   1   1 [ 32 32 32 49 32 32 32 49 0 63 6 8 2 0 0 0 
   1   1 [ 32 32 32 49 32 32 32 49 0 63 6 8 2 0 0 0 
   1   1 [ 32 32 32 49 32 32 32 49 0 63 6 8 2 0 0 0 
   1   1 [ 32 32 32 49 32 32 32 49 0 63 6 8 2 0 0 0 
   6   6 [ 32 32 32 54 32 32 32 54 0 63 6 8 2 0 0 0 
   6   6 [ 32 32 32 54 32 32 32 54 0 63 6 8 2 0 0 0 
  13  13 [ 32 32 49 51 32 32 49 51 0 63 6 8 2 0 0 0 
  13  13 [ 32 32 49 51 32 32 49 51 0 63 6 8 2 0 0 0 
  99  99 [ 32 32 57 57 32 32 57 57 0 63 6 8 2 0 0 0 
-------- Test 1 completed --------

for the solution.

What follows the normal output is a dump of the bytes in the record.

It seems that the join actually doesn't join the fill1 and fill2 fields
but just the keys!