The attached patch adds a user-defined sqlite function for use during searchFiles in sqlitesack. Essentially, for each row in the table, sqlite calls out to a python function that reassembles the full path, and runs the glob function on it.
I'd like some feedback on this, because the sql to python dance is not straightforward, and I would also appreciate seeing some other numbers on the run times. I have seen the time for 'yum provides "*zsh*"' go from 24s to 19s on a 2.8 GHz Xeon, and from 12s to 11s on my laptop (whose stats escape me now). One second may not be enough to bother, which is why I'd like to see what other people experience. -James
? prof.py
? yum.prof
Index: yum/sqlitesack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/sqlitesack.py,v
retrieving revision 1.86
diff -u -r1.86 sqlitesack.py
--- yum/sqlitesack.py 5 Mar 2007 14:04:24 -0000 1.86
+++ yum/sqlitesack.py 6 Mar 2007 15:50:29 -0000
@@ -303,33 +303,30 @@
po = self.pc(rep, pkg)
pkgs.append(po)
+ def filelist_globber(dirname, filenames):
+ files = filenames.split('/')
+ fns = map(lambda f: '%s/%s' % (dirname, f), files)
+ if glob:
+ matches = fnmatch.filter(fns, name)
+ else:
+ matches = filter(lambda x: name==x, fns)
+ return len(matches)
+
+ cache.create_function("filelist_globber", 2, filelist_globber)
# for all the ones where filenames is multiple files,
# make the files up whole and use python's globbing method
- executeSQL(cur, "select packages.pkgID as pkgID, \
- filelist.dirname as dirname, \
- filelist.filenames as filenames \
+ executeSQL(cur, "select packages.pkgID as pkgID \
from filelist,packages where \
packages.pkgKey = filelist.pkgKey \
- and length(filelist.filetypes) > 1")
+ and length(filelist.filetypes) > 1 \
+ and filelist_globber(filelist.dirname,filelist.filenames)")
for ob in cur:
- pkgId = ob['pkgId']
- d = ob['dirname']
- fs = ob['filenames']
-
- files = fs.split('/')
- fns = map(lambda f: '%s/%s' % (d, f), files)
- if glob:
- matches = fnmatch.filter(fns, name)
- else:
- matches = filter(lambda x: name==x, fns)
-
- if len(matches) > 0:
- if self._excluded(rep, pkgId):
- continue
- pkg = self.getPackageDetails(pkgId)
- po = self.pc(rep, pkg)
- pkgs.append(po)
+ if self._excluded(rep, ob['pkgId']):
+ continue
+ pkg = self.getPackageDetails(ob['pkgId'])
+ po = self.pc(rep, pkg)
+ pkgs.append(po)
pkgs = misc.unique(pkgs)
return pkgs
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Yum-devel mailing list [email protected] https://lists.dulug.duke.edu/mailman/listinfo/yum-devel
