Changeset 561

Show
Ignore:
Timestamp:
02/18/05 10:51:22 (4 years ago)
Author:
torben
Message:

Added a DropIndex? call to the system. Untested yet, I need it in CVS to
transport it to another host.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/external-tools/indexer-backends/plucene/Midcom/Indexer/XMLComm.pm

    r531 r561  
    9494 
    9595 
    96 # Parsed dem im ersten Argument übergebenen XML-String und populiert die 
     96# Parsed dem im ersten Argument ᅵbergebenen XML-String und populiert die 
    9797# Requests Liste. 
    9898# 
     
    138138                { 
    139139                        $self->_ParseDelete($node); 
     140                } 
     141                elsif ($node->nodeName eq 'deleteall') 
     142                { 
     143                        $self->_ParseDeleteAll($node); 
    140144                } 
    141145                elsif ($node->nodeName eq 'auth') 
     
    226230 
    227231 
     232sub _ParseDeleteAll 
     233{ 
     234        my ($self, $node) = @_; 
     235         
     236        my $request = Midcom::Plucene::DeleteRequest->new($self); 
     237 
     238        $request->id($node->getAttribute('id')); 
     239        $request->deleteAll(1); 
     240 
     241        # $request->dump; 
     242        $request->execute(); 
     243} 
     244 
     245 
    228246sub _ParseIndex 
    229247{ 
  • trunk/external-tools/indexer-backends/plucene/Midcom/Plucene/DeleteRequest.pm

    r436 r561  
    3131Unless a critical error occures, on data is appended to the XMLReader. 
    3232 
     33This class can also delete a complete index (if and only if deleteAll has been 
     34set to nonzero), in that case it will just recreate the index in place. 
     35 
    3336=head1 METHODS 
    3437 
     
    5053        $self->type('delete'); 
    5154        $self->{_documentID} = undef; 
     55        $self->{_deleteAll} = 0; 
    5256 
    5357        bless ($self, $class); 
     
    6569} 
    6670 
     71sub deleteAll 
     72{ 
     73        my $self = shift; 
     74        if (@_) { $self->{_deleteAll} = shift; } 
     75        return $self->{_deleteAll}; 
     76} 
     77 
    6778 
    6879################# 
     
    7586        my $self = shift; 
    7687 
    77         my $term = Plucene::Index::Term->new( 
    78                 { 
    79                         field => '__RI', 
    80                         text => $self->{_documentID} 
    81                 } 
    82         ); 
    83         $self->{_processor}->indexReader->delete_term($term); 
    84          
    85         # Tag the Writer object, so that it gets loaded from the request 
    86         # processor. This is will optimize the database after completing 
    87         # the current batch thus dropping all unused references to the 
    88         # deleted documents. I hate it. 
    89         $self->{_processor}->indexWriter(); 
     88        if ($self->{_deleteAll} == 1) 
     89        { 
     90                # Tell the request processor to drop the existing index. 
     91                $self->{_processor}->DropIndex(); 
     92        } 
     93        else 
     94        { 
     95                my $term = Plucene::Index::Term->new( 
     96                        { 
     97                                field => '__RI', 
     98                                text => $self->{_documentID} 
     99                        } 
     100                ); 
     101                $self->{_processor}->indexReader->delete_term($term); 
     102                 
     103                # Tag the Writer object, so that it gets loaded from the request 
     104                # processor. This is will optimize the database after completing 
     105                # the current batch thus dropping all unused references to the 
     106                # deleted documents. I hate it. 
     107                $self->{_processor}->indexWriter(); 
     108        } 
    90109} 
    91110 
  • trunk/external-tools/indexer-backends/plucene/Midcom/Plucene/RequestProcessor.pm

    r437 r561  
    133133} 
    134134 
     135sub DropIndex 
     136{ 
     137        my $self = shift; 
     138         
     139        # Close all open handels, then recreate the index. 
     140        # 
     141        # Note, that this is not really protected against multiple simultaneous accesses. 
     142        # You should avoid any indexing operation from other processes while dropping the 
     143        # Index. 
     144         
     145        $self->close(); 
     146         
     147        $self->{_indexWriter} = Plucene::Index::Writer->new( 
     148                $self->{_xmlComm}->indexName(), 
     149                Plucene::Analysis::SimpleAnalyzer->new(), 
     150                1 
     151        ); 
     152} 
     153 
    135154 
    136155 
  • trunk/external-tools/indexer-backends/xml-communication-request.dtd

    r430 r561  
    3535<!ATTLIST delete documentid CDATA #REQUIRED> 
    3636 
     37<!ELEMENT deleteall EMPTY> 
     38<!ATTLIST deleteall id CDATA #REQUIRED> 
    3739