The number of items in your data sets isn't the problem. You have 15,000 and 500,000, which are small enough to process easily with a database. The real issue is that one data set is highly unstructured.

There are a number of ways to skin this cat. But the key is that you're going to need to write a routine that takes an email message and produces a list of possible original recipients from that message. This step should be generous - you don't want to miss any.

Now pick your method. One approach is to create a hash whose keys are the 15,000 test email addresses and follow this pseudocode:

while (my $file = get_email_file()) { for my $email (get_possible_original_recipients($file)) { if ($in_test{$email}) { # Do something here. } } }
A secopnd approach is to create a table in a database with the fields (filename, email_in_file), populate another table with your test emails, then join them.

Personally I'd suggest following the second approach for several reasons.

  1. It is easily parallelizable - you can have multiple jobs populating that first table at once so you get through that big step faster.
  2. As you tweak the more complex later processing, it is faster to re-run. You can just execute a query rather than having to search gigabytes of emails every time you tweak it.
  3. This is generally useful information to have, you're likely to find other uses for it later.

In reply to Re: Algorithm advice sought for seaching through GB's of text (email) files by tilly
in thread Algorithm advice sought for seaching through GB's of text (email) files by chargrill

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.