mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-07 23:43:31 +00:00
cql3: add value_for method
In order to extract value from a restriction for just one column, value_for(column_name, options) method is implemented. It's needed because once ALLOW FILTERING support was introduced, index-related restrictions may contain more than 1 value.
This commit is contained in:
@@ -68,6 +68,10 @@ public:
|
||||
|
||||
virtual std::vector<bytes_opt> values(const query_options& options) const = 0;
|
||||
|
||||
virtual bytes_opt value_for(const column_definition& cdef, const query_options& options) const {
|
||||
throw exceptions::invalid_request_exception("Single value can be obtained from single-column restrictions only");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if one of the restrictions use the specified function.
|
||||
*
|
||||
|
||||
@@ -310,6 +310,11 @@ public:
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
virtual bytes_opt value_for(const column_definition& cdef, const query_options& options) const override {
|
||||
return _restrictions->value_for(cdef, options);
|
||||
}
|
||||
|
||||
std::vector<bytes_opt> bounds(statements::bound b, const query_options& options) const override {
|
||||
// TODO: if this proved to be required.
|
||||
fail(unimplemented::cause::LEGACY_COMPOSITE_KEYS); // not 100% correct...
|
||||
|
||||
@@ -111,6 +111,11 @@ public:
|
||||
return r;
|
||||
}
|
||||
|
||||
virtual bytes_opt value_for(const column_definition& cdef, const query_options& options) const override {
|
||||
auto it = _restrictions.find(std::addressof(cdef));
|
||||
return (it != _restrictions.end()) ? it->second->value(options) : bytes_opt{};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the restriction associated to the specified column.
|
||||
*
|
||||
|
||||
@@ -72,6 +72,9 @@ public:
|
||||
// throw? should not reach?
|
||||
return {};
|
||||
}
|
||||
bytes_opt value_for(const column_definition& cdef, const query_options& options) const override {
|
||||
return {};
|
||||
}
|
||||
std::vector<T> values_as_keys(const query_options& options) const override {
|
||||
// throw? should not reach?
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user