Ignore:
Timestamp:
2008-08-29T13:10:39+12:00 (16 years ago)
Author:
davidb
Message:

Introduction of new GDBM alternative for archives.inf as step towards full incremental building. Information traditionally stored in archives.inf PLUS additional information that will help with working out what files have changed since last build, and what doc-id they hashed to is stored in two GDBM databases. For now these databases aren't read, but in the future ArchivesInfPlugin will be upgraded to use these to support these.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/IncrementalDocument.pm

    r15894 r17087  
    3535  {
    3636    my ($class, $collection, $oid) = @_;
     37
    3738    #rint STDERR "IncrementalDocument::new($collection, $oid)\n";
     39
    3840    # Test the parameters
    3941    die ("Error! Can't create a document that doesn't belong to a collection!") unless $collection;
    4042    die ("Error! Can't create a document that doesn't have a unique id (OID)!") unless $oid;
     43
    4144    # Store the variables
    4245    my $self = {};
     46
    4347    # The collection this document object has been loaded from.
    4448    $self->{'collection'} = $collection;
     49
    4550    # An associative array of information retrieved from the GDBM database
    4651    # which maps a key string to a nested associative array listing values.
    4752    $self->{'data'} = {};
     53
    4854    # The unique identifier of the document loaded
    4955    $self->{'oid'} = $oid;
     56
    5057    # Stores the order in which metadata keys where discovered/added.
    5158    $self->{'order'} = {};
    52     # Bless me father for I have sinned
     59
    5360    bless $self, $class;
    5461    return $self;
     
    6168  {
    6269    my ($self, $key, $value, $internal) = @_;
     70
    6371    # Validate the arguments
    6472    die ("Error! Can't add a metadata value to a document without a valid key!") unless $key =~ /[\w]+/;
    6573    die ("Error! Can't add a metadata key to a document without a valid value!") unless $value =~ /[\w\d]+/;
     74
    6675    # Is this a new key that we haven't encountered before? If so ensure an
    6776    # array exists for its values, and record the order in which we encountered
     
    7584        $self->{'data'}->{$key} = {};
    7685      }
     86
    7787    # Set the value of the associative path to 1.
    7888    $self->{'data'}->{$key}->{$value} = 1;
     
    8494#  */
    8595sub getAllMetadata()
    86   {
     96{
     97    my ($self) = @_;
     98    my @all_metadata;
     99
    87100    print STDERR "IncrementalDocument.getAllMetadata()\n";
    88     my ($self) = @_;
    89     my @all_metadata;
    90101
    91102    my $key_count = scalar(keys %{$self->{'order'}});
     
    137148    #rint STDERR "IncrementalDocument::loadDocument()\n";
    138149    # Load the raw text for the document object from GDBM
    139     my $text = &GDBMUtils::gdbmGet($self->{'collection'}, $self->{'oid'});
     150    my $collection = $self->{'collection'};
     151    my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $self->{'oid'});
    140152    # For each line in the raw text, extract the key (enclosed in angle
    141153    # brackets) and the value
     
    170182    # Get a textual version of this object
    171183    my $text = $self->toString();
     184
    172185    # Now store the object in the database using the GDBM utilities
    173     &GDBMUtils::gdbmSet($self->{'collection'}, $self->{'oid'}, $text);
     186    my $collection = $self->{'collection'};
     187    &GDBMUtils::gdbmCachedCollectionSet($collection, $self->{'oid'}, $text);
     188
    174189    # There is a little bit of extra complexity when saving an incremental
    175190    # document in that we should ensure that a reverse lookup-from DocNum or
     
    178193    if($doc_num >= 0)
    179194      {
    180         my $text = &GDBMUtils::gdbmGet($self->{'collection'}, $doc_num);
     195        my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $doc_num);
    181196        # If there is no reverse lookup, then add one now
    182197        if($text !~ /<section>/)
    183198          {
    184             &GDBMUtils::gdbmSet($self->{'collection'}, $doc_num, "<section>" . $self->{'oid'});
     199            &GDBMUtils::gdbmCachedCollectionSet($collection, $doc_num, "<section>" . $self->{'oid'});
    185200          }
    186201      }
Note: See TracChangeset for help on using the changeset viewer.