sstables: Replace composite class
This patch replaces the sstables::composite class with the one in compound_compat.hh. Signed-off-by: Duarte Nunes <duarte@scylladb.com>
This commit is contained in:
@@ -151,29 +151,6 @@ key::to_partition_key(const schema& s) {
|
||||
return partition_key::from_exploded(s, explode(s));
|
||||
}
|
||||
|
||||
template <typename ClusteringElement>
|
||||
composite composite::from_clustering_element(const schema& s, const ClusteringElement& ce) {
|
||||
return from_components(ce.begin(s), ce.end(s), sstable_serializer());
|
||||
}
|
||||
|
||||
template composite composite::from_clustering_element(const schema& s, const clustering_key_prefix& ck);
|
||||
|
||||
composite composite::from_exploded(const std::vector<bytes_view>& v, composite_marker m) {
|
||||
if (v.size() == 0) {
|
||||
return bytes(size_t(1), bytes::value_type(m));
|
||||
}
|
||||
auto b = from_components(v.begin(), v.end(), sstable_serializer());
|
||||
b.back() = bytes::value_type(m);
|
||||
return composite(std::move(b));
|
||||
}
|
||||
|
||||
composite composite::static_prefix(const schema& s) {
|
||||
static bytes static_marker(size_t(2), bytes::value_type(0xff));
|
||||
|
||||
std::vector<bytes_view> sv(s.clustering_key_size());
|
||||
return static_marker + from_components(sv.begin(), sv.end(), sstable_serializer());
|
||||
}
|
||||
|
||||
inline
|
||||
std::vector<bytes> explode_composite(bytes_view _bytes) {
|
||||
std::vector<bytes> ret;
|
||||
@@ -208,10 +185,6 @@ std::vector<bytes> key_view::explode(const schema& s) const {
|
||||
return explode_composite(_bytes);
|
||||
}
|
||||
|
||||
std::vector<bytes> composite_view::explode() const {
|
||||
return explode_composite(_bytes);
|
||||
}
|
||||
|
||||
int key_view::tri_compare(const schema& s, partition_key_view other) const {
|
||||
auto lf = other.legacy_form(s);
|
||||
return lexicographical_tri_compare(
|
||||
|
||||
@@ -111,36 +111,4 @@ inline key maximum_key() {
|
||||
return key(key::kind::after_all_keys);
|
||||
};
|
||||
|
||||
class composite_view {
|
||||
bytes_view _bytes;
|
||||
public:
|
||||
composite_view(bytes_view b) : _bytes(b) {}
|
||||
|
||||
std::vector<bytes> explode() const;
|
||||
|
||||
explicit operator bytes_view() const {
|
||||
return _bytes;
|
||||
}
|
||||
};
|
||||
|
||||
class composite {
|
||||
bytes _bytes;
|
||||
public:
|
||||
composite (bytes&& b) : _bytes(std::move(b)) {}
|
||||
template <typename Describer>
|
||||
auto describe_type(Describer f) const { return f(const_cast<bytes&>(_bytes)); }
|
||||
|
||||
static composite from_bytes(bytes b) { return composite(std::move(b)); }
|
||||
template <typename ClusteringElement>
|
||||
static composite from_clustering_element(const schema& s, const ClusteringElement& ce);
|
||||
static composite from_exploded(const std::vector<bytes_view>& v, composite_marker m = composite_marker::none);
|
||||
static composite static_prefix(const schema& s);
|
||||
size_t size() const { return _bytes.size(); }
|
||||
explicit operator bytes_view() const {
|
||||
return _bytes;
|
||||
}
|
||||
operator composite_view() const {
|
||||
return composite_view(_bytes);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1068,14 +1068,14 @@ future<> sstable::load() {
|
||||
|
||||
// @clustering_key: it's expected that clustering key is already in its composite form.
|
||||
// NOTE: empty clustering key means that there is no clustering key.
|
||||
void sstable::write_column_name(file_writer& out, const composite& clustering_key, const std::vector<bytes_view>& column_names, composite_marker m) {
|
||||
void sstable::write_column_name(file_writer& out, const composite& clustering_key, const std::vector<bytes_view>& column_names, composite::eoc marker) {
|
||||
// FIXME: min_components and max_components also keep track of clustering
|
||||
// prefix, so we must merge clustering_key and column_names somehow and
|
||||
// pass the result to the functions below.
|
||||
column_name_helper::min_max_components(_c_stats.min_column_names, _c_stats.max_column_names, column_names);
|
||||
|
||||
// was defined in the schema, for example.
|
||||
auto c= composite::from_exploded(column_names, m);
|
||||
auto c = composite::from_exploded(column_names, marker);
|
||||
auto ck_bview = bytes_view(clustering_key);
|
||||
|
||||
// The marker is not a component, so if the last component is empty (IOW,
|
||||
@@ -1197,14 +1197,14 @@ void sstable::write_range_tombstone(file_writer& out,
|
||||
}
|
||||
|
||||
auto start_marker = start_kind == bound_kind::excl_start
|
||||
? composite_marker::end_range
|
||||
: composite_marker::start_range;
|
||||
? composite::eoc::end
|
||||
: composite::eoc::start;
|
||||
write_column_name(out, start, suffix, start_marker);
|
||||
column_mask mask = column_mask::range_tombstone;
|
||||
write(out, mask);
|
||||
auto end_marker = end_kind == bound_kind::excl_end
|
||||
? composite_marker::start_range
|
||||
: composite_marker::end_range;
|
||||
? composite::eoc::start
|
||||
: composite::eoc::end;
|
||||
write_column_name(out, end, suffix, end_marker);
|
||||
uint64_t timestamp = t.timestamp;
|
||||
uint32_t deletion_time = t.deletion_time.time_since_epoch().count();
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "mutation_reader.hh"
|
||||
#include "query-request.hh"
|
||||
#include "key_reader.hh"
|
||||
#include "compound_compat.hh"
|
||||
|
||||
namespace sstables {
|
||||
|
||||
@@ -481,7 +482,7 @@ private:
|
||||
void write_clustered_row(file_writer& out, const schema& schema, const clustering_row& clustered_row);
|
||||
void write_static_row(file_writer& out, const schema& schema, const row& static_row);
|
||||
void write_cell(file_writer& out, atomic_cell_view cell);
|
||||
void write_column_name(file_writer& out, const composite& clustering_key, const std::vector<bytes_view>& column_names, composite_marker m = composite_marker::none);
|
||||
void write_column_name(file_writer& out, const composite& clustering_key, const std::vector<bytes_view>& column_names, composite::eoc marker = composite::eoc::none);
|
||||
void write_column_name(file_writer& out, bytes_view column_names);
|
||||
void write_range_tombstone(file_writer& out, const composite& start, bound_kind start_kind, const composite& end, bound_kind stop_kind, std::vector<bytes_view> suffix, const tombstone t);
|
||||
void write_range_tombstone(file_writer& out, const composite& start, const composite& end, std::vector<bytes_view> suffix, const tombstone t) {
|
||||
|
||||
Reference in New Issue
Block a user