On 2/6/2014 4:23 AM, Frederic Da Vitoria wrote:
Then my trick does not work for you because it hides the fact that the records
are identical.

actually, the problem comes when referencing the IndexOf() the record... IndexOf(Item) is passed (unmodified) thru a couple of routines to finally end up here as 'idx'... IndexOf() being the TSortedCollection IndexOf() routine...

Procedure LogTLEPerApo(tleRecord: PTLERec; idx: sw_integer; var oFile: text);

begin
  WriteLogLine(AppLogFile,0,
             PadLeft(IntToStr(idx),5)
    + '  ' + PadRight(tleRecord^.catnbr^,5)
    + '  ' + PadRight(tleRecord^.cospar^,8)
    + '  ' + PadRight(tleRecord^.satname^,27)
+ ' ' + PadRight(AddChar('0',FloatToStrF(tleRecord^.epoch,ffFixed,15,8),14),15)
           + PadRight(displayEpochString(tleRecord^.epoch),19)
    + '  ' + PadLeft(FloatToStrF(tleRecord^.Perigee,ffFixed,15,8),16)
    + ' x ' + PadLeft(FloatToStrF(tleRecord^.Apogee,ffFixed,15,8),16)
    + ' x ' + PadLeft(FloatToStrF(tleRecord^.Inclination,ffFixed,15,8),16)
    + '  ' + PadLeft(FloatToStrF(tleRecord^.SMajAxisKM,ffFixed,15,8),16)
    + '  ' + PadLeft(FloatToStrF(tleRecord^.MMPeriod,ffFixed,15,8),16)
    + '  ' + PadLeft(FloatToStrF(tleRecord^.SMAPeriodC,ffFixed,15,8),16)
    + '  ' + PadLeft(FloatToStrF(tleRecord^.SMAPeriodP,ffFixed,15,8),16)
  );
  WriteOUTFile(tleRecord,oFile);
  inc(tot_TLEs_written);
end;


You need to give to someone the responsibility of giving the secondary key.

that's not going to happen... anyone can generate these records and make them available to others for use... i'm aware of at least 5 different groups and several owners of the objects who are generating these...

If I understand what you wrote correctly, there is already
something which could be used as a tertiary key, but it doesn't really work
because the way it is filled is not consistent across the different sources.

right... for the same reason as above...

If I were you, I'd keep this tertiary key data (I guess it is meaningful, so
you can't remove it),

right... it is part of the format... some records don't even have this tertiary key filled in...

and I'd create my own secondary key inside the TSortedCollection descendant.

hummm... one group does something similar but i currently don't have any method of doing this... in all actuality i should probably be doing this in a sql database but the overhead of processing speed and storage space is more than i want to deal with... especially since a full processing run using all options takes less than a minute for ~40000 records and a previous tool (limited to 64k) takes almost 30 minutes...

I'd use 2 compare functions,
  - one which works as your current one but wouldn't be declared as a compare
function (you could call it CheckPrimaryExists) and which would return 0 if the
primary key already exists
  - and one which uses both the primary and the secondary key as Jim suggested.

The algo (when duplicates are allowed) would be something like:
if primary key exists
     then set secondary key to a number
insert the data

definitely something for me to contemplate on...

Note that depending on the total number of rows, you could use a general counter
for the secondary key, no need to fetch the value of the last secondary key for
the same primary key.

You'd get something like (primary key / secondary key)
A / 0
B / 0
B / 1 (duplicate detected, first secondary key generated)
C / 0
C / 2 (duplicate detected, second secondary key generated, note that there is 
no C1)
...

... and now that I think of it, you don't need 2 compare functions, the second
one should work for both usages.

this is one of the things i like about talking about problems... while others may not be fully aware of the data, they can still come up with ideas on how to handle situations... one of the things i used to do was to talk to a mechanic friend... i'd convert my tasks and problems to something vehicle related so that he could see it from his mechanic's point of view and then he'd ask about doing it like "this" in vehical mechanic terms which i'd convert back to programming and suddenly have a workable solution... he helped me solve more problems in this way than i can count and he barely knew where the "big red switch" was on the computers ;) ;) ;)


--
NOTE: No off-list assistance is given without prior approval.
      Please keep mailing list traffic on the list unless
      private contact is specifically requested and granted.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to