[yum-git] Branch 'yum-3_2_X' - 4 commits - yum/constants.py yum/sqlitesack.py
James Antill
james at linux.duke.edu
Sun Jul 20 15:36:54 UTC 2008
yum/constants.py | 2 -
yum/sqlitesack.py | 61 +++++++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 52 insertions(+), 11 deletions(-)
New commits:
commit 1b68d4685d15abc98aa854188af05d51bf0e0b56
Author: James Antill <james at and.org>
Date: Sun Jul 20 11:28:16 2008 -0400
Add _skip_all paths to a bunch more functions, some of them do
_all_excludes processing anyway ... but make sure.
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index a5f8fed..2a1de81 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -466,10 +466,22 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
pattern = pattern.replace("_", "!_")
return (pattern, esc)
+ def _skip_all(self):
+ """ Are we going to skip every package in all our repos? """
+ skip_all = True
+ for repo in self.added:
+ if repo not in self._all_excludes:
+ skip_all = False
+ break
+ return skip_all
+
@catchSqliteException
def searchFiles(self, name, strict=False):
"""search primary if file will be in there, if not, search filelists, use globs, if possible"""
+ if self._skip_all():
+ return []
+
# optimizations:
# if it is not glob, then see if it is in the primary.xml filelists,
# if so, just use those for the lookup
@@ -546,6 +558,9 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
@catchSqliteException
def searchPrimaryFields(self, fields, searchstring):
"""search arbitrary fields from the primarydb for a string"""
+ if self._skip_all():
+ return []
+
result = []
if len(fields) < 1:
return result
@@ -568,6 +583,9 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
"""search arbitrary fields from the primarydb for a multiple strings
return packages, number of items it matched as a list of tuples"""
+ if self._skip_all():
+ return []
+
result = [] # (pkg, num matches)
if len(fields) < 1:
return result
@@ -613,6 +631,9 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
@catchSqliteException
def returnObsoletes(self, newest=False):
+ if self._skip_all():
+ return {}
+
if newest:
raise NotImplementedError()
@@ -697,6 +718,9 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
@catchSqliteException
def _search(self, prcotype, name, flags, version):
+ if self._skip_all():
+ return {}
+
if flags == 0:
flags = None
if type(version) in (str, type(None), unicode):
@@ -792,19 +816,14 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
def getRequires(self, name, flags=None, version=(None, None, None)):
return self._search("requires", name, flags, version)
- def _skip_all(self):
- """ Are we going to skip every package in all our repos? """
- skip_all = True
- for repo in self.added:
- if repo not in self._all_excludes:
- skip_all = False
- return skip_all
-
@catchSqliteException
def searchNames(self, names):
"""return a list of packages matching any of the given names. This is
only a match on package name, nothing else"""
+ if self._skip_all():
+ return []
+
returnList = []
if len(names) > constants.PATTERNS_MAX:
names = set(names)
@@ -814,9 +833,6 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
returnList.append(pkg)
return returnList
- if self._skip_all():
- return []
-
pat_sqls = []
qsql = """select pkgId,pkgKey,name,epoch,version,release,arch
from packages where """
@@ -835,6 +851,9 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
@catchSqliteException
def searchPrco(self, name, prcotype):
"""return list of packages having prcotype name (any evr and flag)"""
+ if self._skip_all():
+ return []
+
glob = True
querytype = 'glob'
if not misc.re_glob(name):
@@ -982,6 +1001,9 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
def returnNewestByName(self, name=None, patterns=None, ignore_case=False):
# If name is set do it from the database otherwise use our parent's
# returnNewestByName
+ if self._skip_all():
+ return []
+
if (not name):
return yumRepo.YumPackageSack.returnNewestByName(self, name,
patterns,
@@ -1002,6 +1024,9 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
# Do what packages.matchPackageNames does, but query the DB directly
@catchSqliteException
def matchPackageNames(self, pkgspecs):
+ if self._skip_all():
+ return []
+
matched = []
exactmatch = []
unmatched = list(pkgspecs)
@@ -1094,6 +1119,9 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
@catchSqliteException
def searchNevra(self, name=None, epoch=None, ver=None, rel=None, arch=None):
"""return list of pkgobjects matching the nevra requested"""
+ if self._skip_all():
+ return []
+
returnList = []
# make sure some dumbass didn't pass us NOTHING to search on
commit 34b964478316d0edd2edff71e283ed1311c55deb
Author: James Antill <james at and.org>
Date: Sun Jul 20 11:16:17 2008 -0400
Merge skip_all code paths into a helper function
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 425ee65..a5f8fed 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -792,6 +792,14 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
def getRequires(self, name, flags=None, version=(None, None, None)):
return self._search("requires", name, flags, version)
+ def _skip_all(self):
+ """ Are we going to skip every package in all our repos? """
+ skip_all = True
+ for repo in self.added:
+ if repo not in self._all_excludes:
+ skip_all = False
+ return skip_all
+
@catchSqliteException
def searchNames(self, names):
"""return a list of packages matching any of the given names. This is
@@ -806,12 +814,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
returnList.append(pkg)
return returnList
- skip_all = True
- for repo in self.added:
- if repo not in self._all_excludes:
- skip_all = False
-
- if skip_all:
+ if self._skip_all():
return []
pat_sqls = []
@@ -1072,13 +1075,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
packages are processed for excludes. Note that patterns is just
a hint, we are free it ignore it. """
- # Skip unused repos completely, Eg. *-source
- skip_all = True
- for repo in self.added:
- if repo not in self._all_excludes:
- skip_all = False
-
- if skip_all:
+ if self._skip_all():
return []
if hasattr(self, 'pkgobjlist'):
commit 701e3d0e16c51a2e52cdf65351b7954621bf223f
Author: James Antill <james at and.org>
Date: Sun Jul 20 11:13:29 2008 -0400
Add skip_all path to searchNames(), minor speed up
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 2254b3f..425ee65 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -806,6 +806,14 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
returnList.append(pkg)
return returnList
+ skip_all = True
+ for repo in self.added:
+ if repo not in self._all_excludes:
+ skip_all = False
+
+ if skip_all:
+ return []
+
pat_sqls = []
qsql = """select pkgId,pkgKey,name,epoch,version,release,arch
from packages where """
commit 233b2b3ebe55203e049834e2ca47df32fb7193a4
Author: James Antill <james at and.org>
Date: Sun Jul 20 11:12:06 2008 -0400
Add PATTERNS_MAX path to searchNames(), so large groups work.
Bump PATTERNS_MAX to be larger.
Divide usage of PATTERNS_AMX by the number of fields per. pattern.
diff --git a/yum/constants.py b/yum/constants.py
index 21c0988..00a2bba 100644
--- a/yum/constants.py
+++ b/yum/constants.py
@@ -99,4 +99,4 @@ RPM_TO_SQLITE = { 'packagesize' : 'size_package',
}
# Cut over for when we should just give up and load everything
-PATTERNS_MAX = 128
+PATTERNS_MAX = 512
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index c1fdc23..2254b3f 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -574,7 +574,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
# NOTE: I can't see any reason not to use this all the time, speed
# comparison shows them as baiscally equal.
- if len(searchstrings) > constants.PATTERNS_MAX:
+ if len(searchstrings) > (constants.PATTERNS_MAX / len(fields)):
tot = {}
for searchstring in searchstrings:
matches = self.searchPrimaryFields(fields, searchstring)
@@ -797,6 +797,15 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
"""return a list of packages matching any of the given names. This is
only a match on package name, nothing else"""
+ returnList = []
+ if len(names) > constants.PATTERNS_MAX:
+ names = set(names)
+ for pkg in self.returnPackages():
+ if pkg.name not in names:
+ continue
+ returnList.append(pkg)
+ return returnList
+
pat_sqls = []
qsql = """select pkgId,pkgKey,name,epoch,version,release,arch
from packages where """
@@ -804,7 +813,6 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
pat_sqls.append("name = ?")
qsql = qsql + " OR ".join(pat_sqls)
- returnList = []
for (repo, cache) in self.primarydb.items():
cur = cache.cursor()
executeSQL(cur, qsql, list(names))
@@ -1013,7 +1021,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
"""Builds a list of packages, only containing nevra information. No
excludes are done at this stage. """
- if patterns is None or len(patterns) > constants.PATTERNS_MAX:
+ if patterns is None or len(patterns) > (constants.PATTERNS_MAX / 7):
patterns = []
returnList = []
More information about the Yum-cvs-commits
mailing list