[Bio] / Sprout / ERDBLoad.pm Repository:
ViewVC logotype

Diff of /Sprout/ERDBLoad.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18, Mon Jul 10 09:06:46 2006 UTC revision 1.22, Tue Aug 12 06:07:06 2008 UTC
# Line 28  Line 28 
28    
29  =head3 new  =head3 new
30    
31  C<< my $erload = ERDBLoad->new($erdb, $relationName, $directory, $loadOnly, $ignore); >>      my $erload = ERDBLoad->new($erdb, $relationName, $directory, $loadOnly, $ignore);
32    
33  Begin loading an ERDB relation.  Begin loading an ERDB relation.
34    
# Line 108  Line 108 
108    
109  =head3 Ignore  =head3 Ignore
110    
111  C<< my $flag = $erload->Ignore; >>      my $flag = $erload->Ignore;
112    
113  Return TRUE if we are ignoring this table, else FALSE.  Return TRUE if we are ignoring this table, else FALSE.
114    
# Line 123  Line 123 
123    
124  =head3 Put  =head3 Put
125    
126  C<< my  = $erload->Put($field1, $field2, ..., $fieldN); >>      my  = $erload->Put($field1, $field2, ..., $fieldN);
127    
128  Write a line of data to the load file. This may also cause the load file to be closed  Write a line of data to the load file. This may also cause the load file to be closed
129  and data read into the table.  and data read into the table.
# Line 151  Line 151 
151          my $truncates = $self->{dbh}->VerifyFields($self->{relName}, \@rawFields);          my $truncates = $self->{dbh}->VerifyFields($self->{relName}, \@rawFields);
152          # Run through the list of field values, escaping them.          # Run through the list of field values, escaping them.
153          my @fields = map { Tracer::Escape($_) } @rawFields;          my @fields = map { Tracer::Escape($_) } @rawFields;
         # If this is a primary relation, append the new-record field.  
         if ($self->{primary}) {  
             push @fields, '0';  
         }  
154          # Form a data line from the fields.          # Form a data line from the fields.
155          my $line = join("\t", @fields) . "\n";          my $line = join("\t", @fields) . "\n";
156          # Write the new record to the load file.          # Write the new record to the load file.
# Line 174  Line 170 
170    
171  =head3 Add  =head3 Add
172    
173  C<< my  = $stats->Add($statName, $value); >>      my  = $stats->Add($statName, $value);
174    
175  Increment the specified statistic.  Increment the specified statistic.
176    
# Line 205  Line 201 
201    
202  =head3 Finish  =head3 Finish
203    
204  C<< my $stats = $erload->Finish(); >>      my $stats = $erload->Finish();
205    
206  Finish loading the table. This closes the load file.  Finish loading the table. This closes the load file.
207    
# Line 231  Line 227 
227      return $self->{stats};      return $self->{stats};
228  }  }
229    
230    =head3 FinishAndLoad
231    
232        my $stats = $erload->FinishAndLoad();
233    
234    Finish the load and load the table, returning the statistics.
235    
236    =cut
237    
238    sub FinishAndLoad {
239        # Get the parameters.
240        my ($self) = @_;
241        # Finish the load file.
242        my $retVal = $self->Finish();
243        # Load the table.
244        my $newStats = $self->LoadTable();
245        # Accumulate the stats.
246        $retVal->Accumulate($newStats);
247        # Return the result.
248        return $retVal;
249    }
250    
251  =head3 RelName  =head3 RelName
252    
253  C<< my $name = $erload->RelName; >>      my $name = $erload->RelName;
254    
255  Name of the relation being loaded by this object.  Name of the relation being loaded by this object.
256    
# Line 246  Line 263 
263      return $self->{relName};      return $self->{relName};
264  }  }
265    
266    =head3 LoadTable
267    
268        my $stats = $erload->LoadTable();
269    
270    Load the database table from the load file and return a statistics object.
271    
272    =cut
273    
274    sub LoadTable {
275        # Get the parameters.
276        my ($self) = @_;
277        # Get the database object, the file name, and the relation name.
278        my $erdb = $self->{dbh};
279        my $fileName = $self->{fileName};
280        my $relName = $self->{relName};
281        # Load the table. The third parameter indicates this is a drop and reload.
282        my $retVal = $erdb->LoadTable($fileName, $relName, truncate => 1);
283        # Return the result.
284        return $retVal;
285    }
286    
287  1;  1;
288    

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.22

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3