Skip to content
Snippets Groups Projects
Commit f7182485 authored by Jessica Severin's avatar Jessica Severin
Browse files

Second insert into analysis_data for job_creation added extra overhead.

Removed select before store (made new method store_if_needed if that functionality is required by users)
and added option in AnalysisJobAdaptor::CreateNewJob to pass input_analysis_data_id
so if already know the CreateNewJob will be as fast as before.  Plus there are no limits on the
size of the input_id string.
parent d642eb3c
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,6 @@ sub fetch_by_dbID {
return $data;
}
#
# STORE METHODS
#
......@@ -66,6 +65,21 @@ sub store {
my ($self, $data) = @_;
my $data_id;
return 0 unless($data);
my $sth2 = $self->prepare("INSERT INTO analysis_data (data) VALUES (?)");
$sth2->execute($data);
$data_id = $sth2->{'mysql_insertid'};
$sth2->finish;
return $data_id;
}
sub store_if_needed {
my ($self, $data) = @_;
my $data_id;
return 0 unless($data);
my $sth = $self->prepare("SELECT analysis_data_id FROM analysis_data WHERE data = ?");
......@@ -78,15 +92,9 @@ sub store {
return $data_id;
}
my $sth2 = $self->prepare("INSERT INTO analysis_data (data) VALUES (?)");
$sth2->execute($data);
$data_id = $sth2->{'mysql_insertid'};
$sth2->finish;
return $data_id;
return $self->store($data);
}
1;
......
......@@ -63,11 +63,11 @@ sub CreateNewJob {
return undef unless(scalar @args);
my ($input_id, $analysis, $prev_analysis_job_id, $blocked) =
rearrange([qw(INPUT_ID ANALYSIS input_job_id BLOCK )], @args);
my ($input_id, $input_analysis_data_id, $analysis, $prev_analysis_job_id, $blocked) =
rearrange([qw(INPUT_ID INPUT_ANALYSIS_DATA_ID ANALYSIS input_job_id BLOCK )], @args);
$prev_analysis_job_id=0 unless($prev_analysis_job_id);
throw("must define input_id") unless($input_id);
throw("must define input_id or input_analysis_data_id") unless($input_id or $input_analysis_data_id);
throw("must define analysis") unless($analysis);
throw("analysis must be [Bio::EnsEMBL::Analysis] not a [$analysis]")
unless($analysis->isa('Bio::EnsEMBL::Analysis'));
......@@ -76,8 +76,10 @@ sub CreateNewJob {
my $dbc = $analysis->adaptor->db->dbc;
my $dataDBA = new Bio::EnsEMBL::Hive::DBSQL::AnalysisDataAdaptor($dbc);
my $input_analysis_data_id = $dataDBA->store($input_id);
unless(defined($input_analysis_data_id)) {
my $dataDBA = $analysis->adaptor->db->get_AnalysisDataAdaptor;
$input_analysis_data_id = $dataDBA->store($input_id);
}
my $sql = "INSERT ignore into analysis_job ".
" SET input_analysis_data_id=\"$input_analysis_data_id\" ".
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment