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/ClassifyTreeNode.pm

    r15890 r17087  
    2626    $self->{'model'} = $model;
    2727    $self->{'clid'} = $clid;
     28
     29    my $collection = $model->getCollection();
     30
    2831    # Check if this node already exists in the database, and if not insert it
    2932    # now
    30     my $text = &GDBMUtils::gdbmGet($model->getCollection(), $clid);
     33    my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $clid);
    3134    if($text !~ /\w+/ && $force_new)
    3235      {
    33         &GDBMUtils::gdbmSet($model->getCollection(), $clid,
     36        &GDBMUtils::gdbmCachedCollectionSet($collection, $clid,
    3437                            "<doctype>classify\n<hastxt>0\n<childtype>VList\n<Title>\n<numleafdocs>0\n<contains>\n");
    3538      }
     
    108111    # CLID
    109112    my @child_nodes = $self->getChildren();
     113
    110114    # Retrieve the current document
    111115    my $text = $self->toString();
     116
     117    my $collection = $self->{'model'}->getCollection();
     118
    112119    # Create a new document with the correct CLID
    113     &GDBMUtils::gdbmSet($self->{'model'}->getCollection(), $new_clid, $text);
     120    &GDBMUtils::gdbmCachedCollectionSet($collection, $new_clid, $text);
     121
    114122    # Remove the old document
    115     &GDBMUtils::gdbmSet($self->{'model'}->getCollection(), $self->{'clid'});
     123    &GDBMUtils::gdbmCachedCollectionSet($collection, $self->{'clid'});
     124
    116125    # Finally, change the clid stored in this document
    117126    $self->{'clid'} = $new_clid;
     127
    118128    # Now go through this nodes children, and shift them too
    119129    foreach my $child_node (@child_nodes)
     
    221231    push(@clid_parts, $suffix);
    222232    my $next_clid = join(".", @clid_parts);
     233
     234    my $collection = $self->{'model'}->getCollection();
     235
    223236    # Now determine if this node exists.
    224     if(&GDBMUtils::gdbmGet($self->{'model'}->getCollection(), $next_clid) =~ /\w+/)
     237    if(&GDBMUtils::gdbmCachedCollectionGet($collection, $next_clid) =~ /\w+/)
    225238      {
    226239        # And if so, create it.
     
    474487    # Now remove the node from the database. We do this calling set gdbm with
    475488    # no value argument.
    476     &GDBMUtils::gdbmSet($self->{'model'}->getCollection(), $self->{'clid'});
     489    my $collection = $self->{'model'}->getCollection();
     490    &GDBMUtils::gdbmCachedCollectionSet($collection, $self->{'clid'});
     491
    477492    # Return the leaf count (so we can adjust the numleafdocs at the root node
    478493    # of this deletion.
     
    605620    # Replace any occurance of this nodes CLID with "
    606621    $contains =~ s/$self->{'clid'}/\"/g;
     622
     623    my $collection = $self->{'model'}->getCollection();
     624    my $clid = $self->{'clid'};
     625
    607626    # Load the text of this node
    608     my $text = &GDBMUtils::gdbmGet($self->{'model'}->getCollection(), $self->{'clid'});
     627    my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $clid);
     628
    609629    # Replace the contains
    610630    #rint STDERR "Before: $text\n";
     
    612632    #rint STDERR "After:  $text\n";
    613633    # Store the changed text
    614     &GDBMUtils::gdbmSet($self->{'model'}->getCollection(), $self->{'clid'}, $text);
     634    &GDBMUtils::gdbmCachedCollectionSet($collection, $clid, $text);
    615635  }
    616636# /** setContains() **/
     
    626646    my ($self, $numleafdocs) = @_;
    627647    print STDERR "ClassifyTreeNode::setNumLeafDocs(numleafdocs)\n" unless !$self->{'debug'};
     648
     649    my $collection = $self->{'model'}->getCollection();
     650    my $clid = $self->{'clid'};
     651
    628652    # Load the text of this node
    629     my $text = &GDBMUtils::gdbmGet($self->{'model'}->getCollection(), $self->{'clid'});
     653    my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $clid);
    630654    # Replace the numleafdocs
    631655    $text =~ s/<numleafdocs>\d*?\n+/<numleafdocs>$numleafdocs\n/;
    632656    # Store the changed text
    633     &GDBMUtils::gdbmSet($self->{'model'}->getCollection(), $self->{'clid'}, $text);
     657    &GDBMUtils::gdbmCachedCollectionSet($collection, $clid, $text);
    634658  }
    635659# /** setNumLeafDocs() **/
     
    647671    my ($self, $title) = @_;
    648672    print STDERR "ClassifyTreeNode::setTitle(\"$title\")\n" unless !$self->{'debug'};
     673
     674    my $collection = $self->{'model'}->getCollection();
     675    my $clid = $self->{'clid'};
     676
    649677    # Load the text of this node
    650     my $text = &GDBMUtils::gdbmGet($self->{'model'}->getCollection(), $self->{'clid'});
     678    my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $clid);
    651679    # Replace the title
    652680    $text =~ s/<Title>.*?\n+/<Title>$title\n/;
    653681    # Store the changed text
    654     &GDBMUtils::gdbmSet($self->{'model'}->getCollection(), $self->{'clid'}, $text);
     682    &GDBMUtils::gdbmCachedCollectionSet($collection, $clid, $text);
    655683  }
    656684# /** setValue() **/
     
    666694    my ($self) = @_;
    667695    print STDERR "ClassifyTreeNode::toString()\n" unless !$self->{'debug'};
    668     my $text = &GDBMUtils::gdbmGet($self->{'model'}->getCollection(), $self->{'clid'});
     696    my $collection = $self->{'model'}->getCollection();
     697    my $clid = $self->{'clid'};
     698
     699    my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $clid);
    669700    return $text;
    670701  }
Note: See TracChangeset for help on using the changeset viewer.