From: Tomasz Grabiec <
tgra...@scylladb.com>
Committer: Avi Kivity <
a...@scylladb.com>
Branch: next
position_in_partition: Introduce reversed() transformation
It transforms the position from a forward-clustering-order schema
domain to a reversed-clustering-order schema domain.
The object still refers to the same element of the space of keys under this
transformation. However, the identification of the position,
the position_in_partition object, is schema-dependent, it is always
interpreted relative to some schema. Hence the need to transform it
when switching schema domains.
Message-Id: <
20210917102612.3...@scylladb.com>
---
diff --git a/position_in_partition.hh b/position_in_partition.hh
--- a/position_in_partition.hh
+++ b/position_in_partition.hh
@@ -59,6 +59,18 @@ enum class bound_weight : int8_t {
after_all_prefixed = 1,
};
+inline
+bound_weight reversed(bound_weight w) {
+ switch (w) {
+ case bound_weight::equal:
+ return w;
+ case bound_weight::before_all_prefixed:
+ return bound_weight::after_all_prefixed;
+ case bound_weight::after_all_prefixed:
+ return bound_weight::before_all_prefixed;
+ }
+}
+
inline
bound_weight position_weight(bound_kind k) {
switch (k) {
@@ -213,6 +225,11 @@ public:
friend std::ostream& operator<<(std::ostream& os, printer p);
};
+ // Create a position which is the same as this one but governed by a schema with reversed clustering key order.
+ position_in_partition_view reversed() const {
+ return position_in_partition_view(_type, ::reversed(_bound_weight), _ck);
+ }
+
friend std::ostream& operator<<(std::ostream& os, printer p);
friend std::ostream& operator<<(std::ostream&, position_in_partition_view);
friend bool no_clustering_row_between(const schema&, position_in_partition_view, position_in_partition_view);
@@ -522,6 +539,16 @@ public: