Changeset 23485

Show
Ignore:
Timestamp:
14.12.2010 16:16:48 (9 years ago)
Author:
davidb
Message:

read_infodb_entry now returns a hashmap directly. Code updated to take advantage of this, and in places where the hashmap is not needed, the alternative read_infodb_rawentry is called.

Location:
main/trunk/greenstone2/perllib
Files:
8 modified

Legend:

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

    r22749 r23485  
    157157    my $index_text_directory_path = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $self->getCollection(), "index", "text"); 
    158158    my $infodb_file_path = &dbutil::get_infodb_file_path($self->{'infodbtype'}, $self->getCollection(), $index_text_directory_path); 
    159     if (&dbutil::read_infodb_entry($self->{'infodbtype'}, $infodb_file_path, $clid) =~ /\w+/) 
     159    if (&dbutil::read_infodb_rawentry($self->{'infodbtype'}, $infodb_file_path, $clid) =~ /\w+/) 
    160160      { 
    161161        # Since the CLID can directly reference the correct entry in the info database we 
  • main/trunk/greenstone2/perllib/ClassifyTreeNode.pm

    r22749 r23485  
    6262    # Check if this node already exists in the database, and if not insert it 
    6363    # now 
    64     my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 
     64    my $text = &dbutil::read_infodb_rawentry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 
    6565    if($text !~ /\w+/ && $force_new) 
    6666      { 
     
    268268 
    269269    # Now determine if this node exists. 
    270     if (&dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $next_clid) =~ /\w+/) 
     270    if (&dbutil::read_infodb_rawentry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $next_clid) =~ /\w+/) 
    271271      { 
    272272        # And if so, create it. 
     
    658658 
    659659    # Load the text of this node 
    660     my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 
     660    my $text = &dbutil::read_infodb_rawentry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 
    661661 
    662662    # Replace the contains 
     
    686686 
    687687    # Load the text of this node 
    688     my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 
     688    my $text = &dbutil::read_infodb_rawentry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 
    689689    # Replace the numleafdocs 
    690690    $text =~ s/<numleafdocs>\d*?\n+/<numleafdocs>$numleafdocs\n/; 
     
    713713 
    714714    # Load the text of this node 
    715     my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 
     715    my $text = &dbutil::read_infodb_rawentry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 
    716716    # Replace the title 
    717717    $text =~ s/<Title>.*?\n+/<Title>$title\n/; 
     
    736736    my $clid = $self->{'clid'}; 
    737737 
    738     my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 
     738    my $text = &dbutil::read_infodb_rawentry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 
    739739    return $text; 
    740740  } 
  • main/trunk/greenstone2/perllib/IncrementalDocument.pm

    r21645 r23485  
    154154    my $index_text_directory_path = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "index", "text"); 
    155155    my $infodb_file_path = &dbutil::get_infodb_file_path($self->{'infodbtype'}, $collection, $index_text_directory_path); 
    156     my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $infodb_file_path, $self->{'oid'}); 
     156    my $text = &dbutil::read_infodb_rawentry($self->{'infodbtype'}, $infodb_file_path, $self->{'oid'}); 
    157157    # For each line in the raw text, extract the key (enclosed in angle 
    158158    # brackets) and the value 
     
    203203    if($doc_num >= 0) 
    204204      { 
    205     my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $infodb_file_path, $doc_num); 
     205    my $text = &dbutil::read_infodb_rawentry($self->{'infodbtype'}, $infodb_file_path, $doc_num); 
    206206 
    207207        # If there is no reverse lookup, then add one now 
  • main/trunk/greenstone2/perllib/dbutil.pm

    r23448 r23485  
    214214    } 
    215215} 
     216 
     217sub read_infodb_rawentry 
     218{ 
     219  my $infodb_type = shift(@_); 
     220  my $infodb_file_path = shift(@_); 
     221  my $infodb_key = shift(@_); 
     222 
     223     
     224  # !! TEMPORARY: Slow and naive implementation that just reads the entire file and picks out the one value 
     225  # !! This will soon be replaced with database-specific versions that will use dbget etc. 
     226  my $infodb_map = {}; 
     227  &read_infodb_file($infodb_type, $infodb_file_path, $infodb_map); 
     228   
     229  return $infodb_map->{$infodb_key};  
     230} 
     231 
    216232 
    217233sub read_infodb_entry 
     
    248264   
    249265   
    250    
    251   # !! TEMPORARY: Slow and naive implementation that just reads the entire file and picks out the one value 
    252   # !! This will soon be replaced with database-specific versions that will use dbget etc. 
    253   my $infodb_map = {}; 
    254   &read_infodb_file($infodb_type, $infodb_file_path, $infodb_map); 
    255    
    256   my $infodb_rec = &dbutil::convert_infodb_string_to_hash($infodb_map->{$infodb_key});  
     266  # rawentry above is currently naive implementation 
     267  my $raw_string = read_infodb_rawentry($infodb_type, $infodb_file_path, $infodb_key); 
     268  my $infodb_rec = &dbutil::convert_infodb_string_to_hash($raw_string);  
    257269   
    258270  return $infodb_rec; 
  • main/trunk/greenstone2/perllib/doc.pm

    r23413 r23485  
    283283    } 
    284284    } 
     285 
     286    if (!&util::filename_is_absolute($filename)) { 
     287    $filename = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},$filename); 
     288    } 
     289 
    285290    return $filename; 
    286291} 
     
    410415 
    411416    if ($use_hash_oid) { 
    412         my $hash_on_file = 1; 
     417        my $hash_on_file = 0; 
    413418        if ($self->{'OIDtype'} eq "hash_on_ga_xml") { 
    414419        $hash_on_file = 0; 
  • main/trunk/greenstone2/perllib/inexport.pm

    r23402 r23485  
    944944        # is it modified?? 
    945945        if (-M $full_curr_file < $archiveinf_timestamp) { 
    946             print STDERR "*** Detected a modified metadata file: $full_curr_file\n" if $verbosity > 2; 
     946            print STDERR "*** Detected a *modified metadata* file: $full_curr_file\n" if $verbosity >= 2; 
    947947            # its newer than last build 
    948948            $block_hash->{'new_or_modified_metadata_files'}->{$full_curr_file} = 1; 
     
    974974        # Greenstone to always be this) 
    975975 
    976         print STDERR "***** Detected new metadata file: $full_curr_file\n" if $verbosity > 2; 
     976        print STDERR "*** Detected *new* metadata file: $full_curr_file\n" if $verbosity >= 2; 
    977977        $block_hash->{'new_or_modified_metadata_files'}->{$full_curr_file} = 1; 
    978978        } 
     
    10121012     
    10131013        if ($existing_f =~ m/^$situated_dir/) { 
     1014 
     1015        print STDERR "**** Existing file $existing_f\nis located within\n$situated_dir\n"; 
     1016 
    10141017        push(@$reindex_files,$existing_f); 
    10151018        $block_hash->{'reindex_files'}->{$existing_f} = 1; 
     
    11071110    # that this file is used in (note in most cases, it's just one OID) 
    11081111     
    1109     my $src_rec_string = &dbutil::read_infodb_entry($infodbtype, $arcinfo_src_filename, $file); 
    1110     my $src_rec = &dbutil::convert_infodb_string_to_hash($src_rec_string); 
     1112    my $src_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_src_filename, $file); 
    11111113    my $oids = $src_rec->{'oid'}; 
    11121114    my $file_record_deleted = 0; 
     
    11211123 
    11221124        # find the source doc (the primary file that becomes this oid) 
    1123         my $doc_rec_string = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $oid); 
    1124         my $doc_rec = &dbutil::convert_infodb_string_to_hash($doc_rec_string); 
     1125        my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $oid); 
    11251126        my $doc_source_file = $doc_rec->{'src-file'}->[0]; 
    11261127        if (!&util::filename_is_absolute($doc_source_file)) { 
     
    11421143        # mark oid for deletion (it will be deleted or reimported) 
    11431144        $archive_info->set_status_info($oid,"D"); 
    1144         my $val = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $oid); 
     1145        my $val = &dbutil::read_infodb_rawentry($infodbtype, $arcinfo_doc_filename, $oid); 
    11451146        $val =~ s/^<index-status>(.*)$/<index-status>D/m; 
    11461147 
  • main/trunk/greenstone2/perllib/manifest.pm

    r22731 r23485  
    185185        my $arcinfo_doc_filename = $self->{'_arcinfo-doc-filename'}; 
    186186         
    187         my $doc_rec_string = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $oid); 
    188  
    189         my $doc_rec = &dbutil::convert_infodb_string_to_hash($doc_rec_string); 
     187        my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $oid); 
    190188         
    191189        my $doc_source_file = $doc_rec->{'src-file'}->[0]; 
  • main/trunk/greenstone2/perllib/plugin.pm

    r23212 r23485  
    232232    # that this file is used in (note in most cases, it's just one OID) 
    233233     
    234     my $src_rec_string = &dbutil::read_infodb_entry($infodbtype, $arcinfo_src_filename, $file); 
    235     my $src_rec = &dbutil::convert_infodb_string_to_hash($src_rec_string); 
     234    my $src_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_src_filename, $file); 
    236235    my $oids = $src_rec->{'oid'}; 
    237236    my $rv;