Hi all,
 I've been going through all the sql and trying to find places where we
can make it faster. I was going through globbing in the filelist
matching code trying to make it run quicker. I was working on a script
outside of the yum base so it was easier to test and play. I've attached
the script. I'm curious if anyone knows of a faster way to make this
work.

right now going through all of extras it takes 7.5s, which isn't too
bad, but I want to know if I'm missing anything.

-sv

#!/usr/bin/python -tt
import sys
import fnmatch
import os.path
import sqlite
from yum.sqlutils import executeSQL
from yum.misc import unique

mydb = '/var/cache/yum/extras/filelists.xml.gz.sqlite'

my = sqlite.connect(mydb)
cur = my.cursor()

pkgs = []

# grab the entries that area single file in the filenames section, use sqlites globbing method
executeSQL(cur, "select packages.pkgID, filelist.dirname, filelist.filenames \
                 from filelist,packages where packages.pkgKey = filelist.pkgKey and \
                 length(filelist.filetypes) = 1 and \
                 filelist.dirname || ? || filelist.filenames glob ?", ('/', sys.argv[1]))


for (p,d,fs) in cur.fetchall():
    pkgs.append(p)
    
# 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, filelist.dirname, filelist.filenames \
                 from filelist,packages where packages.pkgKey = filelist.pkgKey \
                 and length(filelist.filetypes) > 1")

for (p,d,fs) in cur.fetchall():
    files = fs.split('/')
    matches = fnmatch.filter(map(lambda f: '%s/%s' % (d, f), files), sys.argv[1])
    if len(matches) > 0:
        pkgs.append(p)

print len(pkgs)
print len(unique(pkgs))
            
            
        
                
        

        
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to