mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-29 01:33:46 +00:00
Implement locate_sets_in_db().
It's finally got fast & easy to write! Too bad it was the last one...
This commit is contained in:
parent
346f7ce971
commit
5e69367c2c
4 changed files with 26 additions and 11 deletions
|
@ -254,12 +254,12 @@ namespace dindb {
|
|||
return dindb::locate_in_db(m_redis, parSearch, parTags);
|
||||
}
|
||||
|
||||
std::vector<LocatedSet> BackendRedis::locate_sets_in_db (const std::string& parSearch, bool parCaseInsensitive) {
|
||||
return dindb::locate_sets_in_db(m_redis, parSearch, parCaseInsensitive);
|
||||
std::vector<LocatedSet> BackendRedis::locate_sets_in_db (const std::string& parSubstr, bool parCaseInsensitive) {
|
||||
return dindb::locate_sets_in_db(m_redis, parSubstr, parCaseInsensitive);
|
||||
}
|
||||
|
||||
std::vector<LocatedSet> BackendRedis::locate_sets_in_db (const std::string& parSearch, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive) {
|
||||
return std::vector<LocatedSet>();
|
||||
std::vector<LocatedSet> BackendRedis::locate_sets_in_db (const std::string& parSubstr, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive) {
|
||||
return dindb::locate_sets_in_db(m_redis, parSubstr, parSets, parCaseInsensitive);
|
||||
}
|
||||
|
||||
std::vector<GroupIDType> BackendRedis::find_all_sets() {
|
||||
|
|
|
@ -49,8 +49,8 @@ namespace dindb {
|
|||
|
||||
virtual std::vector<LocatedItem> locate_in_db ( const std::string& parSearch, const TagList& parTags ) override;
|
||||
virtual std::vector<LocatedItem> locate_in_db ( const mchlib::TigerHash& parSearch, const TagList& parTags ) override;
|
||||
virtual std::vector<LocatedSet> locate_sets_in_db ( const std::string& parSearch, bool parCaseInsensitive ) override;
|
||||
virtual std::vector<LocatedSet> locate_sets_in_db ( const std::string& parSearch, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive ) override;
|
||||
virtual std::vector<LocatedSet> locate_sets_in_db ( const std::string& parSubstr, bool parCaseInsensitive ) override;
|
||||
virtual std::vector<LocatedSet> locate_sets_in_db ( const std::string& parSubstr, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive ) override;
|
||||
|
||||
virtual std::vector<GroupIDType> find_all_sets ( void ) override;
|
||||
virtual std::vector<dinhelp::MaxSizedArray<std::string, 4>> find_set_details ( const std::vector<GroupIDType>& parSets ) override;
|
||||
|
|
|
@ -226,18 +226,31 @@ namespace dindb {
|
|||
}
|
||||
|
||||
std::vector<LocatedSet> locate_sets_in_db (redis::IncRedis& parRedis, const std::string& parSubstr, bool parCaseInsensitive) {
|
||||
auto filter_case_ins = [&parSubstr](const boost::tuple<std::vector<redis::Reply>, std::string>& t) {
|
||||
return locate_sets_in_db(parRedis, parSubstr, std::vector<GroupIDType>(), parCaseInsensitive);
|
||||
}
|
||||
|
||||
std::vector<LocatedSet> locate_sets_in_db (redis::IncRedis& parRedis, const std::string& parSubstr, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive) {
|
||||
using dinhelp::lexical_cast;
|
||||
|
||||
auto filter_case_ins = [&parSubstr, &parSets](const boost::tuple<std::vector<redis::Reply>, std::string>& t) {
|
||||
const auto& s = redis::get_string(t.get<0>()[0]);
|
||||
return s.end() != std::search(
|
||||
s.begin(),
|
||||
s.end(),
|
||||
parSubstr.begin(),
|
||||
parSubstr.end(),
|
||||
[](char c1, char c2) {return std::toupper(c1) == std::toupper(c2);}
|
||||
);
|
||||
[](char c1, char c2) {return std::toupper(c1) == std::toupper(c2);}) and
|
||||
(
|
||||
parSets.empty() or
|
||||
std::find(parSets.begin(), parSets.end(), lexical_cast<GroupIDType>(t.get<1>())) != parSets.end()
|
||||
);
|
||||
};
|
||||
auto filter_case_sens = [&parSubstr](const boost::tuple<std::vector<redis::Reply>, std::string>& t) {
|
||||
return redis::get_string(t.get<0>()[0]).find(parSubstr) != std::string::npos;
|
||||
auto filter_case_sens = [&parSubstr, &parSets](const boost::tuple<std::vector<redis::Reply>, std::string>& t) {
|
||||
return redis::get_string(t.get<0>()[0]).find(parSubstr) != std::string::npos and
|
||||
(
|
||||
parSets.empty() or
|
||||
std::find(parSets.begin(), parSets.end(), lexical_cast<GroupIDType>(t.get<1>())) != parSets.end()
|
||||
);
|
||||
};
|
||||
std::function<bool(const boost::tuple<std::vector<redis::Reply>, std::string>&)> filter;
|
||||
if (parCaseInsensitive)
|
||||
|
@ -246,5 +259,6 @@ namespace dindb {
|
|||
filter = filter_case_sens;
|
||||
|
||||
return locate_in_bursts<LocatedSet>(parRedis, PROGRAM_NAME ":set:*", filter, "desc", "item_count", "dir_count");
|
||||
|
||||
}
|
||||
} //namespace dindb
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace dindb {
|
|||
std::vector<LocatedItem> locate_in_db ( redis::IncRedis& parRedis, const std::string& parRegex, const TagList& parTags );
|
||||
std::vector<LocatedItem> locate_in_db ( redis::IncRedis& parRedis, const mchlib::TigerHash& parSearch, const TagList& parTags );
|
||||
std::vector<LocatedSet> locate_sets_in_db ( redis::IncRedis& parRedis, const std::string& parSubstr, bool parCaseInsensitive );
|
||||
std::vector<LocatedSet> locate_sets_in_db ( redis::IncRedis& parRedis, const std::string& parSubstr, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive );
|
||||
} //namespace dindb
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue