[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.1, Tue Sep 30 15:23:55 2008 UTC revision 1.2, Thu Oct 9 17:23:54 2008 UTC
# Line 57  Line 57 
57  Reference to the descriptor for this table's relation in the ERDB database  Reference to the descriptor for this table's relation in the ERDB database
58  object.  object.
59    
60    =item stats
61    
62    Statistics object for recording events.
63    
64  =item table  =item table
65    
66  Name of the relation table being loaded.  Name of the relation table being loaded.
# Line 67  Line 71 
71    
72  =head3 new  =head3 new
73    
74      my $erdbload = ERDBGenerate->new($erdb, $directory, $table, $section);      my $erdbload = ERDBGenerate->new($erdb, $directory, $table, $stats);
75    
76  Create an ERDB Table Load Utility object for a specified table. Note that  Create an ERDB Table Load Utility object for a specified table. Note that
77  when generating a table, the section ID is required, but for collating  when generating a table, the section ID is required, but for collating
# Line 87  Line 91 
91    
92  Name of the table being loaded.  Name of the table being loaded.
93    
94  =item section  =item stats
95    
96  ID of the current section.  Statistics object for recording events.
97    
98  =back  =back
99    
# Line 97  Line 101 
101    
102  sub new {  sub new {
103      # Get the parameters.      # Get the parameters.
104      my ($class, $db, $directory, $table) = @_;      my ($class, $erdb, $directory, $table, $stats) = @_;
105      # Ask the database for the relation's descriptor.      # Ask the database for the relation's descriptor.
106      my $relation = $db->FindRelation($table);      my $relation = $erdb->FindRelation($table);
107      Confess("Invalid table name \"$table\".") if (! defined $relation);      Confess("Invalid table name \"$table\".") if (! defined $relation);
108      # Create the new object.      # Create the new object.
109      my $retVal = {      my $retVal = {
110          directory => $directory,          directory => $directory,
111          erdb => $db,          erdb => $erdb,
112          fh => undef,          fh => undef,
113          fileName => undef,          fileName => undef,
114          relation => $relation,          relation => $relation,
115            stats => $stats,
116          table => $table,          table => $table,
117      };      };
118      # Is this relation the primary relation of an entity?      # Is this relation the primary relation of an entity?
119      if ($db->IsEntity($table)) {      if ($erdb->IsEntity($table)) {
120          # Yes. Create a duplicate-check hash. We don't create an empty          # Yes. Create a duplicate-check hash. We don't create an empty
121          # hash unless it's needed, because the method that checks for          # hash unless it's needed, because the method that checks for
122          # the hash uses "exists".          # the hash uses "exists".
# Line 218  Line 223 
223              }              }
224              # Push the value into the result list.              # Push the value into the result list.
225              push @values, $value;              push @values, $value;
226                Trace("Field $field->{name} in $self->{table} has value \"$value\".") if T(4);
227              # Record its length.              # Record its length.
228              $retVal += length("$value");              $retVal += length("$value");
229          }          }
230            # Fix and verify the field values.
231            my $truncates = $self->{erdb}->VerifyFields($self->{table}, \@values);
232            # Record any field truncation events.
233            $self->{stats}->Add(truncations => $truncates) if $truncates;
234          # Write the record.          # Write the record.
235          Tracer::PutLine($oh, \@values);          Tracer::PutLine($oh, \@values);
236      }      }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3