Skip to content

Commit

Permalink
enable overflow for accu keys, to_analysis_urls, and submission_cmd_args
Browse files Browse the repository at this point in the history
  • Loading branch information
ens-bwalts committed Jan 21, 2019
1 parent eb200cb commit abf8ff5
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
29 changes: 29 additions & 0 deletions modules/Bio/EnsEMBL/Hive/DBSQL/AccumulatorAdaptor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ sub default_table_name {
}


sub slicer { # take a slice of the hashref (if only we could inline in Perl!)
my ($self, $hashref, $fields) = @_;

my $overflow_limit = $self->overflow_limit();

return [ map { eval { my $value = $hashref->{$_};
my $ol = $overflow_limit->{$_};
if (defined($ol) and defined($value) and (length($value) > $ol)) {
$self->db->get_AnalysisDataAdaptor()->store_if_needed($value);
} else {
$value;
}
}


} @$fields ];
}

sub overflow_limit {
return {
'key_signature' => 255,
'struct_name' => 255,
};
}


sub fetch_structures_for_job_ids {
my ($self, $job_ids_csv, $id_scale, $id_offset) = @_;
$id_scale ||= 1;
Expand All @@ -63,6 +89,9 @@ sub fetch_structures_for_job_ids {

ROW: while(my ($receiving_job_id, $struct_name, $key_signature, $stringified_value) = $sth->fetchrow_array() ) {

($key_signature, $struct_name) = map {$self->check_and_dereference_analysis_data($_)}
($key_signature, $struct_name);

my $value = destringify($stringified_value);

my $sptr = \$structures{$receiving_job_id * $id_scale + $id_offset}{$struct_name};
Expand Down
25 changes: 25 additions & 0 deletions modules/Bio/EnsEMBL/Hive/DBSQL/BaseAdaptor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,31 @@ sub store {
}


=head2 check_and_dereference_analysis_data
Arg [1] : string data that may reference an analysis_data_id
Usage : my $value = $self->check_and_dereference_analysis_data($$fetched_row[0])
Description : Checks to see if the passed value matches the regular expression
: /^_ext(?:\w+)_data_id (\d+)$/ (e.g. "external_data_id 3", pointer to an analysis_data_id).
: If so, it returns the entry from the "data" column in analysis_data from the
: row containing the given analysis_data_id.
: If not, it returns the passed parameter unchanged.
Returntype : string
=cut

sub check_and_dereference_analysis_data {
my $self = shift @_;
my $possible_analysis_data_id_ref = shift @_;

if ($possible_analysis_data_id_ref =~ /^_ext(?:\w+)_data_id (\d+)$/) {
return $self->db->get_AnalysisDataAdaptor->fetch_by_analysis_data_id_TO_data($1);
} else {
return $possible_analysis_data_id_ref;
}
}


sub DESTROY { } # to simplify AUTOLOAD

sub AUTOLOAD {
Expand Down
7 changes: 7 additions & 0 deletions modules/Bio/EnsEMBL/Hive/DBSQL/DataflowRuleAdaptor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ sub default_insertion_method {
}


sub overflow_limit {
return {
'to_analysis_url' => 255,
};
}


sub object_class {
return 'Bio::EnsEMBL::Hive::DataflowRule';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/Bio/EnsEMBL/Hive/DBSQL/ObjectAdaptor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ sub slicer { # take a slice of the object (if only we could inline in Perl!)
? $object->dbID()
: eval { my $value = $object->$_();
my $ol = $overflow_limit->{$_};
(defined($ol) and length($value)>$ol)
(defined($ol) and defined($value) and length($value)>$ol)
? $self->db->get_AnalysisDataAdaptor()->store_if_needed( $value )
: $value
}
Expand Down
7 changes: 7 additions & 0 deletions modules/Bio/EnsEMBL/Hive/DBSQL/ResourceDescriptionAdaptor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ sub default_insertion_method {
}


sub overflow_limit {
return {
'submission_cmd_args' => 255,
};
}


sub object_class {
return 'Bio::EnsEMBL::Hive::ResourceDescription';
}
Expand Down

0 comments on commit abf8ff5

Please sign in to comment.