From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
Date: Sun, 7 Dec 2014 23:14:02 +0000 (UTC) [thread overview]
Message-ID: <1417993848.55c8c8bc7a781e3f71ce92922eea64ad4cafce3c.zmedico@gentoo> (raw)
commit: 55c8c8bc7a781e3f71ce92922eea64ad4cafce3c
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 5 05:07:26 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Dec 7 23:10:48 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=55c8c8bc
Add emerge --search-index option.
The new emerge --search-index option, which is enabled by default,
causes pkg_desc_index to be used for search optimization. The search
index needs to be regenerated by egencache after changes are made to
a repository (see the --update-pkg-desc-index action).
For users that would like to modify ebuilds in a repository without
running egencache afterwards, emerge --search-index=n can be used to
get non-indexed search. Alternatively, the user could simply remove
the stale index file, in order to disable the search index for a
particular repository.
In order to conserve memory, indices are read as streams, and
MultiIterGroupBy is used to group results from IndexedPortdb and
IndexedVardb. Stream-oriented search also makes it possible to
display search results incrementally (for bug #412471).
X-Gentoo-Bug: 525718
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=525718
---
man/emerge.1 | 8 ++++++++
pym/_emerge/actions.py | 3 ++-
pym/_emerge/depgraph.py | 2 +-
pym/_emerge/main.py | 5 +++++
pym/_emerge/search.py | 31 ++++++++++++++++++++++++++-----
5 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/man/emerge.1 b/man/emerge.1
index be46a7d..b9ce79c 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -804,6 +804,14 @@ If ebuilds using EAPIs which \fIdo not\fR support \fBHDEPEND\fR are built in
the same \fBemerge\fR run as those using EAPIs which \fIdo\fR support
\fBHDEPEND\fR, this option affects only the former.
.TP
+.BR "\-\-search\-index < y | n >"
+Enable or disable indexed search for search actions. This option is
+enabled by default. The search index needs to be regenerated by
+\fBegencache\fR(1) after changes are made to a repository (see the
+\fB\-\-update\-pkg\-desc\-index\fR action). This setting can be added
+to \fBEMERGE_DEFAULT_OPTS\fR (see \fBmake.conf\fR(5)) and later
+overridden via the command line.
+.TP
.BR "\-\-select [ y | n ] (\-w short option)"
Add specified packages to the world set (inverse of
\fB\-\-oneshot\fR). This is useful if you want to
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 434fc47..c7246a9 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -1901,7 +1901,8 @@ def action_search(root_config, myopts, myfiles, spinner):
searchinstance = search(root_config,
spinner, "--searchdesc" in myopts,
"--quiet" not in myopts, "--usepkg" in myopts,
- "--usepkgonly" in myopts)
+ "--usepkgonly" in myopts,
+ search_index = myopts.get("--search-index", "y") != "n")
for mysearch in myfiles:
try:
searchinstance.execute(mysearch)
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 3455b6b..df1e266 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -8730,7 +8730,7 @@ def ambiguous_package_name(arg, atoms, root_config, spinner, myopts):
s = search(root_config, spinner, "--searchdesc" in myopts,
"--quiet" not in myopts, "--usepkg" in myopts,
- "--usepkgonly" in myopts)
+ "--usepkgonly" in myopts, search_index = False)
null_cp = portage.dep_getkey(insert_category_into_atom(
arg, "null"))
cat, atom_pn = portage.catsplit(null_cp)
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 1506207..66d4891 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -617,6 +617,11 @@ def parse_opts(tmpcmdline, silent=False):
"choices" :("True", "rdeps")
},
+ "--search-index": {
+ "help": "Enable or disable indexed search (enabled by default)",
+ "choices": y_or_n
+ },
+
"--select": {
"shortopt" : "-w",
"help" : "add specified packages to the world set " + \
diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py
index e51d206..4b1833a 100644
--- a/pym/_emerge/search.py
+++ b/pym/_emerge/search.py
@@ -5,9 +5,12 @@ import re
import portage
from portage import os
from portage.dbapi.porttree import _parse_uri_map
+from portage.dbapi.IndexedPortdb import IndexedPortdb
+from portage.dbapi.IndexedVardb import IndexedVardb
from portage.localization import localized_size
from portage.output import bold, bold as white, darkgreen, green, red
from portage.util import writemsg_stdout
+from portage.util.iterators.MultiIterGroupBy import MultiIterGroupBy
from _emerge.Package import Package
@@ -23,7 +26,7 @@ class search(object):
# public interface
#
def __init__(self, root_config, spinner, searchdesc,
- verbose, usepkg, usepkgonly):
+ verbose, usepkg, usepkgonly, search_index=True):
"""Searches the available and installed packages for the supplied search key.
The list of available and installed packages is created at object instantiation.
This makes successive searches faster."""
@@ -45,6 +48,10 @@ class search(object):
bindb = root_config.trees["bintree"].dbapi
vardb = root_config.trees["vartree"].dbapi
+ if search_index:
+ portdb = IndexedPortdb(portdb)
+ vardb = IndexedVardb(vardb)
+
if not usepkgonly and portdb._have_root_eclass_dir:
self._dbs.append(portdb)
@@ -60,10 +67,16 @@ class search(object):
self.spinner.update()
def _cp_all(self):
- cp_all = set()
+ iterators = []
for db in self._dbs:
- cp_all.update(db.cp_all())
- return list(sorted(cp_all))
+ i = db.cp_all()
+ try:
+ i = iter(i)
+ except TypeError:
+ pass
+ iterators.append(i)
+ for group in MultiIterGroupBy(iterators):
+ yield group[0]
def _aux_get(self, *args, **kwargs):
for db in self._dbs:
@@ -154,9 +167,17 @@ class search(object):
result = cpv
else:
db_keys = list(db._aux_cache_keys)
+ matches = db.match(atom)
+ try:
+ db.match_unordered
+ except AttributeError:
+ pass
+ else:
+ db._cpv_sort_ascending(matches)
+
# break out of this loop with highest visible
# match, checked in descending order
- for cpv in reversed(db.match(atom)):
+ for cpv in reversed(matches):
if portage.cpv_getkey(cpv) != cp:
continue
metadata = zip(db_keys,
next reply other threads:[~2014-12-07 23:14 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-07 23:14 Zac Medico [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-02-03 3:07 [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/ Zac Medico
2018-01-30 4:24 Zac Medico
2017-05-14 18:12 Zac Medico
2016-08-08 15:56 Zac Medico
2014-10-21 23:11 Zac Medico
2014-10-20 0:08 Zac Medico
2014-09-24 22:36 Brian Dolbec
2014-06-14 21:46 Alexander Berntsen
2014-06-14 21:46 Alexander Berntsen
2014-06-14 20:58 Alexander Berntsen
2013-07-18 20:25 Zac Medico
2013-07-18 20:23 Zac Medico
2013-02-23 19:17 Zac Medico
2012-12-29 22:35 Zac Medico
2012-12-08 9:25 Zac Medico
2012-11-29 7:53 Zac Medico
2012-10-08 20:30 Zac Medico
2011-12-14 4:47 Zac Medico
2011-10-16 18:58 Zac Medico
2011-10-10 18:05 Zac Medico
2011-09-21 14:00 Zac Medico
2011-09-19 16:03 Zac Medico
2011-09-19 14:15 Zac Medico
2011-09-18 20:16 Zac Medico
2011-07-19 8:38 Zac Medico
2011-06-04 23:32 Zac Medico
2011-06-03 5:40 Zac Medico
2011-05-17 4:31 Zac Medico
2011-05-15 19:20 Zac Medico
2011-05-11 19:04 Zac Medico
2011-04-28 16:16 Zac Medico
2011-04-27 22:07 Zac Medico
2011-04-27 22:03 Zac Medico
2011-04-27 22:00 Zac Medico
2011-03-24 18:18 Zac Medico
2011-03-14 17:52 Zac Medico
2011-02-13 0:24 Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1417993848.55c8c8bc7a781e3f71ce92922eea64ad4cafce3c.zmedico@gentoo \
--to=zmedico@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox