[yum-commits] Branch 'yum-3_2_X' - 6 commits - yum/sqlitesack.py
James Antill
james at osuosl.org
Mon Aug 17 18:55:18 UTC 2009
yum/sqlitesack.py | 85 +++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 68 insertions(+), 17 deletions(-)
New commits:
commit 3c7c627bfded1d1b20058a0b425efe24e23e6fe7
Author: James Antill <james at and.org>
Date: Mon Aug 17 12:09:40 2009 -0400
Pass "fields" from _setupPkgObjList to _yieldSQLDataList, so we know
what we are searching for.
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index f4d3f95..3f9dc37 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -1481,12 +1481,12 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
else:
tmp.append((pat, '='))
if not need_full and not need_glob and patterns:
- return (need_full, patterns, True)
+ return (need_full, patterns, fields, True)
patterns = tmp
- return (need_full, patterns, False)
+ return (need_full, patterns, fields, False)
@catchSqliteException
- def _yieldSQLDataList(self, repoid=None, patterns=None, ignore_case=False):
+ def _yieldSQLDataList(self, repoid, patterns, fields, ignore_case):
"""Yields all the package data for the given params. Excludes are done
at this stage. """
@@ -1518,12 +1518,13 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
returnList = []
- (need_full, patterns, names) = self._setupPkgObjList(repoid, patterns,
- ignore_case)
+ data = self._setupPkgObjList(repoid, patterns, ignore_case)
+ (need_full, patterns, fields, names) = data
if names:
return self.searchNames(patterns)
- for (repo, x) in self._yieldSQLDataList(repoid, patterns, ignore_case):
+ for (repo, x) in self._yieldSQLDataList(repoid, patterns, fields,
+ ignore_case):
po = self._packageByKeyData(repo, x['pkgKey'], x)
if po is None:
continue
@@ -1587,9 +1588,10 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
repoid = None
returnList = []
# Haven't loaded everything, so _just_ get the pkgtups...
- (need_full, patterns, names) = self._setupPkgObjList(repoid, patterns,
- ignore_case)
- for (repo, x) in self._yieldSQLDataList(repoid, patterns, ignore_case):
+ data = self._setupPkgObjList(repoid, patterns, ignore_case)
+ (need_full, patterns, fields, names) = data
+ for (repo, x) in self._yieldSQLDataList(repoid, patterns, fields,
+ ignore_case):
# NOTE: Can't unexclude things...
pkgtup = self._pkgtupByKeyData(repo, x['pkgKey'], x)
if pkgtup is None:
commit daab5bd8a7bf33902789e4f032babb2e88ac2f0d
Author: James Antill <james at and.org>
Date: Mon Aug 17 11:28:33 2009 -0400
Add optimized simplePkgList() to sqlitesack, significant speedup:
This is what the above few patches were for, as this function now just
calls them.
Speed differences on my machine:
time (echo | yum update wodim)
Before: 8.0 seconds
After: 6.5 seconds (81.25%)
time yum check-update
Before: 3.9 seconds
After: 2.5 seconds (64.10%)
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 1edf2ab..f4d3f95 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -1448,7 +1448,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
return exactmatch, matched, unmatched
def _setupPkgObjList(self, repoid=None, patterns=None, ignore_case=False):
- """Setup need_full and patterns for _buildPkgObjList, also see if
+ """Setup need_full and patterns for _yieldSQLDataList, also see if
we can get away with just using searchNames(). """
if patterns is None:
@@ -1572,6 +1572,31 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
return returnList
+ def simplePkgList(self, patterns=None, ignore_case=False):
+ """Returns a list of pkg tuples (n, a, e, v, r), optionally from a
+ single repoid. """
+
+ if self._skip_all():
+ return []
+
+ internal_pkgoblist = hasattr(self, 'pkgobjlist')
+ if internal_pkgoblist:
+ return yumRepo.YumPackageSack.simplePkgList(self, patterns,
+ ignore_case)
+
+ repoid = None
+ returnList = []
+ # Haven't loaded everything, so _just_ get the pkgtups...
+ (need_full, patterns, names) = self._setupPkgObjList(repoid, patterns,
+ ignore_case)
+ for (repo, x) in self._yieldSQLDataList(repoid, patterns, ignore_case):
+ # NOTE: Can't unexclude things...
+ pkgtup = self._pkgtupByKeyData(repo, x['pkgKey'], x)
+ if pkgtup is None:
+ continue
+ returnList.append(pkgtup)
+ return returnList
+
@catchSqliteException
def searchNevra(self, name=None, epoch=None, ver=None, rel=None, arch=None):
"""return list of pkgobjects matching the nevra requested"""
commit 443a2f42d33413828ab7a0643b015c3b1377d7b9
Author: James Antill <james at and.org>
Date: Mon Aug 17 11:09:46 2009 -0400
Add pkgtupByKeyData, so we don't have to create package objects
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 4d8ac0a..1edf2ab 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -725,6 +725,19 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
pkgkeys.append(pkgKey)
return self._key2pkg[repo][data['pkgKey']]
+ def _pkgtupByKeyData(self, repo, pkgKey, data):
+ """ Like _packageByKeyData() but we don't create the package, we just
+ return the pkgtup. """
+ if self._pkgExcludedRKD(repo, pkgKey, data):
+ return None
+ if repo not in self._key2pkg:
+ self._key2pkg[repo] = {}
+ self._pkgname2pkgkeys[repo] = {}
+ if data['pkgKey'] in self._key2pkg.get(repo, {}):
+ return self._key2pkg[repo][data['pkgKey']].pkgtup
+ return (data['name'], data['arch'],
+ data['epoch'], data['version'], data['release'])
+
def _packagesByName(self, pkgname):
""" Load all pkgnames from cache, with a given name. """
ret = []
commit c7e7663efd2f0feec38ad9b446228ecc60c37a2f
Author: James Antill <james at and.org>
Date: Mon Aug 17 11:23:16 2009 -0400
Fix whitespace, comments and doc-comments
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 843cf81..4d8ac0a 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -1496,14 +1496,12 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
if pat_sqls:
qsql = _FULL_PARSE_QUERY_BEG + " OR ".join(pat_sqls)
executeSQL(cur, qsql, pat_data)
- # Note: If we are building the pkgobjlist, we don't exclude
- # here, so that we can un-exclude later on ... if that matters.
for x in cur:
yield (repo, x)
def _buildPkgObjList(self, repoid=None, patterns=None, ignore_case=False):
- """Builds a list of packages, only containing nevra information. No
- excludes are done at this stage. """
+ """Builds a list of packages, only containing nevra information.
+ Excludes are done at this stage. """
returnList = []
@@ -1513,14 +1511,10 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
return self.searchNames(patterns)
for (repo, x) in self._yieldSQLDataList(repoid, patterns, ignore_case):
- exclude = not patterns
- if True: # NOTE: Can't unexclude things...
- exclude = True
- po = self._packageByKeyData(repo, x['pkgKey'], x,
- exclude=exclude)
- if po is None:
- continue
- returnList.append(po)
+ po = self._packageByKeyData(repo, x['pkgKey'], x)
+ if po is None:
+ continue
+ returnList.append(po)
if not patterns and repoid is None:
self.pkgobjlist = returnList
self._pkgnames_loaded = set() # Save memory
commit 5f50bc578c69b6e9888bb95e9cc9e88fe8acf513
Author: James Antill <james at and.org>
Date: Mon Aug 17 11:21:57 2009 -0400
Split the SQL part of _buildPkgObjList() into a separate function
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 277ca8c..843cf81 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -1473,16 +1473,9 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
return (need_full, patterns, False)
@catchSqliteException
- def _buildPkgObjList(self, repoid=None, patterns=None, ignore_case=False):
- """Builds a list of packages, only containing nevra information. No
- excludes are done at this stage. """
-
- returnList = []
-
- (need_full, patterns, names) = self._setupPkgObjList(repoid, patterns,
- ignore_case)
- if names:
- return self.searchNames(patterns)
+ def _yieldSQLDataList(self, repoid=None, patterns=None, ignore_case=False):
+ """Yields all the package data for the given params. Excludes are done
+ at this stage. """
for (repo,cache) in self.primarydb.items():
if (repoid == None or repoid == repo.id):
@@ -1506,6 +1499,20 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
# Note: If we are building the pkgobjlist, we don't exclude
# here, so that we can un-exclude later on ... if that matters.
for x in cur:
+ yield (repo, x)
+
+ def _buildPkgObjList(self, repoid=None, patterns=None, ignore_case=False):
+ """Builds a list of packages, only containing nevra information. No
+ excludes are done at this stage. """
+
+ returnList = []
+
+ (need_full, patterns, names) = self._setupPkgObjList(repoid, patterns,
+ ignore_case)
+ if names:
+ return self.searchNames(patterns)
+
+ for (repo, x) in self._yieldSQLDataList(repoid, patterns, ignore_case):
exclude = not patterns
if True: # NOTE: Can't unexclude things...
exclude = True
commit 8a0fc032da66150a49e7acc8d75df2af2d34ec9f
Author: James Antill <james at and.org>
Date: Mon Aug 17 11:15:08 2009 -0400
Split the setup part of _buildPkgObjList() into a separate function
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 643f1f6..277ca8c 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -1434,16 +1434,13 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
unmatched = misc.unique(unmatched)
return exactmatch, matched, unmatched
- @catchSqliteException
- def _buildPkgObjList(self, repoid=None, patterns=None, ignore_case=False):
- """Builds a list of packages, only containing nevra information. No
- excludes are done at this stage. """
+ def _setupPkgObjList(self, repoid=None, patterns=None, ignore_case=False):
+ """Setup need_full and patterns for _buildPkgObjList, also see if
+ we can get away with just using searchNames(). """
if patterns is None:
patterns = []
- returnList = []
-
fields = ['name', 'sql_nameArch', 'sql_nameVerRelArch',
'sql_nameVer', 'sql_nameVerRel',
'sql_envra', 'sql_nevra']
@@ -1471,8 +1468,21 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
else:
tmp.append((pat, '='))
if not need_full and not need_glob and patterns:
- return self.searchNames(patterns)
+ return (need_full, patterns, True)
patterns = tmp
+ return (need_full, patterns, False)
+
+ @catchSqliteException
+ def _buildPkgObjList(self, repoid=None, patterns=None, ignore_case=False):
+ """Builds a list of packages, only containing nevra information. No
+ excludes are done at this stage. """
+
+ returnList = []
+
+ (need_full, patterns, names) = self._setupPkgObjList(repoid, patterns,
+ ignore_case)
+ if names:
+ return self.searchNames(patterns)
for (repo,cache) in self.primarydb.items():
if (repoid == None or repoid == repo.id):
More information about the Yum-commits
mailing list