mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-02-19 12:04:54 +00:00
Implement find_set_details().
This commit is contained in:
parent
d10ae6846d
commit
d7c254e1a0
4 changed files with 41 additions and 7 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <cstdint>
|
||||
#include <boost/range/empty.hpp>
|
||||
#include <fstream>
|
||||
#include <ctime>
|
||||
|
||||
namespace dindb {
|
||||
namespace {
|
||||
|
@ -180,7 +181,8 @@ namespace dindb {
|
|||
"content_type", parSetData.content_type,
|
||||
"base_file_id", lexical_cast<std::string>(base_file_id),
|
||||
"item_count", lexical_cast<std::string>(parData.size()),
|
||||
"dir_count", lexical_cast<std::string>(std::count_if(parData.begin(), parData.end(), [](const mchlib::FileRecordData& r){return r.is_directory;}))
|
||||
"dir_count", lexical_cast<std::string>(std::count_if(parData.begin(), parData.end(), [](const mchlib::FileRecordData& r){return r.is_directory;})),
|
||||
"creation", lexical_cast<std::string>(std::time(nullptr))
|
||||
);
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
|
@ -204,7 +206,9 @@ namespace dindb {
|
|||
"is_symlink", (file_data.is_symlink ? '1' : '0'),
|
||||
"unreadable", (file_data.unreadable ? '1' : '0'),
|
||||
"hash_valid", (file_data.hash_valid ? '1' : '0'),
|
||||
"group_id", group_id
|
||||
"group_id", group_id,
|
||||
"atime", lexical_cast<std::string>(file_data.atime),
|
||||
"mtime", lexical_cast<std::string>(file_data.mtime)
|
||||
);
|
||||
|
||||
batch.sadd(
|
||||
|
@ -267,7 +271,7 @@ namespace dindb {
|
|||
}
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 4>> BackendRedis::find_set_details (const std::vector<GroupIDType>& parSets) {
|
||||
return std::vector<dinhelp::MaxSizedArray<std::string, 4>>();
|
||||
return dindb::find_set_details(m_redis, parSets);
|
||||
}
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 1>> BackendRedis::find_file_details (GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir) {
|
||||
|
|
|
@ -84,7 +84,6 @@ namespace dindb {
|
|||
using boost::adaptors::transformed;
|
||||
using boost::tuple;
|
||||
using boost::make_tuple;
|
||||
using redis::get_string;
|
||||
using redis::Reply;
|
||||
using std::vector;
|
||||
using dinhelp::lexical_cast;
|
||||
|
@ -259,6 +258,35 @@ namespace dindb {
|
|||
filter = filter_case_sens;
|
||||
|
||||
return locate_in_bursts<LocatedSet>(parRedis, PROGRAM_NAME ":set:*", filter, "desc", "item_count", "dir_count");
|
||||
|
||||
}
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 4>> find_set_details (redis::IncRedis& parRedis, const std::vector<GroupIDType>& parSets) {
|
||||
using dinhelp::lexical_cast;
|
||||
using MArr = dinhelp::MaxSizedArray<std::string, 4>;
|
||||
|
||||
auto batch = parRedis.make_batch();
|
||||
for (auto set_id : parSets) {
|
||||
const auto set_key = PROGRAM_NAME ":set:" + lexical_cast<std::string>(set_id);
|
||||
batch.hmget(set_key, "creation", "name", "disk_label");
|
||||
}
|
||||
batch.throw_if_failed();
|
||||
|
||||
std::vector<MArr> retval;
|
||||
auto curr_set = parSets.begin();
|
||||
for (const auto& reply : batch.replies()) {
|
||||
const auto& reply_list = get_array(reply);
|
||||
if (redis::RedisVariantType_Nil != reply_list[0].which() and
|
||||
redis::RedisVariantType_Nil != reply_list[1].which() and
|
||||
redis::RedisVariantType_Nil != reply_list[2].which())
|
||||
{
|
||||
retval.resize(retval.size() + 1);
|
||||
retval.back().push_back(lexical_cast<std::string>(*curr_set));
|
||||
retval.back().push_back(get_string(reply_list[1]));
|
||||
retval.back().push_back(get_string(reply_list[0]));
|
||||
retval.back().push_back(get_string(reply_list[2]));
|
||||
}
|
||||
++curr_set;
|
||||
}
|
||||
return retval;
|
||||
};
|
||||
} //namespace dindb
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define idB4972996B4494E66A03B6AE205B1FA36
|
||||
|
||||
#include "backends/db_backend.hpp"
|
||||
#include "helpers/MaxSizedArray.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace redis {
|
||||
|
@ -31,6 +32,7 @@ namespace dindb {
|
|||
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 );
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 4>> find_set_details ( redis::IncRedis& parRedis, const std::vector<GroupIDType>& parSets );
|
||||
} //namespace dindb
|
||||
|
||||
#endif
|
||||
|
|
|
@ -78,9 +78,9 @@ namespace redis {
|
|||
|
||||
private:
|
||||
template <typename T>
|
||||
Reply forward_scan_command ( typename std::enable_if<HasScanTargetMethod<T>::value, int>::type parDummy );
|
||||
Reply forward_scan_command ( typename std::enable_if<HasScanTargetMethod<T>::value, long long>::type parContext );
|
||||
template <typename T>
|
||||
Reply forward_scan_command ( typename std::enable_if<not HasScanTargetMethod<T>::value, int>::type parDummy );
|
||||
Reply forward_scan_command ( typename std::enable_if<not HasScanTargetMethod<T>::value, long long>::type parContext );
|
||||
bool is_end ( void ) const;
|
||||
|
||||
void increment ( void );
|
||||
|
|
Loading…
Add table
Reference in a new issue