The problem is the size of the file is large(About 800Mb to 2Gb)
Repeating what was discussed in the CB,
tye maintains
Algorithm::Diff so he'd be your best bet for issues related to the module.
With such large files though, you may need to change your approach. Assuming that Algorithm::Diff is bogging down due to the large file size, the idea is that you should make sure that not so much of the data is loaded at one time.
Method 1
Algorithm::Diff works from two arrays, right? If so perhaps the easiest thing to do is just to pass it (references to) two
Tie::File objects.
Update: well, it's not that simple. Algorithm::Diff builds a hash to keep track of indexes, which grows (O(?)) with the length of the arrays passed.
Method 2
If that didn't work (or was too slow) I'd do something like this (pseudocode):
declare @differences
open file1 and file2
read chunk1 from file1 (64mbyte)
read chunk2 from file2 (64mbyte)
while (chunk1 contains data)
compute h1: md5hex of chunk1
compute h2: md5hex of chunk2
if h1 != h2
compute @diff: pass chunk1 and chunk2 to Algorithm::Diff
append @diff to @differences
end-of-if
read chunk1 from file1 (64mbyte)
read chunk2 from file2 (64mbyte)
end-of-while
close file1 and file2
#maybe combine adjacent deltas in @differences (eg: by line number)
report @differences
That way Algorithm::Diff only ever deals with 2x 64Mbyte of data at a time. If two adjacent chunks both contain differences between the files, you might investigate whether there's some way to combine those differences.
-David
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.