[Yum-devel] [PATCH] Enable "big update" speedup, disable if a repo. doesn't have pkgfiles index.

James Antill james at and.org
Wed Apr 14 22:26:54 UTC 2010


---
 yum/packageSack.py     |   11 ++++++++---
 yum/packages.py        |    3 +++
 yum/sqlitesack.py      |   19 +++++++++++++++++++
 yum/transactioninfo.py |    7 ++++---
 4 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/yum/packageSack.py b/yum/packageSack.py
index 7a5ce7a..e63a8d7 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -152,6 +152,10 @@ class PackageSackBase(object):
         """returns a dict of obsoletes dict[obsoleting pkgtuple] = [list of obs]"""
         raise NotImplementedError()
 
+    def have_fastSearchFiles(self):
+        """ Is calling searchFiles() faster than using """
+        raise NotImplementedError()
+
     def searchFiles(self, name):
         """return list of packages by filename"""
         raise NotImplementedError()
@@ -772,10 +776,11 @@ class PackageSack(PackageSackBase):
             
         return obs
         
+    def have_fastSearchFiles(self):
+        return True
+
     def searchFiles(self, name):
-        """return list of packages by filename
-           FIXME - need to add regex match against keys in file list
-        """
+        """ Return list of packages by filename. """
         self._checkIndexes(failure='build')
         if self.filenames.has_key(name):
             return self.filenames[name]
diff --git a/yum/packages.py b/yum/packages.py
index 427893b..289660d 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -159,6 +159,9 @@ class FakeSack:
     def __init__(self):
         pass # This is fake, so do nothing
     
+    def have_fastSearchFiles(self):
+        return True
+
     def delPackage(self, obj):
         """delete a pkgobject, do nothing, but make localpackages work with --skip-broken"""
         pass # This is fake, so do nothing
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index b5cea0e..8986699 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -842,6 +842,25 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
         return misc.unique(results)
         
     @catchSqliteException
+    def have_fastSearchFiles(self):
+        """ Return true if searchFiles() is always fast, basically relies on
+            "CREATE INDEX pkgfiles ON files (pkgKey);" existing. """
+
+        for (rep,cache) in self.primarydb.items():
+            if rep in self._all_excludes:
+                continue
+            cur = cache.cursor()
+            executeSQL(cur, "PRAGMA index_info(pkgfiles)")
+            #  If we get anything, we're fine. There might be a better way of
+            # saying "anything" but this works.
+            for ob in cur:
+                break
+            else:
+                return False
+
+        return True
+
+    @catchSqliteException
     def searchFiles(self, name, strict=False):
         """search primary if file will be in there, if not, search filelists, use globs, if possible"""
         
diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index e7b60de..95fff11 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -89,9 +89,7 @@ class TransactionData:
         self.pkgSack = None
         self.pkgSackPackages = 0
         self.localSack = PackageSack()
-        # FIXME: This is turned off atm. ... it'll be turned on when
-        #        the new yum-metadata-parser with the "pkgfiles" index is std.
-        self._inSack = None # GetProvReqOnlyPackageSack()
+        self._inSack = GetProvReqOnlyPackageSack()
 
         # lists of txmbrs in their states - just placeholders
         self.instgroups = []
@@ -238,6 +236,9 @@ class TransactionData:
             self.localSack.addPackage(txmember.po)
         elif isinstance(txmember.po, YumAvailablePackageSqlite):
             self.pkgSackPackages += 1
+        if (self._inSack is not None and
+            not txmember.po.repo.sack.have_fastSearchFiles()):
+            self._inSack = None
         if self._inSack is not None and txmember.output_state in TS_INSTALL_STATES:
             self._inSack.addPackage(txmember.po)
 
-- 
1.6.6.1



More information about the Yum-devel mailing list