GNU bug report logs - #39258
Faster guix search using an sqlite cache

Previous Next

Package: guix-patches;

Reported by: Arun Isaac <arunisaac <at> systemreboot.net>

Date: Thu, 23 Jan 2020 19:53:02 UTC

Severity: important

Done: Arun Isaac <arunisaac <at> systemreboot.net>

Bug is archived. No further changes may be made.

Full log


Message #367 received at 39258 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: 39258 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org, arunisaac <at> systemreboot.net, zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH v6 2/2] DRAFT scripts: package: Use cache in
 'find-packages-by-description'.
Date: Thu, 15 Jul 2021 09:33:28 +0200
* guix/scripts/package.scm (find-packages-by-description): Replace
'fold-packages' by 'fold-available-packages'.
---
 guix/scripts/package.scm | 46 +++++++++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 694959d326..ff2aed6905 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -8,7 +8,7 @@
 ;;; Copyright © 2016 Chris Marusich <cmmarusich <at> gmail.com>
 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me <at> tobias.gr>
 ;;; Copyright © 2020 Ricardo Wurmus <rekado <at> elephly.net>
-;;; Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com>
+;;; Copyright © 2020, 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -181,17 +181,39 @@ hooks\" run when building the profile."
   "Return a list of pairs: packages whose name, synopsis, description,
 or output matches at least one of REGEXPS sorted by relevance, and its
 non-zero relevance score."
-  (let ((matches (fold-packages (lambda (package result)
-                                  (if (package-superseded package)
-                                      result
-                                      (match (package-relevance package
-                                                                regexps)
-                                        ((? zero?)
-                                         result)
-                                        (score
-                                         (cons (cons package score)
-                                               result)))))
-                                '())))
+  (define (read-package-from module symbol)
+    (module-ref (resolve-interface module) symbol))
+
+  (let ((matches (fold-available-packages
+                  (lambda* (name version result
+                                 #:key outputs description synopsis location
+                                 module symbol
+                                 deprecated?
+                                 #:allow-other-keys)
+                    (if deprecated?
+                        result
+                        (let* ((package
+                                 (package
+                                   (name name)
+                                   (version version)
+                                   (source #f)
+                                   (build-system #f)
+                                   (outputs outputs)
+                                   (synopsis synopsis)
+                                   (description description)
+                                   (home-page #f)
+                                   (license #f)
+                                   (location location))))
+                          (match (package-relevance package
+                                                    regexps)
+                            ((? zero?)
+                             result)
+                            (score
+                             (cons (cons (read-package-from module symbol)
+                                         score)
+                                   result))))))
+                  '())))
+
     (sort matches
           (lambda (m1 m2)
             (match m1
-- 
2.32.0





This bug report was last modified 38 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.