filter: Update filter test for Index class removal
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
23d0b008e5
commit
99718ade43
|
@ -91,11 +91,7 @@ static void add_substrings(const std::string &text, unsigned int track_id)
|
|||
std::string substr;
|
||||
for (unsigned int i = 1; i <= text.size(); i++) {
|
||||
substr = text.substr(0, i);
|
||||
try {
|
||||
filter_index.find(substr).insert(track_id);
|
||||
} catch (...) {
|
||||
filter_index.insert(IndexEntry(substr, track_id));
|
||||
}
|
||||
index_insert(filter_index, substr, track_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,10 +107,10 @@ void filter :: add(const std::string &text, unsigned int track_id)
|
|||
|
||||
static void find_intersection(std::string &text, std::set<unsigned int> &res)
|
||||
{
|
||||
std::set<unsigned int> terms = filter_index[text];
|
||||
IndexEntry *terms = &filter_index.find(text);
|
||||
std::set<unsigned int> tmp;
|
||||
|
||||
set_intersection(filter_index[text].begin(), filter_index[text].end(),
|
||||
set_intersection(terms->values.begin(), terms->values.end(),
|
||||
res.begin(), res.end(),
|
||||
std::inserter<std::set<unsigned int> >(tmp, tmp.begin()));
|
||||
res.swap(tmp);
|
||||
|
@ -130,7 +126,11 @@ void filter :: search(const std::string &text, std::set<unsigned int> &res)
|
|||
return;
|
||||
|
||||
it = parsed.begin();
|
||||
res = filter_index[*it];
|
||||
try {
|
||||
res = filter_index.find(*it).values;
|
||||
} catch (...) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (it++; it != parsed.end(); it++)
|
||||
find_intersection(*it, res);
|
||||
|
|
|
@ -48,10 +48,15 @@ std::string quotes [] = {
|
|||
|
||||
static const unsigned int num_quotes = sizeof(quotes) / sizeof(std::string);
|
||||
|
||||
void print_index(Index &index)
|
||||
void print_index(Database<IndexEntry> &db)
|
||||
{
|
||||
index.print_keys();
|
||||
index.print();
|
||||
db.print_keys();
|
||||
for (unsigned int i = db.first(); i <= db.last(); i = db.next(i)) {
|
||||
print("index[%s] = ", db[i].primary_key().c_str());
|
||||
db[i].print();
|
||||
print("\n");
|
||||
}
|
||||
print("\n");
|
||||
}
|
||||
|
||||
void test_search(const std::string &text)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue