[yum-cvs] yum/yum packageSack.py,1.25,1.26 sqlitesack.py,1.56,1.57

James Bowes jbowes at linux.duke.edu
Sat Feb 3 21:23:29 UTC 2007


Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv21300/yum

Modified Files:
	packageSack.py sqlitesack.py 
Log Message:
Apply patch from David Lutterkort for speedup of yum install

Index: packageSack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/packageSack.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- packageSack.py	28 Jan 2007 20:05:36 -0000	1.25
+++ packageSack.py	3 Feb 2007 21:23:26 -0000	1.26
@@ -18,6 +18,7 @@
 import warnings
 import re
 import fnmatch
+import misc
 
 class PackageSackBase(object):
     """Base class that provides the interface for PackageSacks."""
@@ -335,6 +336,30 @@
     def searchAll(self, arg, query_type):
         return self._computeAggregateListResult("searchAll", arg, query_type)
 
+    def matchPackageNames(self, pkgspecs):
+        matched = []
+        exactmatch = []
+        unmatched = None
+        for sack in self.sacks.values():
+            if hasattr(sack, "matchPackageNames"):
+                e, m, u = [], [], []
+                try:
+                    e, m, u = sack.matchPackageNames(pkgspecs)
+                except PackageSackError:
+                    continue
+
+                exactmatch.extend(e)
+                matched.extend(m)
+                if unmatched is None:
+                    unmatched = set(u)
+                else:
+                    unmatched = unmatched.intersection(set(u))
+
+        matched = misc.unique(matched)
+        exactmatch = misc.unique(exactmatch)
+        unmatched = list(unmatched)
+        return exactmatch, matched, unmatched
+
     def _computeAggregateListResult(self, methodName, *args):
         result = []
         for sack in self.sacks.values():

Index: sqlitesack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/sqlitesack.py,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- sqlitesack.py	28 Jan 2007 22:57:00 -0000	1.56
+++ sqlitesack.py	3 Feb 2007 21:23:26 -0000	1.57
@@ -499,6 +499,33 @@
             raise Errors.PackageSackError, 'No Package Matching %s' % name
         return misc.newestInList(allpkg)
 
+    # Do what packages.matchPackageNames does, but query the DB directly
+    def matchPackageNames(self, pkgspecs):
+        matched = []
+        exactmatch = []
+        unmatched = list(pkgspecs)
+        for p in pkgspecs:
+            if re.match('[\*\?\[\]]', p):
+                query = PARSE_QUERY % ({ "op": "glob", "q": p })
+                matchres = matched
+            else:
+                query = PARSE_QUERY % ({ "op": "=", "q": p })
+                matchres = exactmatch
+
+            for (rep, db) in self.primarydb.items():
+                cur = db.cursor()
+                executeSQL(cur, query)
+                res = cur.fetchall()
+                if len(res) > 0:
+                    unmatched.remove(p)
+                    pos = map(lambda x: self.pc(rep,self.db2class(x,True)), res)
+                    matchres.extend(pos)
+
+        exactmatch = misc.unique(exactmatch)
+        matched = misc.unique(matched)
+        unmatched = misc.unique(unmatched)
+        return exactmatch, matched, unmatched
+
     def returnPackages(self, repoid=None):
         """Returns a list of packages, only containing nevra information """
         returnList = []
@@ -506,7 +533,7 @@
             if (repoid == None or repoid == repo.id):
                 cur = cache.cursor()
                 executeSQL(cur, "select pkgId,name,epoch,version,release,arch from packages")
-                for x in cur.fetchall():
+                for x in cur:
                     if (self.excludes[repo].has_key(x['pkgId'])):
                         continue
                     returnList.append(self.pc(repo,self.db2class(x,True)))
@@ -585,3 +612,18 @@
     string2ft = {'f':'file','d': 'dir','g': 'ghost'}
     return [string2ft[x] for x in filetypestring]
 
+
+# Query used by matchPackageNames
+# op is either '=' or 'like', q is the search term
+# Check against name, nameArch, nameVerRelArch, nameVer, nameVerRel,
+# envra, nevra
+PARSE_QUERY = """
+select pkgId, name, arch, epoch, version, release from packages
+where name %(op)s '%(q)s'
+   or name || '.' || arch %(op)s '%(q)s'
+   or name || '-' || version %(op)s '%(q)s'
+   or name || '-' || version || '-' || release %(op)s '%(q)s'
+   or name || '-' || version || '-' || release || '.' || arch %(op)s '%(q)s'
+   or epoch || ':' || name || '-' || version || '-' || release || '.' || arch %(op)s '%(q)s'
+   or name || '-' || epoch || ':' || version || '-' || release || '.' || arch %(op)s '%(q)s'
+"""




More information about the Yum-cvs-commits mailing list