Changeset 15725


Ignore:
Timestamp:
05/27/08 15:02:16 (13 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Added $infodb_type as first argument to all the dbutil functions.

Location:
gsdl/trunk/perllib
Files:
6 edited

Legend:

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

    r15711 r15725  
    9999    $self->{'collect_cfg_preserve'} = &colcfg::read_collection_cfg_xml ($colcfgname);
    100100    }
    101    
     101
     102    # get the database type for this collection from the collect.cfg file (may be undefined)
     103    $self->{'infodbtype'} = $self->{'collect_cfg'}->{'infodbtype'} || "";
     104
    102105    # get the list of plugins for this collection
    103106    my $plugins = [];
     
    321324
    322325    # Get info database file path
    323     my $infodb_file_path = &dbutil::get_infodb_file_path($self->{'collection'}, $textdir);
     326    my $infodb_file_path = &dbutil::get_infodb_file_path($self->{'infodbtype'}, $self->{'collection'}, $textdir);
    324327
    325328    print $outhandle "\n*** creating the info database and processing associated files\n"
     
    333336    if ($self->{'keepold'}) {
    334337    # reconstruct doc_obj metadata from database for all docs
    335     $reconstructed_docs = &classify::reconstruct_doc_objs_metadata($infodb_file_path);
     338    $reconstructed_docs = &classify::reconstruct_doc_objs_metadata($self->{'infodbtype'}, $infodb_file_path);
    336339    }
    337340   
     
    342345    }
    343346    else {
    344     $infodb_handle = &dbutil::open_infodb_write_handle($infodb_file_path);
     347    print STDERR "Infodbtype: " . $self->{'infodbtype'} . "\n";
     348    $infodb_handle = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $infodb_file_path);
    345349    if (!defined($infodb_handle))
    346350    {
     
    349353    }
    350354    }
    351    
     355
     356    $self->{'buildproc'}->set_infodbtype ($self->{'infodbtype'});
    352357    $self->{'buildproc'}->set_output_handle ($infodb_handle);
    353358    $self->{'buildproc'}->set_mode ('infodb');
     
    382387   
    383388    # output classification information
    384     &classify::output_classify_info ($self->{'classifiers'}, $infodb_handle,
     389    &classify::output_classify_info ($self->{'classifiers'}, $self->{'infodbtype'}, $infodb_handle,
    385390                     $self->{'remove_empty_classifications'},
    386391                     $self->{'gli'});
     
    391396    # output doclist
    392397    my @doc_list = $self->{'buildproc'}->get_doc_list();
    393     &dbutil::write_infodb_entry($infodb_handle, "browselist", { 'hastxt' => [ "0" ],
    394                                     'childtype' => [ "VList" ],
    395                                     'numleafdocs' => [ scalar(@doc_list) ],
    396                                     'thistype' => [ "Invisible" ],
    397                                     'contains' => [ join(";", @doc_list) ] });
     398    my $browselist_infodb = { 'hastxt' => [ "0" ],
     399                  'childtype' => [ "VList" ],
     400                  'numleafdocs' => [ scalar(@doc_list) ],
     401                  'thistype' => [ "Invisible" ],
     402                  'contains' => [ join(";", @doc_list) ] };
     403    print STDERR "Infodbtype: " . $self->{'infodbtype'} . "\n";
     404    &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, "browselist", $browselist_infodb);
    398405
    399406    close ($infodb_handle) if !$self->{'debug'};
     
    587594    my %collection_infodb = ();
    588595    $self->get_collection_meta_sets(\%collection_infodb);
    589     &dbutil::write_infodb_entry($infodb_handle, "collection", \%collection_infodb);
     596    &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, "collection", \%collection_infodb);
    590597}
    591598
  • gsdl/trunk/perllib/basebuildproc.pm

    r15708 r15725  
    225225}
    226226
     227sub set_infodbtype
     228{
     229    my $self = shift(@_);
     230    my $infodbtype = shift(@_);
     231    $self->{'infodbtype'} = $infodbtype;
     232}
     233
    227234sub set_index {
    228235    my $self = shift (@_);
     
    429436        # special case for URL metadata
    430437        if ($field =~ /^URL$/i) {
    431             &dbutil::write_infodb_entry($infodb_handle, $value, { 'section' => [ $section_OID ] });
     438            &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, $value, { 'section' => [ $section_OID ] });
    432439        }
    433440
     
    506513    }
    507514   
    508     &dbutil::write_infodb_entry($infodb_handle, $section_OID, \%section_infodb);
     515    &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, $section_OID, \%section_infodb);
    509516   
    510517    # output a database entry for the document number
    511518    if ($self->{'db_level'} eq "document") {
    512         &dbutil::write_infodb_entry($infodb_handle, $self->{'num_docs'}, { 'section' => [ $doc_OID ] });
     519        &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, $self->{'num_docs'}, { 'section' => [ $doc_OID ] });
    513520    }
    514521    else {
    515         &dbutil::write_infodb_entry($infodb_handle, $self->{'num_sections'}, { 'section' => [ $section_OID ] });
     522        &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, $self->{'num_sections'}, { 'section' => [ $section_OID ] });
    516523    }
    517524
  • gsdl/trunk/perllib/classify.pm

    r15705 r15725  
    233233sub reconstruct_doc_objs_metadata
    234234{
    235     my ($infodb_file_path) = @_;
     235    my $infodb_type = shift(@_);
     236    my $infodb_file_path = shift(@_);
    236237
    237238    my %database_recs;
    238     &dbutil::read_infodb_file($infodb_file_path, \%database_recs);
     239    &dbutil::read_infodb_file($infodb_type, $infodb_file_path, \%database_recs);
    239240
    240241    # dig out top level doc sections
     
    293294sub output_classify_info
    294295{
    295     my ($classifiers, $infodb_handle, $remove_empty_classifications, $gli) = @_;
     296    my ($classifiers, $infodb_type, $infodb_handle, $remove_empty_classifications, $gli) = @_;
    296297
    297298    $gli = 0 unless defined $gli;
     
    313314    }
    314315
    315     &print_classify_info ($infodb_handle, $classifyinfo, "", $remove_empty_classifications);
     316    &print_classify_info($infodb_type, $infodb_handle, $classifyinfo, "", $remove_empty_classifications);
    316317}
    317318
     
    319320sub print_classify_info
    320321{
    321     my ($infodb_handle, $classifyinfo, $OID, $remove_empty_classifications) = @_;
     322    my ($infodb_type, $infodb_handle, $classifyinfo, $OID, $remove_empty_classifications) = @_;
    322323
    323324    $OID =~ s/^\.+//; # just for good luck
     
    381382            #rint STDERR "Result: \"" . join(";", @{$clids}) . "\"\n";
    382383           
    383         &print_classify_info ($infodb_handle, $tempinfo, $tempinfo->{'classifyOID'},
     384        &print_classify_info ($infodb_type, $infodb_handle, $tempinfo, $tempinfo->{'classifyOID'},
    384385                  $remove_empty_classifications);
    385386    } elsif (defined ($tempinfo->{'OID'})) {
     
    426427                #rint STDERR "Result: \"" . join(";", @{$clids}) . "\"\n";
    427428       
    428         &print_classify_info ($infodb_handle, $tempinfo, "$OID.$next_subOID",
     429        &print_classify_info ($infodb_type, $infodb_handle, $tempinfo, "$OID.$next_subOID",
    429430                      $remove_empty_classifications);
    430431        $next_subOID++;
     
    438439    if ($mdoffset_text !~ m/^;+$/);
    439440   
    440     &dbutil::write_infodb_entry($infodb_handle, $OID, \%classify_infodb);
     441    &dbutil::write_infodb_entry($infodb_type, $infodb_handle, $OID, \%classify_infodb);
    441442}
    442443
  • gsdl/trunk/perllib/dbutil.pm

    r15722 r15725  
    3131sub get_infodb_file_path
    3232{
     33    my $infodb_type = shift(@_);
    3334    my $collection_name = shift(@_);
    3435    my $infodb_directory_path = shift(@_);
    3536
     37    if ($infodb_type eq "sqlite")
     38    {
     39    return &get_infodb_file_path_sqlite($collection_name, $infodb_directory_path);
     40    }
     41
     42    # Use GDBM if the infodb type is empty or not one of the values above
    3643    return &get_infodb_file_path_gdbm($collection_name, $infodb_directory_path);
    3744}
     
    4047sub open_infodb_write_handle
    4148{
    42     my $infodb_file_path = shift(@_);
    43 
     49    my $infodb_type = shift(@_);
     50    my $infodb_file_path = shift(@_);
     51
     52    if ($infodb_type eq "sqlite")
     53    {
     54    return &open_infodb_write_handle_sqlite($infodb_file_path);
     55    }
     56
     57    # Use GDBM if the infodb type is empty or not one of the values above
    4458    return &open_infodb_write_handle_gdbm($infodb_file_path);
    4559}
     
    4862sub read_infodb_file
    4963{
     64    my $infodb_type = shift(@_);
    5065    my $infodb_file_path = shift(@_);
    5166    my $infodb_map = shift(@_);
     
    5772sub write_infodb_entry
    5873{
     74    my $infodb_type = shift(@_);
    5975    my $infodb_handle = shift(@_);
    6076    my $infodb_key = shift(@_);
    6177    my $infodb_map = shift(@_);
    6278
    63     &write_infodb_entry_gdbm($infodb_handle, $infodb_key, $infodb_map);
     79    if ($infodb_type eq "sqlite")
     80    {
     81    return &write_infodb_entry_sqlite($infodb_handle, $infodb_key, $infodb_map);
     82    }
     83
     84    # Use GDBM if the infodb type is empty or not one of the values above
     85    return &write_infodb_entry_gdbm($infodb_handle, $infodb_key, $infodb_map);
    6486}
    6587
  • gsdl/trunk/perllib/lucenebuilder.pm

    r15718 r15725  
    364364    # Get info database file path
    365365    my $text_directory_path = &util::filename_cat($self->{'build_dir'}, "text");
    366     my $infodb_file_path = &dbutil::get_infodb_file_path($self->{'collection'}, $text_directory_path);
     366    my $infodb_file_path = &dbutil::get_infodb_file_path($self->{'infodbtype'}, $self->{'collection'}, $text_directory_path);
    367367
    368368    # If we aren't doing an incremental addition, then we just call the super-
  • gsdl/trunk/perllib/mgppbuilder.pm

    r15715 r15725  
    708708    $self->get_collection_meta_sets(\%collection_infodb);
    709709    $self->get_collection_meta_indexes(\%collection_infodb);
    710     &dbutil::write_infodb_entry($infodb_handle, "collection", \%collection_infodb);
     710    &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, "collection", \%collection_infodb);
    711711}
    712712
Note: See TracChangeset for help on using the changeset viewer.