Files
scylladb/cql_serialization_format.hh
Avi Kivity 2739ac66ed treewide: drop cql_serialization_format
Now that we don't accept cql protocol version 1 or 2, we can
drop cql_serialization format everywhere, except when in the IDL
(since it's part of the inter-node protocol).

A few functions had duplicate versions, one with and one without
a cql_serialization_format parameter. They are deduplicated.

Care is taken that `partition_slice`, which communicates
the cql_serialization_format across nodes, still presents
a valid cql_serialization_format to other nodes when
transmitting itself and rejects protocol 1 and 2 serialization\
format when receiving. The IDL is unchanged.

One test checking the 16-bit serialization format is removed.
2023-01-03 19:54:13 +02:00

37 lines
1.1 KiB
C++

/*
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include <iostream>
#include <cstdint>
#include <exception>
using cql_protocol_version_type = uint8_t;
// Abstraction of transport protocol-dependent serialization format
// Protocols v1, v2 used 16 bits for collection sizes, while v3 and
// above use 32 bits. But letting every bit of the code know what
// transport protocol we're using (and in some cases, we aren't using
// any transport -- it's for internal storage) is bad, so abstract it
// away here.
class cql_serialization_format {
cql_protocol_version_type _version;
public:
static constexpr cql_protocol_version_type latest_version = 4;
explicit cql_serialization_format(cql_protocol_version_type version) : _version(version) {}
static cql_serialization_format latest() { return cql_serialization_format{latest_version}; }
cql_protocol_version_type protocol_version() const { return _version; }
void ensure_supported() const {
if (_version < 3) {
throw std::runtime_error("cql protocol version must be 3 or later");
}
}
};