-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathSessionInfo.cpp
50 lines (43 loc) · 1.14 KB
/
SessionInfo.cpp
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
#include <Interpreters/Streaming/SessionInfo.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
namespace DB
{
namespace Streaming
{
void SessionInfo::serialize(WriteBuffer & wb) const
{
writeIntBinary(id, wb);
writeIntBinary(win_start, wb);
writeIntBinary(win_end, wb);
writeIntBinary(timeout_ts, wb);
writeIntBinary(max_session_ts, wb);
writeBoolText(active, wb);
}
void SessionInfo::deserialize(ReadBuffer & rb)
{
readIntBinary(id, rb);
readIntBinary(win_start, rb);
readIntBinary(win_end, rb);
readIntBinary(timeout_ts, rb);
readIntBinary(max_session_ts, rb);
readBoolText(active, rb);
}
void serialize(const SessionInfoQueue & sessions, WriteBuffer & wb)
{
writeIntBinary(sessions.size(), wb);
for (const auto & session_info : sessions)
session_info->serialize(wb);
}
void deserialize(SessionInfoQueue & sessions, ReadBuffer & rb)
{
size_t num_sessions;
readIntBinary(num_sessions, rb);
for (size_t i = 0; i < num_sessions; ++i)
{
auto & session_info = sessions.emplace_back(std::make_shared<SessionInfo>());
session_info->deserialize(rb);
}
}
}
}