🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: demon.ip.developers
Article #68

Re: Newshistory checking

#68
From: Terrance Richard Boyes
Date: Wed, 14 Jul 1999 00:00
51 lines
3360 bytes
Nikki Locke <nikki@trmphrst.demon.co.uk> wrote:
> In article <19990713.200500.0AA80202.PEaa@pierrot.co.uk>, Terrance 
> Richard Boyes wrote:
>> I'm looking for an efficient way to check for duplicate Message-IDs
>> in a large NewsHistory file against the output of NEWNEWS (or XOVER
>> after extracting the Message-ID).

>> Any thoughts on the best way to do it in C ?

> That's what hash tables are for, surely. I'm pretty sure that's how 
> PERL does it under the hood.

Probably, when using awk the read time is proportional to file
size, and check time is always practically instantaneous (at
least up to 1,000,000 items).

> Most C++ libraries include some form of Dictionary, which works like 
> the PERL method, and is usually implemented using hash tables. 

> I seem to remember standard Unix library functions to do hash tables - 
> were they called hcreate/hsearch/hdestroy?

I'd prefer not to use anything that may be OS dependant, certainly
nothing that uses runtime libs.

Though if I did the GDBM looks useful...

> The basic idea is that you create an array large enough to hold at 
> least the expected number of message ID's. 

Performance wise (at least in RDBMS terms) it makes more sense to 
leave a fair amount of empty space.

[snip]

> The efficiency of the hash table depends heavily on the suitability of 
> the initial hashing algorithm - if the ID's all hash to different 
> numbers, it is very fast. If they all hash to the same number, it is as 
> slow as a linear search.

One problem with message-ids is how to hash them uniquely, they
tend to be relatively large, so any prime-multiplication
type method would result in huge numbers. I did a few experiments
last night with simple things like adding up all the ASCII values
(and a variant splitting the message-id into <lhs@rhs>) and
there is a lot of overflow.

-- 
<URL:http://www.pierrot.co.uk/>                                  Team AMIGA
Life is like an onion: you peel off layer after layer, then you find
there is nothing in it.
Technical Details
Message-ID: <19990714.205259.0AA80202.Tuaa@pierrot.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <19990713.200500.0AA80202.PEaa@pierrot.co.uk> <VA.000067f3.00e611c6@trmphrst.demon.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10bb05,75d5f9974c0fd91a
X-Google-Attributes: gid10bb05,public
From: tez@pierrot.co.uk (Terrance Richard Boyes)
Subject: Re: Newshistory checking
Date: 1999/07/14
Message-ID: <19990714.205259.0AA80202.Tuaa@pierrot.co.uk>
X-Deja-AN: 501114116
X-PGP-Fingerprint: 20 66 0F E8 85 64 9C 2C  6F 82 6F 19 6C 2F 6A 1D 
X-Cancel-Lock: TEZT:426cd8b70ad7391bb91bf244ba262d37 f0a4e777aebc9a02f8ac127108bdcdb8
X-PGP-Keyfile: <URL:http://www.pierrot.co.uk/pgpauth/>
References: <19990713.200500.0AA80202.PEaa@pierrot.co.uk> <VA.000067f3.00e611c6@trmphrst.demon.co.uk>
X-PGP-Auth: pub   512/3A14C4B9 1999/04/22 Tez Boyes <tez@pierrot.co.uk> iQBVAwUBN40JLEXush46FMS5AQEIvwH6A0Bc9IwsUVjNHBWt/mVHww7zt3A8wiZk 3dMT+pYZqr1bfRMQiuU0ZR0B7hSu5+EJsQHnb1aqVAPDuHW6dA27pw== =X4fm
X-NaMLServ: $VER: v0.9b <tez@pierrot.co.uk>
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!finch-post-12.mail.demon.net!pierrot.demon.co.uk!pierrot.co.uk!tez@pierrot.co.uk
X-Trace: mail2news.demon.co.uk 931993397 mail2news:13582 mail2news mail2news.demon.co.uk
Organization: ECL.Net
User-Agent: tin/pre-1.4-980618 (AMIGA)
X-Lan-Trace: news.pierrot.lan 19990714.205259 news:Tuaa IDENT tez@ami060.pierrot.lan
Newsgroups: demon.ip.developers