Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
422e390a
Commit
422e390a
authored
21 years ago
by
Arne Stabenau
Browse files
Options
Downloads
Patches
Plain Diff
Use cahching for all values.
Added get_max_assembly_contig for optimized queries on assembly table.
parent
b802ac29
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/Bio/EnsEMBL/DBSQL/MetaContainer.pm
+32
-46
32 additions, 46 deletions
modules/Bio/EnsEMBL/DBSQL/MetaContainer.pm
with
32 additions
and
46 deletions
modules/Bio/EnsEMBL/DBSQL/MetaContainer.pm
+
32
−
46
View file @
422e390a
...
...
@@ -65,6 +65,11 @@ sub list_value_by_key {
my
(
$self
,
$key
)
=
@_
;
my
@result
;
$self
->
{'
cache
'}
||=
{};
if
(
exists
$self
->
{'
cache
'}
->
{
$key
}
)
{
return
$self
->
{'
cache
'}
->
{
$key
};
}
my
$sth
=
$self
->
prepare
(
"
SELECT meta_value
FROM meta
WHERE meta_key = ? ORDER BY meta_id
"
);
...
...
@@ -72,7 +77,8 @@ sub list_value_by_key {
while
(
my
$arrRef
=
$sth
->
fetchrow_arrayref
()
)
{
push
(
@result
,
$arrRef
->
[
0
]
);
}
$self
->
{'
cache
'}
->
{
$key
}
=
\
@result
;
return
\
@result
;
}
...
...
@@ -98,29 +104,11 @@ sub store_key_value {
VALUES( ?, ? )
"
);
my
$res
=
$sth
->
execute
(
$key
,
$value
);
return
;
}
=head2 update_key_value
Arg [1] : string $key
a key under which $value should be updated
Arg [2] : string $value
the value to update in the meta table
Example : $meta_container->update_key_value($key, $value);
Description: update a value in the meta container, accessable by a key
Returntype : none
Exceptions : none
Caller : ?
=cut
sub
update_key_value
{
my
(
$self
,
$key
,
$value
)
=
@_
;
$self
->
{'
cache
'}
||=
{};
my
$sth
=
$self
->
prepare
(
"
UPDATE meta SET meta_value = ? WHERE meta_key = ?
"
)
;
delete
$self
->
{'
cache
'}
->
{
$key
}
;
my
$res
=
$sth
->
execute
(
$value
,
$key
);
return
;
}
...
...
@@ -142,12 +130,9 @@ sub update_key_value {
sub
get_Species
{
my
$self
=
shift
;
my
$sth
=
$self
->
prepare
(
"
SELECT meta_value
FROM meta
WHERE meta_key = 'species.common_name'
"
);
$sth
->
execute
;
my
$arrRef
=
$self
->
list_value_by_key
(
'
species.common_name
'
);
my
$common_name
;
if
(
my
$arrRef
=
$sth
->
fetchrow_arrayref
()
)
{
if
(
@
$arrRef
)
{
$common_name
=
$arrRef
->
[
0
];
}
else
{
return
undef
;
...
...
@@ -179,22 +164,15 @@ sub get_Species {
sub
get_taxonomy_id
{
my
$self
=
shift
;
my
$arrRef
=
$self
->
list_value_by_key
(
'
species.taxonomy_id
'
);
if
(
!
defined
$self
->
{'
_taxonomy_id
'}
)
{
my
$sth
=
$self
->
prepare
(
"
SELECT meta_value
FROM meta
WHERE meta_key = 'species.taxonomy_id'
"
);
$sth
->
execute
();
my
(
$tax
)
=
$sth
->
fetchrow_array
();
if
(
!
defined
$tax
)
{
$self
->
warn
("
Please insert meta_key 'species.taxonomy_id'
"
.
"
in meta table at core db.
\n
");
}
$self
->
{'
_taxonomy_id
'}
=
$tax
;
if
(
@$arrRef
)
{
return
$arrRef
->
[
0
];
}
else
{
$self
->
warn
("
Please insert meta_key 'species.taxonomy_id'
"
.
"
in meta table at core db.
\n
");
}
return
$self
->
{'
_taxonomy_id
'};
}
...
...
@@ -213,18 +191,26 @@ sub get_taxonomy_id {
sub
get_default_assembly
{
my
$self
=
shift
;
my
$sth
=
$self
->
prepare
(
"
SELECT meta_value
FROM meta
WHERE meta_key = 'assembly.default'
"
);
$sth
->
execute
;
if
(
my
$arrRef
=
$sth
->
fetchrow_arrayref
()
)
{
my
$arrRef
=
$self
->
list_value_by_key
('
assembly.default
'
);
if
(
@$arrRef
)
{
return
$arrRef
->
[
0
];
}
else
{
return
undef
;
}
}
sub
get_max_assembly_contig
{
my
$self
=
shift
;
my
$value_list
=
$self
->
list_value_by_key
(
"
assembly.maxcontig
"
);
if
(
@$value_list
)
{
return
$value_list
->
[
0
];
}
else
{
return
undef
;
}
}
1
;
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment