[Debtags-commits] [svn] r1920 - in daemon: . src
Enrico Zini
enrico at costa.debian.org
Mon Sep 18 12:55:26 UTC 2006
Author: enrico
Date: Mon Sep 18 12:55:25 2006
New Revision: 1920
Modified:
daemon/ (props changed)
daemon/src/debtagsd.cpp
Log:
r3355 at viaza: enrico | 2006-09-18 14:54:37 +0200
Implemented smart search
Modified: daemon/src/debtagsd.cpp
==============================================================================
--- daemon/src/debtagsd.cpp (original)
+++ daemon/src/debtagsd.cpp Mon Sep 18 12:55:25 2006
@@ -331,11 +331,23 @@
for (set<string>::const_iterator i = res.begin(); i != res.end(); ++i)
outputPackage(*i, conn);
}
+ else if (cmd == "STAGS")
+ {
+ vector<string> terms = parseKeys(line);
+ set<string> pkgs = fts.search(terms);
+ // TODO: this is still wasteful: we don't need to build a
+ // coll::Fast, but just to count how many times a tag appears
+ // attached to the packages in 'pkgs': that gives the
+ // tag list and the cardinalities needed for the computation
+ tagcoll::coll::Fast<string, string> subcoll;
+ for (set<string>::const_iterator i = pkgs.begin(); i != pkgs.end(); ++i)
+ subcoll.insert(wibble::singleton(*i), coll.getTagsOfItem(*i));
+ vector<string> tags = subcoll.tagsInRelevanceOrder(coll);
+ for (vector<string>::const_reverse_iterator i = tags.rbegin(); i != tags.rend(); ++i)
+ conn.write(*i + "\n");
+ }
else
- conn.write("Lippocippo\n");
-
- // write output to fd
- //conn.write("Hello " + line + "\n");
+ conn.write("Command not recognized: " + cmd + "\n");
} catch (std::exception& e) {
log << e.what() << endl;
}
More information about the Debtags-commits
mailing list