Changeset 4743


Ignore:
Timestamp:
2003-06-20T14:09:21+12:00 (21 years ago)
Author:
sjboddie
Message:

Build code changes allowing mg collections containing no indexes to
be built (it in fact builds a small "dummy:text" index if none are
specified since we need an index for the runtime code to be able to
retrieve the compressed text).

Location:
trunk/gsdl/perllib
Files:
2 edited

Legend:

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

    r4192 r4743  
    118118    }
    119119
    120     # make sure that the same index isn't specified more than once
    121     my %tmphash = ();
    122     my @tmparray = @{$self->{'collect_cfg'}->{'indexes'}};
    123     $self->{'collect_cfg'}->{'indexes'} = [];
    124     foreach my $i (@tmparray) {
    125     if (!defined ($tmphash{$i})) {
    126         push (@{$self->{'collect_cfg'}->{'indexes'}}, $i);
    127         $tmphash{$i} = 1;
    128     }
     120    if (defined($self->{'collect_cfg'}->{'indexes'})) {
     121    # make sure that the same index isn't specified more than once
     122    my %tmphash = ();
     123    my @tmparray = @{$self->{'collect_cfg'}->{'indexes'}};
     124    $self->{'collect_cfg'}->{'indexes'} = [];
     125    foreach my $i (@tmparray) {
     126        if (!defined ($tmphash{$i})) {
     127        push (@{$self->{'collect_cfg'}->{'indexes'}}, $i);
     128        $tmphash{$i} = 1;
     129        }
     130    }
     131    } else {
     132    $self->{'collect_cfg'}->{'indexes'} = [];
     133    }
     134
     135    if (scalar(@{$self->{'collect_cfg'}->{'indexes'}}) == 0) {
     136    # no indexes have been specified so we'll build a "dummy:text" index
     137    push (@{$self->{'collect_cfg'}->{'indexes'}}, "dummy:text");   
    129138    }
    130139
  • trunk/gsdl/perllib/mgbuildproc.pm

    r3834 r4743  
    475475        if (!($real_field =~ s/^top//) || ($doc_section == 1)) {
    476476            my $new_text = "";
    477             if ($real_field eq "text") {
     477            if ($level eq "dummy") {
     478            # a dummy index is a special case used when no
     479            # indexes are specified (since there must always be
     480            # at least one index or we can't retrieve the
     481            # compressed text) - we add a small amount of text
     482            # to these dummy indexes which will never be seen
     483            # but will overcome mg's problems with building
     484            # empty indexes
     485            $new_text = "this is dummy text to stop mg barfing";
     486            $self->{'num_processed_bytes'} += length ($new_text);
     487
     488            } elsif ($real_field eq "text") {
    478489            $new_text = $doc_obj->get_text ($section) if $self->{'store_text'};
    479490            $self->{'num_processed_bytes'} += length ($new_text);
Note: See TracChangeset for help on using the changeset viewer.