Gentoo Archives: gentoo-portage-dev

From: Emma Strubell <emma.strubell@×××××.com>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] search functionality in emerge
Date: Sun, 23 Nov 2008 18:49:30
Message-Id: 5a8c638a0811231049g56506b9flc0986705a24094f0@mail.gmail.com
In Reply to: Re: [gentoo-portage-dev] search functionality in emerge by Lucian Poston
1 Wow, that's extremely helpful!! I happen to particularly enjoy tries, so the
2 suffix trie sounds like a great idea. The trie class example is really
3 helpful too, because this will be my first time programming in Python, and
4 it's a bit easier to figure out what's going on syntax-wise in that simple
5 trie class than in the middle of the portage source code!
6
7 Seriously, thanks again :]
8
9 On Sun, Nov 23, 2008 at 11:56 AM, Lucian Poston <lucianposton@×××××.com>wrote:
10
11 > > Thanks for the replies! I know there are a couple programs out there that
12 > > basically already do what I'm looking to do... Unfortunately I wasn't
13 > aware
14 > > of these pre-existing utilities until after I submitted my project
15 > proposal
16 > > to my professor. So, I'm looking to implement a better search myself.
17 > > Preferably by editing the existing portage code, not writing a separate
18 > > program. So if anyone can offer any help regarding the actual
19 > implementation
20 > > of search in portage, I would greatly appreciate it!
21 >
22 > Most of the search implementation is in
23 > /usr/lib/portage/pym/_emerge/__init__.py in class search. The class's
24 > execute() method simply iterates over all packages (and descriptions
25 > and package sets) and matches against the searchkey. You might need
26 > to look into pym/portage/dbapi/porttree.py for portdbapi as well.
27 >
28 > If you intend to index and support fast regex lookup, then you need to
29 > do some fancy indexing, which I'm not terribly familiar with. You
30 > could follow in the steps of eix[1] or other indexed search utilities
31 > and design some sort of index layout, which is easier than the
32 > following thought. You might consider implementing a suffix trie or
33 > similar that has sublinear regexp lookup and marshalling the structure
34 > for the index. I couldn't find a python implementation for something
35 > like this, but here is a general trie class[2] that you might start
36 > with if you go that route. There is a perl module[3],
37 > Tie::Hash::Regex, that does that, but properly implementing that in
38 > python would be a chore. :)
39 >
40 > That project sounds interesting and fun. Good luck!
41 >
42 > Lucian Poston
43 >
44 > [1] https://projects.gentooexperimental.org/eix/wiki/IndexFileLayout
45 > [2]
46 > http://www.koders.com/python/fid7B6BC1651A9E8BBA547552FE3F039479A4DECC45.aspx
47 > [3]
48 > http://search.cpan.org/~davecross/Tie-Hash-Regex-1.02/lib/Tie/Hash/Regex.pm<http://search.cpan.org/%7Edavecross/Tie-Hash-Regex-1.02/lib/Tie/Hash/Regex.pm>
49 >
50 >

Replies