Changeset 21562


Ignore:
Timestamp:
01/21/10 15:22:28 (11 years ago)
Author:
mdewsnip
Message:

Changed calls to GDBMUtils::gdbmCachedCollectionSet() to dbutil::write_infodb_entry(). Part of removing GDBMUtils.pm and making the code less GDBM-specific.

Location:
main/trunk/greenstone2/perllib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/ClassifyTreeNode.pm

    r21561 r21562  
    3737    if($text !~ /\w+/ && $force_new)
    3838      {
    39         &GDBMUtils::gdbmCachedCollectionSet($collection, $clid,
    40                             "<doctype>classify\n<hastxt>0\n<childtype>VList\n<Title>\n<numleafdocs>0\n<contains>\n");
     39    my $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $self->{'infodb_file_path'}, "append");
     40    &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash("<doctype>classify\n<hastxt>0\n<childtype>VList\n<Title>\n<numleafdocs>0\n<contains>\n"));
     41    &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
    4142      }
    4243    # Bless me father for I have sinned
     
    121122
    122123    # Create a new document with the correct CLID
    123     &GDBMUtils::gdbmCachedCollectionSet($collection, $new_clid, $text);
    124 
     124    my $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $self->{'infodb_file_path'}, "append");
     125    &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $new_clid, &dbutil::convert_infodb_string_to_hash($text));
    125126    # Remove the old document
    126     &GDBMUtils::gdbmCachedCollectionSet($collection, $self->{'clid'});
     127    &dbutil::delete_infodb_entry("gdbm", $infodb_file_handle, $self->{'clid'});
     128    &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
    127129
    128130    # Finally, change the clid stored in this document
     
    488490        $num_leaf_docs += $1;
    489491      }
    490     # Now remove the node from the database. We do this calling set gdbm with
    491     # no value argument.
    492     my $collection = $self->{'model'}->getCollection();
    493     &GDBMUtils::gdbmCachedCollectionSet($collection, $self->{'clid'});
     492    # Now remove the node from the database
     493    my $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $self->{'infodb_file_path'}, "append");
     494    &dbutil::delete_infodb_entry("gdbm", $infodb_file_handle, $self->{'clid'});
     495    &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
    494496
    495497    # Return the leaf count (so we can adjust the numleafdocs at the root node
     
    635637    #rint STDERR "After:  $text\n";
    636638    # Store the changed text
    637     &GDBMUtils::gdbmCachedCollectionSet($collection, $clid, $text);
     639    my $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $self->{'infodb_file_path'}, "append");
     640    &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash($text));
     641    &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
    638642  }
    639643# /** setContains() **/
     
    658662    $text =~ s/<numleafdocs>\d*?\n+/<numleafdocs>$numleafdocs\n/;
    659663    # Store the changed text
    660     &GDBMUtils::gdbmCachedCollectionSet($collection, $clid, $text);
     664    my $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $self->{'infodb_file_path'}, "append");
     665    &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash($text));
     666    &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
    661667  }
    662668# /** setNumLeafDocs() **/
     
    683689    $text =~ s/<Title>.*?\n+/<Title>$title\n/;
    684690    # Store the changed text
    685     &GDBMUtils::gdbmCachedCollectionSet($collection, $clid, $text);
     691    my $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $self->{'infodb_file_path'}, "append");
     692    &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash($text));
     693    &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
    686694  }
    687695# /** setValue() **/
  • main/trunk/greenstone2/perllib/IncrementalBuildUtils.pm

    r17283 r21562  
    390390        # Now use the GDBM utils to write a blank string to this oid in the
    391391        # database
    392         &GDBMUtils::gdbmCachedCollectionSet($collection, $oid, "");
     392    my $index_text_directory_path = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "index", "text");
     393    my $infodb_file_path = &dbutil::get_infodb_file_path("gdbm", $collection, $index_text_directory_path);
     394    my $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $infodb_file_path, "append");
     395    &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $oid, &dbutil::convert_infodb_string_to_hash(""));
    393396        # Remove reverse lookup
    394         &GDBMUtils::gdbmCachedCollectionSet($collection, $doc_num, "");
     397    &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $doc_num, &dbutil::convert_infodb_string_to_hash(""));
     398    &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
     399
    395400        # And remove from the database
    396401        &callGS2LuceneDelete($collection, $doc_num);
  • main/trunk/greenstone2/perllib/IncrementalDocument.pm

    r21561 r21562  
    187187    # Now store the object in the database using the GDBM utilities
    188188    my $collection = $self->{'collection'};
    189     &GDBMUtils::gdbmCachedCollectionSet($collection, $self->{'oid'}, $text);
     189
     190    my $index_text_directory_path = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "index", "text");
     191    my $infodb_file_path = &dbutil::get_infodb_file_path("gdbm", $collection, $index_text_directory_path);
     192    my $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $infodb_file_path, "append");
     193    &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $self->{'oid'}, &dbutil::convert_infodb_string_to_hash($text));
     194    &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
    190195
    191196    # There is a little bit of extra complexity when saving an incremental
     
    195200    if($doc_num >= 0)
    196201      {
    197     my $index_text_directory_path = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "index", "text");
    198     my $infodb_file_path = &dbutil::get_infodb_file_path("gdbm", $collection, $index_text_directory_path);
    199202    my $text = &dbutil::read_infodb_entry("gdbm", $infodb_file_path, $doc_num);
    200203
     
    202205        if($text !~ /<section>/)
    203206          {
    204             &GDBMUtils::gdbmCachedCollectionSet($collection, $doc_num, "<section>" . $self->{'oid'});
     207        $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $infodb_file_path, "append");
     208        &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $doc_num, &dbutil::convert_infodb_string_to_hash("<section>" . $self->{'oid'}));
     209        &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
    205210          }
    206211      }
Note: See TracChangeset for help on using the changeset viewer.