[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.66, Thu Jul 13 04:53:54 2006 UTC revision 1.67, Fri Jul 14 01:36:29 2006 UTC
# Line 3250  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 3278  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 3287  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.

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3