ClickHouse/src/Common/TransactionID.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
917 B
C++
Raw Normal View History

2021-11-08 18:56:09 +00:00
#include <Common/TransactionID.h>
#include <Common/SipHash.h>
2021-12-30 13:15:28 +00:00
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
2021-11-08 18:56:09 +00:00
namespace DB
{
TIDHash TransactionID::getHash() const
{
SipHash hash;
hash.update(start_csn);
hash.update(local_tid);
hash.update(host_id);
return hash.get64();
}
2021-12-30 13:15:28 +00:00
void TransactionID::write(const TransactionID & tid, WriteBuffer & buf)
{
writeChar('(', buf);
writeText(tid.start_csn, buf);
writeCString(", ", buf);
writeText(tid.local_tid, buf);
writeCString(", ", buf);
writeText(tid.host_id, buf);
writeChar(')', buf);
}
TransactionID TransactionID::read(ReadBuffer & buf)
{
TransactionID tid = Tx::EmptyTID;
assertChar('(', buf);
readText(tid.start_csn, buf);
assertString(", ", buf);
readText(tid.local_tid, buf);
assertString(", ", buf);
readText(tid.host_id, buf);
assertChar(')', buf);
return tid;
}
2021-11-08 18:56:09 +00:00
}