From eaa61ba86cf689c5e7f336f6e7781b1c0fbb0aab Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Mon, 25 May 2015 17:48:38 -0400 Subject: [PATCH] sstables: encode logic for creating a static key component in composite Signed-off-by: Glauber Costa --- sstables/key.cc | 7 +++++++ sstables/key.hh | 1 + 2 files changed, 8 insertions(+) diff --git a/sstables/key.cc b/sstables/key.cc index 3365991c3e..df09607b6e 100644 --- a/sstables/key.cc +++ b/sstables/key.cc @@ -127,6 +127,13 @@ composite composite::from_exploded(const std::vector& v) { return from_components(v.begin(), v.end(), std::vector(v.size(), bytes_type), true); } +composite composite::static_prefix(const schema& s) { + static bytes static_marker(size_t(2), bytes::value_type(0xff)); + + std::vector sv(s.clustering_key_size()); + return static_marker + from_components(sv.begin(), sv.end(), std::vector(sv.size(), bytes_type), true); +} + inline std::vector explode_composite(bytes_view _bytes) { std::vector ret; diff --git a/sstables/key.hh b/sstables/key.hh index e542f7078f..000bda3090 100644 --- a/sstables/key.hh +++ b/sstables/key.hh @@ -115,6 +115,7 @@ public: static composite from_bytes(bytes b) { return composite(std::move(b)); } static composite from_clustering_key(const schema& s, const clustering_key& ck); static composite from_exploded(const std::vector& v); + static composite static_prefix(const schema& s); explicit operator bytes_view() const { return _bytes; }