mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-02-19 12:04:54 +00:00
Call wrapper methods instead of plain run().
This commit is contained in:
parent
f4c495c5ea
commit
d6682eb130
4 changed files with 19 additions and 22 deletions
|
@ -169,10 +169,9 @@ namespace dindb {
|
|||
assert(file_id_int >= data_size);
|
||||
const auto base_file_id = file_id_int - data_size + 1;
|
||||
|
||||
auto batch = m_redis.command().make_batch();
|
||||
auto batch = m_redis.make_batch();
|
||||
|
||||
batch.run(
|
||||
"HMSET",
|
||||
batch.hmset(
|
||||
set_key,
|
||||
"name", parSetData.name,
|
||||
"disk_label", parSetData.disk_label,
|
||||
|
@ -187,8 +186,7 @@ namespace dindb {
|
|||
const std::string file_key = PROGRAM_NAME ":file:" + lexical_cast<std::string>(z);
|
||||
const auto& file_data = parData[z - base_file_id];
|
||||
const std::string hash = tiger_to_string(file_data.hash);
|
||||
batch.run(
|
||||
"HMSET",
|
||||
batch.hmset(
|
||||
file_key,
|
||||
"hash", hash,
|
||||
"path", file_data.path(),
|
||||
|
@ -203,8 +201,7 @@ namespace dindb {
|
|||
"group_id", group_id
|
||||
);
|
||||
|
||||
batch.run(
|
||||
"SADD",
|
||||
batch.sadd(
|
||||
PROGRAM_NAME ":hash:" + hash,
|
||||
lexical_cast<std::string>(z)
|
||||
);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
namespace dindb {
|
||||
namespace {
|
||||
std::pair<bool, std::size_t> confirm_dele (redis::Batch& parBatch, const std::vector<GroupIDType>& parIDs, ConfirmDeleCallback parConf) {
|
||||
std::pair<bool, std::size_t> confirm_dele (redis::IncRedisBatch& parBatch, const std::vector<GroupIDType>& parIDs, ConfirmDeleCallback parConf) {
|
||||
using dinhelp::lexical_cast;
|
||||
|
||||
if (parIDs.empty())
|
||||
|
@ -37,7 +37,7 @@ namespace dindb {
|
|||
|
||||
for (auto id : parIDs) {
|
||||
const auto set_key = PROGRAM_NAME ":set:" + lexical_cast<std::string>(id);
|
||||
parBatch.run("HMGET", set_key, "base_file_id", "file_count", "name");
|
||||
parBatch.hmget(set_key, "base_file_id", "file_count", "name");
|
||||
}
|
||||
|
||||
std::map<GroupIDType, std::string> set_dele_list;
|
||||
|
@ -80,10 +80,10 @@ namespace dindb {
|
|||
using dinhelp::lexical_cast;
|
||||
using IDRange = std::tuple<GroupIDType, FileIDType, FileIDType>;
|
||||
|
||||
auto set_batch = parRedis.command().make_batch();
|
||||
auto set_batch = parRedis.make_batch();
|
||||
|
||||
auto dele_pair = confirm_dele(set_batch, parIDs, parConf);
|
||||
assert(set_batch.replies_requested());
|
||||
assert(set_batch.batch().replies_requested());
|
||||
if (not dele_pair.first)
|
||||
return;
|
||||
|
||||
|
@ -121,30 +121,30 @@ namespace dindb {
|
|||
delete_all_tags(parRedis, parDeleTagIfInSet, ids, set_id);
|
||||
}
|
||||
|
||||
auto dele_batch = parRedis.command().make_batch();
|
||||
auto dele_batch = parRedis.make_batch();
|
||||
for (const auto& dele_tuple : ranges) {
|
||||
const auto set_id = std::get<0>(dele_tuple);
|
||||
const auto file_base_index = std::get<1>(dele_tuple);
|
||||
const auto file_count = std::get<2>(dele_tuple);
|
||||
|
||||
auto hash_query_batch = parRedis.command().make_batch();
|
||||
auto hash_query_batch = parRedis.make_batch();
|
||||
for (FileIDType i = file_base_index; i < file_base_index + file_count; ++i) {
|
||||
const auto file_key = PROGRAM_NAME ":file:" + lexical_cast<std::string>(i);
|
||||
hash_query_batch.run("HGET", file_key, "hash");
|
||||
hash_query_batch.hget(file_key, "hash");
|
||||
}
|
||||
hash_query_batch.throw_if_failed();
|
||||
|
||||
for (const auto& rep : hash_query_batch.replies()) {
|
||||
const auto hash_key = PROGRAM_NAME ":hash:" + redis::get_string(rep);
|
||||
parDeleHash.run(
|
||||
dele_batch,
|
||||
dele_batch.batch(),
|
||||
std::make_tuple(hash_key),
|
||||
std::make_tuple(lexical_cast<std::string>(file_base_index), lexical_cast<std::string>(file_count))
|
||||
);
|
||||
}
|
||||
|
||||
dele_batch.run("DEL", PROGRAM_NAME ":set:" + lexical_cast<std::string>(set_id));
|
||||
chunked_run<FileIDType, 8>(dele_batch, +"DEL", file_base_index, file_count, [](FileIDType id){return PROGRAM_NAME ":file:" + lexical_cast<std::string>(id);});
|
||||
dele_batch.del(PROGRAM_NAME ":set:" + lexical_cast<std::string>(set_id));
|
||||
chunked_run<FileIDType, 8>(dele_batch.batch(), +"DEL", file_base_index, file_count, [](FileIDType id){return PROGRAM_NAME ":file:" + lexical_cast<std::string>(id);});
|
||||
}
|
||||
|
||||
dele_batch.throw_if_failed();
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace dindb {
|
|||
return true;
|
||||
}
|
||||
|
||||
void store_matching_paths (redis::Batch& parBatch, std::vector<LocatedItem>& parOut, std::vector<FileIDType>& parIDs, const boost::regex& parSearch, const TagList& parTags) {
|
||||
void store_matching_paths (redis::IncRedisBatch& parBatch, std::vector<LocatedItem>& parOut, std::vector<FileIDType>& parIDs, const boost::regex& parSearch, const TagList& parTags) {
|
||||
using dinhelp::lexical_cast;
|
||||
assert(parIDs.size() == parBatch.replies().size());
|
||||
|
||||
|
@ -87,10 +87,10 @@ namespace dindb {
|
|||
ids.reserve(prefetch_count);
|
||||
|
||||
int curr_count = 0;
|
||||
auto batch = parRedis.command().make_batch();
|
||||
auto batch = parRedis.make_batch();
|
||||
for (const auto& itm : parRedis.scan(PROGRAM_NAME ":file:*")) {
|
||||
++curr_count;
|
||||
batch.run("HMGET", itm, "path", "group_id", "tags");
|
||||
batch.hmget(itm, "path", "group_id", "tags");
|
||||
ids.push_back(lexical_cast<FileIDType>(split_and_trim(itm, ':').back()));
|
||||
|
||||
if (curr_count == prefetch_count) {
|
||||
|
|
|
@ -122,10 +122,10 @@ namespace dindb {
|
|||
}
|
||||
|
||||
void delete_all_tags (redis::IncRedis& parRedis, redis::Script& parDeleIfInSet, const std::vector<FileIDType>& parFiles, GroupIDType parSet) {
|
||||
auto batch = parRedis.command().make_batch();
|
||||
auto batch = parRedis.make_batch();
|
||||
for (const auto file_id : parFiles) {
|
||||
const auto file_key = make_file_key(file_id);
|
||||
batch.run("HGET", file_key, "tags");
|
||||
batch.hget(file_key, "tags");
|
||||
}
|
||||
|
||||
batch.throw_if_failed();
|
||||
|
|
Loading…
Add table
Reference in a new issue