I will second NetWallah's suggestion for using a database here — it looks like you probably have too much data to fit in RAM all at once.

That does not necessarily mean SQL; you could store image:offset tuples and have objects that abstract data retrieval from disk as-needed. The big problem that I see is that you are looking at possibly (224)*(224) arrays, which are a few hundred bytes each in AV overhead. Do you have 248 ~ 256TiB RAM?

Start by what we actually, no question about it, know: the PPN for each page, which we know because it is the address where we read that page from the NAND array. Further, the PPNs have a contiguous range. So we can make an array of hashes: (see also perldsc)

# array mapping PPN to hash of info key => value # element keys: # LPN => logical page number stored at this block # XPPN => array of unknown numbers found with this block my @PPN = ();

We probably have the LPN for each block, but we have no guarantee that LPNs in the image are contiguous, and we already know that many PPNs store different versions of the same LPN. However, LPNs are probably mostly contiguous, so we can still use an array, this time of arrays:

# array mapping LPN to array of PPNs that store copies # each element is an array of PPNs my @LPN = ();

Loading these arrays should be relatively simple:

use constant NAND_PAGE_SIZE => 16384; # or whatever... { open IMAGE, '<', $image_file_name or die "$image_file_name: $!"; local $/ = \NAND_PAGE_SIZE; while (<IMAGE>) { my $ppn = (tell IMAGE) / NAND_PAGE_SIZE; my $lpn = get_LPN($_); $PPN[$ppn] = { LPN => $lpn, XPPN => [ get_XPPNs($_) ] }; push @{$LPN[$lpn]}, $ppn; } close IMAGE; }

Hopefully this helps...


In reply to Re^3: Adding cols to 3d arrays - syntax by jcb
in thread Adding cols to 3d arrays - syntax by peterrowse

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.