idl-compiler: generate *_range methods using vector_deserializer

Generate code for *_range methods that return a
vector_deserializer rather than constructing the complete
vector of views.

This would be useful for streamed mutation unfreezing
in the following patch.

Later, we should just use vector_deserializer for all vectors.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2022-05-13 10:23:48 +03:00
parent 5b902d9fd6
commit 29632e739d

View File

@@ -1353,6 +1353,13 @@ def param_view_type(t):
return t.name + join_template_view(t.template_parameters, additional_types)
def element_type(t):
assert isinstance(t, TemplateType)
assert len(t.template_parameters) == 1
assert t.name != "boost::variant" and t.name != "std::variant"
return param_view_type(t.template_parameters[0])
read_sizes = set()
@@ -1424,6 +1431,18 @@ def add_view(cout, cls):
else:
deser = f"{DESERIALIZER}(in, boost::type<{full_type}>())"
if is_vector(m.type):
elem_type = element_type(m.type)
fprintln(cout, reindent(4, """
auto {name}_range() const {{
return seastar::with_serialized_stream(v, [this] (auto& v) {{
auto in = v;
{skip}
return vector_deserializer<{elem_type}>(in);
}});
}}
""").format(f=DESERIALIZER, **locals()))
fprintln(cout, reindent(4, """
auto {name}() const {{
return seastar::with_serialized_stream(v, [this] (auto& v) -> decltype({f}(std::declval<utils::input_stream&>(), boost::type<{full_type}>())) {{