1
This commit is contained in:
parent
32520caba0
commit
0e8bc69245
@ -102,32 +102,6 @@ a8::XObject DBEngine::GetConnInfo(long long data)
|
||||
return conn_info;
|
||||
}
|
||||
|
||||
void DBEngine::UpdateFriendApplyIdx(long long crc32_code, long long new_idx)
|
||||
{
|
||||
if (GetFriendApplyCurrIdx(crc32_code) < new_idx) {
|
||||
friend_apply_idx_hash_[GetInstanceId(crc32_code)] = new_idx;
|
||||
}
|
||||
}
|
||||
|
||||
long long DBEngine::GetFriendApplyCurrIdx(long long crc32_code)
|
||||
{
|
||||
auto itr = friend_apply_idx_hash_.find(GetInstanceId(crc32_code));
|
||||
return itr != friend_apply_idx_hash_.end() ? itr->second : 0;
|
||||
}
|
||||
|
||||
void DBEngine::UpdateGroupApplyIdx(long long crc32_code, long long new_idx)
|
||||
{
|
||||
if (GetGroupApplyCurrIdx(crc32_code) < new_idx) {
|
||||
group_apply_idx_hash_[GetInstanceId(crc32_code)] = new_idx;
|
||||
}
|
||||
}
|
||||
|
||||
long long DBEngine::GetGroupApplyCurrIdx(long long crc32_code)
|
||||
{
|
||||
auto itr = group_apply_idx_hash_.find(GetInstanceId(crc32_code));
|
||||
return itr != group_apply_idx_hash_.end() ? itr->second : 0;
|
||||
}
|
||||
|
||||
long long DBEngine::GetEventCurrIdx(long long crc32_code)
|
||||
{
|
||||
auto itr = event_idx_hash_.find(GetInstanceId(crc32_code));
|
||||
@ -158,37 +132,4 @@ void DBEngine::RefreshIdx()
|
||||
if (mysql_cluster_conf->Size() <= 0) {
|
||||
abort();
|
||||
}
|
||||
|
||||
auto on_ok =
|
||||
[] (a8::XParams& param, const f8::DataSet* data_set)
|
||||
{
|
||||
long long instance_idx = param.sender.GetInt64();
|
||||
const std::vector<std::string>& row0 = (*data_set)[0];
|
||||
const std::vector<std::string>& row1 = (*data_set)[1];
|
||||
long long friend_apply_idx = a8::XValue(row0[0]);
|
||||
long long event_idx = a8::XValue(row1[0]);
|
||||
DBEngine::Instance()->UpdateFriendApplyIdx(instance_idx, friend_apply_idx);
|
||||
DBEngine::Instance()->UpdateEventIdx(instance_idx, event_idx);
|
||||
};
|
||||
auto on_error =
|
||||
[] (a8::XParams& param, int error_code, const std::string& error_msg)
|
||||
{
|
||||
};
|
||||
|
||||
for (int i = 0; i < mysql_cluster_conf->Size(); ++i) {
|
||||
a8::XObject conn_info = GetConnInfo(i);
|
||||
DBEngine::Instance()->ExecAsyncQuery
|
||||
(
|
||||
conn_info,
|
||||
"SELECT IFNULL(MAX(idx), 0) FROM friend_apply UNION ALL "
|
||||
"SELECT IFNULL(MAX(idx), 0) FROM event;",
|
||||
{
|
||||
},
|
||||
a8::XParams()
|
||||
.SetSender(i),
|
||||
on_ok,
|
||||
on_error,
|
||||
i
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -32,13 +32,9 @@ class DBEngine : public a8::Singleton<DBEngine>
|
||||
a8::XObject GetConnInfo(const std::string& data);
|
||||
a8::XObject GetConnInfo(long long data);
|
||||
|
||||
long long GetFriendApplyCurrIdx(long long crc32_code);
|
||||
long long GetGroupApplyCurrIdx(long long crc32_code);
|
||||
long long GetEventCurrIdx(long long crc32_code);
|
||||
|
||||
private:
|
||||
void UpdateFriendApplyIdx(long long crc32_code, long long new_idx);
|
||||
void UpdateGroupApplyIdx(long long crc32_code, long long new_idx);
|
||||
void UpdateEventIdx(long long crc32_code, long long new_idx);
|
||||
|
||||
private:
|
||||
@ -46,8 +42,6 @@ private:
|
||||
void RefreshIdx();
|
||||
|
||||
private:
|
||||
std::map<long long, long long> friend_apply_idx_hash_;
|
||||
std::map<long long, long long> group_apply_idx_hash_;
|
||||
std::map<long long, long long> event_idx_hash_;
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user