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

Diff of /Sprout/ERDBGenerate.pm

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

revision 1.3, Mon Jan 19 21:46:21 2009 UTC revision 1.4, Thu Apr 2 01:35:54 2009 UTC
# Line 33  Line 33 
33    
34  Directory into which load files should be placed.  Directory into which load files should be placed.
35    
 =item dupHash  
   
 Hash of IDs already seen for this table. This hash is only created if the table  
 is the primary relation of an entity. Removing duplicate IDs is not strictly necessary,  
 but it saves disk space and avoids unnecessary I/O, which makes us a bit faster.  
   
36  =item erdb  =item erdb
37    
38  [[ErdbPm]] object used to create and access the database. This will usually  [[ErdbPm]] object used to create and access the database. This will usually
# Line 115  Line 109 
109          stats => $stats,          stats => $stats,
110          table => $table,          table => $table,
111      };      };
     # Is this relation the primary relation of an entity?  
     if ($erdb->IsEntity($table)) {  
         # Yes. Create a duplicate-check hash. We don't create an empty  
         # hash unless it's needed, because the method that checks for  
         # the hash uses "exists".  
         $retVal->{dupHash} = {};  
     }  
112      # Bless and return the result.      # Bless and return the result.
113      bless $retVal, $class;      bless $retVal, $class;
114      return $retVal;      return $retVal;
# Line 199  Line 186 
186      # Insure we have an output file to which we can write.      # Insure we have an output file to which we can write.
187      my $oh = $self->{fh};      my $oh = $self->{fh};
188      Confess("Put before Start for $self->{table}.") if ! defined $oh;      Confess("Put before Start for $self->{table}.") if ! defined $oh;
     # Before we try to output this record, see if it's a duplicate. This is only  
     # possible if the duplicate-key hash exists and we have an ID.  
     my $duplicate;  
     if (exists $self->{dupHash} && $putFields{id}) {  
         # Okay, here we can make the check. If the ID has already been  
         # seen, this statement will set $duplicate to a nonzero value.  
         # Otherwise, it will be undefined.  
         $duplicate = $self->{dupHash}->{$putFields{id}}++;  
     }  
     # Only proceed if we're NOT a duplicate.  
     if (! $duplicate) {  
189          # We'll create an ordered list of field values in here.          # We'll create an ordered list of field values in here.
190          my @values;          my @values;
191          # Loop through the relation's fields.          # Loop through the relation's fields.
# Line 243  Line 219 
219          $erdb->DigestFields($self->{table}, \@values);          $erdb->DigestFields($self->{table}, \@values);
220          # Write the record.          # Write the record.
221          Tracer::PutLine($oh, \@values);          Tracer::PutLine($oh, \@values);
     }  
222      # Return the record length.      # Return the record length.
223      return $retVal;      return $retVal;
224  }  }
# Line 439  Line 414 
414  sub GetLoadFiles {  sub GetLoadFiles {
415      # Get the parameters.      # Get the parameters.
416      my ($directory) = @_;      my ($directory) = @_;
417        Trace("GetLoadFiles called for $directory.") if T(3);
418      # Get matching file names from the specified directory.      # Get matching file names from the specified directory.
419      my @retVal = grep { $_ =~ /\w+(-.+)?\.dt(x|y|z)$/ } Tracer::OpenDir($directory);      my @retVal = grep { $_ =~ /\.dt[xyz]$/ } Tracer::OpenDir($directory);
420      # Return the result.      # Return the result.
421      return @retVal;      return @retVal;
422  }  }
# Line 499  Line 475 
475      # Close the file handle if it's open.      # Close the file handle if it's open.
476      my $oh = $self->{fh};      my $oh = $self->{fh};
477      close $oh if defined $oh;      close $oh if defined $oh;
     # Clear the duplicate-key hash if we have one. We are careful here to  
     # insure that we don't create a new one by accident. The existence of  
     # a dupHash determines whether or not we need to make the duplicate-key  
     # check.  
     if (exists $self->{dupHash}) {  
         $self->{dupHash} = {};  
     }  
478      # Denote we're no longer inside a section.      # Denote we're no longer inside a section.
479      for my $field (qw(fh fileName section)) {      for my $field (qw(fh fileName)) {
480          $self->{$field} = undef;          $self->{$field} = undef;
481      }      }
482      # Return the result.      # Return the result.

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3