Article View: news.software.nntp
Article #64510Re: Newsreader programming - sorting one million lines ?
From: Heiko Studt
Date: Mon, 24 Mar 2003 18:54
Date: Mon, 24 Mar 2003 18:54
97 lines
3947 bytes
3947 bytes
Juergen Helbing did nothing on 24.03.2003 13:40:45:
> Sorting header lists by date, subject line and/or from is necessary
> (and sorting by subject is also needed for joining multiparts).
You want to sort *one* thing at a time, right, and only with same values you
want to sort again!?
> I'm still keeping the 150.000 msgs in memory (approx. 30-70 MB)
Then you save *everything*.
Use something like an database:
You save every XOver(?)-Line in one line in a "Direktzugriffs"-file.
(In a kind of form you like)
Now you save a pointer to the beginning of the line in a
fixed-width-record-file.
Now you load 10 chars from all subjects to memory and save the index of it.
Therefor you can use a sorted stringlist. (AFAIK sorting by including is
fastest, isn't it?). After all you have a pre-sorted list where you have to
resort all "similar" things with full-width subject, date and so on.
This is a smaller solution in Delphi:
pInt = ^int64;
temI : pInt;
f : tFileStream64;
i : int64;
tsl : tStringList;
begin
f := tFileStream.Create('TempDatabase.tmp');
tsl := tStringList.create;
try
f.position := 0;
tsl.sorted := true;
i := 0;
while not StreamEof(XOverStream) do begin
s := GetLine(XOverStream);
new(temI);
temI := i;
tsl.AddObject(GetSortingItems(s), tObject(temI));
f.write(s);
i := f.position;
end;
//And here you have a sorted tsl with pointers in tsl.Objects.
//The rest you can do yourself. ;-P
finally
tsl.free
f.free;
end;
> where sorting is easy - even if it is not too fast with quicksort or
> heapsort.
> A first test-run with 500.000 msgs shows me that sorting them
> takes up to one minute - and if there is not enough memory in the
> computer and swapping begins then sorting takes forever.
>
> I'm not yet keeping sorting indices for subject, date, author,
> msgid(sending host), filename, size, line, available server.
> And introducing them (and updating them - again very slowly -
> at every header fetch) would cause both - disk space and time
> and effort for expiry........
>
> Reducing the amount by detecting - and eliminating - multiparts
> would not be a solution for me.
>
>
> So here finally my question:
> How do you sort your header-lists if they dont fit into memory ?
>
> I believe that sorting "1.500.000" lines simply by 'users-click'
> is a very demanding job - and such quantities appear only on
> the binary usenet today....
>
> Any ideas, tips,
> genuine disk sorting algorithms introduced since 1979
> and better/faster than B-Tree ?
>
>
> TIA
> --
> Juergen
MFG
--
Heiko Studt
http://www.goldpool.org/temp/IMAPHamster.zip 20.3.2003 24:00
Technical Details
Message-ID:
<b5nnpr.180.1@Heiko.Studt.dialin.t-online.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mailReferences:
<4540d.o33203@archiver.winews.net>Show Full Headers
Complete Article Headers
Message-ID: <b5nnpr.180.1@Heiko.Studt.dialin.t-online.de> Subject: Re: Newsreader programming - sorting one million lines ? Date: Mon, 24 Mar 2003 19:54:34 +0100 From: Heiko Studt <UsenetBecky@goldpool.org> References: <4540d.o33203@archiver.winews.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail Newsgroups: news.software.nntp Organization: HSR Lines: 96 Reply-To: Heiko.Studt@gmx.de Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: news.t-online.com 1048532274 06 19006 mogtE+oESxHYoB 030324 18:57:54 X-Complaints-To: abuse@t-online.com X-ID: VCyEr4ZXreZXLxocgR8QqxBzS4sCdlgLkD55nl2FRNKti5Ly0jTcsV X-Mailer: Becky! ver. 2.05.10 with BkNews Plug-In ver. 2.0 User-Agent: Hamster-Pg/1.8