Change return value of OpaqueVal::DoSerialize.

Now it returns a broker::expected<broker::data>, instead of directly
returning a broker::data before. This means that broker::data does no
longer have to be abused to convey error information.

In a way it would be kind of neat to have more fine-granular broker error
types for this use-case - at the moment everything returns
broker::ec::invalid_data, which seems to be the only reasonable choice.
This commit is contained in:
Johanna Amann 2019-06-18 15:23:02 -07:00
parent 53cde131e9
commit e0f10fd6d3
6 changed files with 40 additions and 36 deletions

View file

@ -408,7 +408,7 @@ void TopkVal::IncrementCounter(Element* e, unsigned int count)
IMPLEMENT_OPAQUE_VALUE(TopkVal)
broker::data TopkVal::DoSerialize() const
broker::expected<broker::data> TopkVal::DoSerialize() const
{
broker::vector d = {size, numElements, pruned};
@ -416,7 +416,7 @@ broker::data TopkVal::DoSerialize() const
{
auto t = SerializeType(type);
if ( t == broker::none() )
return broker::none();
return broker::ec::invalid_data;
d.emplace_back(t);
}
@ -440,7 +440,7 @@ broker::data TopkVal::DoSerialize() const
d.emplace_back(element->epsilon);
auto v = bro_broker::val_to_data(element->value);
if ( ! v )
return broker::none();
return broker::ec::invalid_data;
d.emplace_back(*v);