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

Diff of /Sprout/ERDB.pm

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

revision 1.60, Sun Jul 9 21:16:12 2006 UTC revision 1.67, Fri Jul 14 01:36:29 2006 UTC
# Line 1436  Line 1436 
1436  sub GetCount {  sub GetCount {
1437      # Get the parameters.      # Get the parameters.
1438      my ($self, $objectNames, $filter, $params) = @_;      my ($self, $objectNames, $filter, $params) = @_;
1439        # Insure the params argument is an array reference if the caller left it off.
1440        if (! defined($params)) {
1441            $params = [];
1442        }
1443      # Declare the return variable.      # Declare the return variable.
1444      my $retVal;      my $retVal;
1445      # Find out if we're counting an entity or a relationship.      # Find out if we're counting an entity or a relationship.
# Line 1838  Line 1842 
1842          }          }
1843      }      }
1844      # Analyze the table to improve performance.      # Analyze the table to improve performance.
1845        Trace("Analyzing and compacting $relationName.") if T(3);
1846      $dbh->vacuum_it($relationName);      $dbh->vacuum_it($relationName);
1847      # Flush the database cache.      Trace("$relationName load completed.") if T(3);
     $dbh->flush_tables();  
1848      # Return the statistics.      # Return the statistics.
1849      return $retVal;      return $retVal;
1850  }  }
# Line 3246  Line 3250 
3250  relation when creating the load file.  relation when creating the load file.
3251    
3252  For example, if the load file should be sorted ascending by the first  For example, if the load file should be sorted ascending by the first
3253  field with duplicates removed, this method would return  field, this method would return
3254    
3255      sort -k 1 -u -t "\t"      sort -k1 -t"\t"
3256    
3257  If the first field is numeric and duplicates are okay, the method would  If the first field is numeric, the method would return
 return  
3258    
3259      sort -k 1n -t "\t"      sort -k 1n -t "\t"
3260    
3261    Unfortunately, due to a bug in the C<sort> command, we cannot eliminate duplicate
3262    keys using a sort.
3263    
3264  =over 4  =over 4
3265    
3266  =item relationName  =item relationName
# Line 3274  Line 3280 
3280      my ($self, $relationName) = @_;      my ($self, $relationName) = @_;
3281      # Declare a descriptor to hold the names of the key fields.      # Declare a descriptor to hold the names of the key fields.
3282      my @keyNames = ();      my @keyNames = ();
     # Declare a flag for indicating uniqueness.  
     my $unique;  
3283      # Get the relation structure.      # Get the relation structure.
3284      my $relationData = $self->_FindRelation($relationName);      my $relationData = $self->_FindRelation($relationName);
3285      # Find out if the relation is a primary entity relation,      # Find out if the relation is a primary entity relation,
# Line 3283  Line 3287 
3287      my $entityTable = $self->{_metaData}->{Entities};      my $entityTable = $self->{_metaData}->{Entities};
3288      my $relationshipTable = $self->{_metaData}->{Relationships};      my $relationshipTable = $self->{_metaData}->{Relationships};
3289      if (exists $entityTable->{$relationName}) {      if (exists $entityTable->{$relationName}) {
3290          # Here we have a primary entity relation, so we have a unique sort on the          # Here we have a primary entity relation.
         # ID field.  
         $unique = "-u ";  
3291          push @keyNames, "id";          push @keyNames, "id";
3292      } elsif (exists $relationshipTable->{$relationName}) {      } elsif (exists $relationshipTable->{$relationName}) {
3293          # Here we have a relationship. We sort using the FROM index.          # Here we have a relationship. We sort using the FROM index.
         $unique = "";  
3294          my $relationshipData = $relationshipTable->{$relationName};          my $relationshipData = $relationshipTable->{$relationName};
3295          my $index = $relationData->{Indexes}->{"idx${relationName}From"};          my $index = $relationData->{Indexes}->{"idx${relationName}From"};
3296          push @keyNames, @{$index->{IndexFields}};          push @keyNames, @{$index->{IndexFields}};
3297      } else {      } else {
3298          # Here we have a secondary entity relation, so we have a non-unique sort on          # Here we have a secondary entity relation, so we have a sort on the ID field.
         # the ID field.  
         $unique = "";  
3299          push @keyNames, "id";          push @keyNames, "id";
3300      }      }
3301      # Now we parse the key names into sort parameters. First, we prime the return      # Now we parse the key names into sort parameters. First, we prime the return
3302      # string.      # string.
3303      my $retVal = "sort -t \"\t\" $unique";      my $retVal = "sort -t\"\t\" ";
3304      # Get the relation's field list.      # Get the relation's field list.
3305      my @fields = @{$relationData->{Fields}};      my @fields = @{$relationData->{Fields}};
3306      # Loop through the keys.      # Loop through the keys.
# Line 3328  Line 3327 
3327                      $modifier .= "r";                      $modifier .= "r";
3328                  }                  }
3329                  # Store the position and modifier into the field spec, which                  # Store the position and modifier into the field spec, which
3330                  # will stop the inner loop.                  # will stop the inner loop. Note that the field number is
3331                  $fieldSpec = "$i$modifier";                  # 1-based in the sort command, so we have to increment the
3332                    # index.
3333                    $fieldSpec = ($i + 1) . $modifier;
3334              }              }
3335          }          }
3336          # Add this field to the sort command.          # Add this field to the sort command.

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.67

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3