mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
feat(server): Buffered journal serializers (#619)
This commit is contained in:
parent
f204f1c670
commit
7788600c9b
13 changed files with 240 additions and 189 deletions
|
@ -30,12 +30,27 @@ using nonstd::make_unexpected;
|
|||
dest = std::move(exp_res.value()); \
|
||||
}
|
||||
|
||||
// Represents meta information for an encoded packed unsigned integer.
|
||||
struct PackedUIntMeta {
|
||||
// Initialize by first byte in sequence.
|
||||
PackedUIntMeta(uint8_t first_byte) : first_byte{first_byte} {
|
||||
}
|
||||
|
||||
// Get underlying RDB type.
|
||||
int Type() const;
|
||||
|
||||
// Get additional size in bytes (excluding first one).
|
||||
unsigned ByteSize() const;
|
||||
|
||||
uint8_t first_byte;
|
||||
};
|
||||
|
||||
// Saves an packed unsigned integer. The first two bits in the first byte are used to
|
||||
// hold the encoding type. See the RDB_* definitions for more information
|
||||
// on the types of encoding. buf must be at least 9 bytes.
|
||||
unsigned WritePackedUInt(uint64_t value, uint8_t* buf);
|
||||
unsigned WritePackedUInt(uint64_t value, io::MutableBytes dest);
|
||||
|
||||
// Deserialize packed unsigned integer.
|
||||
io::Result<uint64_t> ReadPackedUInt(io::Source* source);
|
||||
io::Result<uint64_t> ReadPackedUInt(PackedUIntMeta meta, io::Bytes source);
|
||||
|
||||
} // namespace dfly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue