-
Notifications
You must be signed in to change notification settings - Fork 20
/
kv_client_table.hpp
59 lines (50 loc) · 2.11 KB
/
kv_client_table.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include "base/abstract_partition_manager.hpp"
#include "base/magic.hpp"
#include "base/message.hpp"
#include "base/third_party/sarray.h"
#include "base/threadsafe_queue.hpp"
#include "worker/abstract_callback_runner.hpp"
#include <cinttypes>
#include <vector>
namespace csci5570 {
/**
* Provides the API to users, and implements the worker-side abstraction of model
* Each model in one application is uniquely handled by one KVClientTable
*
* @param Val type of model parameter values
*/
template <typename Val>
class KVClientTable {
public:
/**
* @param app_thread_id user thread id
* @param model_id model id
* @param sender_queue the work queue of a sender communication thread
* @param partition_manager model partition manager
* @param callback_runner callback runner to handle received replies from servers
*/
KVClientTable(uint32_t app_thread_id, uint32_t model_id, ThreadsafeQueue<Message>* const sender_queue,
const AbstractPartitionManager* const partition_manager, AbstractCallbackRunner* const callback_runner)
: app_thread_id_(app_thread_id),
model_id_(model_id),
sender_queue_(sender_queue),
partition_manager_(partition_manager),
callback_runner_(callback_runner){};
// ========== API ========== //
void Clock();
// vector version
void Add(const std::vector<Key>& keys, const std::vector<Val>& vals) {}
void Get(const std::vector<Key>& keys, std::vector<Val>* vals) {}
// sarray version
void Add(const third_party::SArray<Key>& keys, const third_party::SArray<Val>& vals) {}
void Get(const third_party::SArray<Key>& keys, third_party::SArray<Val>* vals) {}
// ========== API ========== //
private:
uint32_t app_thread_id_; // identifies the user thread
uint32_t model_id_; // identifies the model on servers
ThreadsafeQueue<Message>* const sender_queue_; // not owned
AbstractCallbackRunner* const callback_runner_; // not owned
const AbstractPartitionManager* const partition_manager_; // not owned
}; // class KVClientTable
} // namespace csci5570