forked from BOINC/boinc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new keyword model: - keywords as identified by integer IDs - instead of being treated as opaque data, the keyword XML is now parsed by the client. This is a first step: pass keywords from AM to client to scheduler, so that they can be used in job filtering. Displaying keywords in the client will come later.
- Loading branch information
1 parent
daee3b6
commit 5add5fd
Showing
11 changed files
with
145 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// This file is part of BOINC. | ||
// http://boinc.berkeley.edu | ||
// Copyright (C) 2017 University of California | ||
// | ||
// BOINC is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU Lesser General Public License | ||
// as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// | ||
// BOINC is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
// utility functions for keywords | ||
|
||
#include <stdio.h> | ||
#include <algorithm> | ||
|
||
#include "parse.h" | ||
#include "keyword.h" | ||
|
||
int USER_KEYWORDS::parse(XML_PARSER& xp) { | ||
clear(); | ||
int x; | ||
while (!xp.get_tag()) { | ||
if (xp.match_tag("/user_keywords")) { | ||
return 0; | ||
} | ||
if (xp.parse_int("yes", x)) { | ||
yes.push_back(x); | ||
} else if (xp.parse_int("no", x)) { | ||
no.push_back(x); | ||
} | ||
} | ||
return ERR_XML_PARSE; | ||
} | ||
|
||
void USER_KEYWORDS::write(FILE* f) { | ||
if (empty()) { | ||
return; | ||
} | ||
unsigned int i; | ||
fprintf(f, "<user_keywords>\n"); | ||
for (i=0; i<yes.size(); i++) { | ||
fprintf(f, " <yes>%d</yes>\n", yes[i]); | ||
} | ||
for (i=0; i<no.size(); i++) { | ||
fprintf(f, " <no>%d</no>\n", no[i]); | ||
} | ||
fprintf(f, "</user_keywords>\n"); | ||
} | ||
|
||
double keyword_score(USER_KEYWORDS& user_keywords, JOB_KEYWORDS& job_keywords) { | ||
double score = 0; | ||
for (unsigned int i=0; i<job_keywords.ids.size(); i++) { | ||
int jk = job_keywords.ids[i]; | ||
if (std::find(user_keywords.yes.begin(), user_keywords.yes.end(), jk) != user_keywords.yes.end()) { | ||
score += 1; | ||
} else if (std::find(user_keywords.no.begin(), user_keywords.no.end(), jk) != user_keywords.no.end()) { | ||
return -1; | ||
} | ||
} | ||
return score; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// This file is part of BOINC. | ||
// http://boinc.berkeley.edu | ||
// Copyright (C) 2017 University of California | ||
// | ||
// BOINC is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU Lesser General Public License | ||
// as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// | ||
// BOINC is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
// utility classes for keywords | ||
|
||
#include <vector> | ||
#include "parse.h" | ||
|
||
struct USER_KEYWORDS { | ||
std::vector<int> yes; | ||
std::vector<int> no; | ||
int parse(XML_PARSER&); | ||
void clear() { | ||
yes.clear(); | ||
no.clear(); | ||
} | ||
void write(FILE*); | ||
bool empty() { | ||
return yes.empty() && no.empty(); | ||
} | ||
}; | ||
|
||
struct JOB_KEYWORDS { | ||
std::vector<int> ids; | ||
void parse_str(char*); | ||
// parse space-separated list | ||
}; | ||
|
||
extern double keyword_score(USER_KEYWORDS&, JOB_KEYWORDS&); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters