Merge remote-tracking branch 'origin/topic/johanna/1033'

- Fixed signed/unsigned comparison compiler warning
- Did other minor changes to address efficiency nitpicks

* origin/topic/johanna/1033:
  BrokerStore <-> Zeek Tables: support complex indices
This commit is contained in:
Jon Siwek 2020-11-17 13:32:57 -08:00
commit 824ff81bf6
17 changed files with 129 additions and 41 deletions

View file

@ -345,6 +345,32 @@ struct val_converter {
return rval;
}
else if ( type->Tag() == TYPE_LIST )
{
// lists are just treated as vectors on the broker side.
auto lt = type->AsTypeList();
auto pure = lt->IsPure();
const auto& types = lt->GetTypes();
if ( ! pure && a.size() > types.size() )
return nullptr;
auto lt_tag = pure ? lt->GetPureType()->Tag() : TYPE_ANY;
auto rval = make_intrusive<ListVal>(lt_tag);
unsigned int pos = 0;
for ( auto& item : a )
{
auto item_val = data_to_val(move(item), pure ? lt->GetPureType().get() : types[pos].get());
pos++;
if ( ! item_val )
return nullptr;
rval->Append(std::move(item_val));
}
return rval;
}
else if ( type->Tag() == TYPE_FUNC )
{
if ( a.size() < 1 || a.size() > 2 )
@ -955,6 +981,31 @@ broker::expected<broker::data> val_to_data(const Val* v)
rval.emplace_back(move(*item));
}
return {std::move(rval)};
}
case TYPE_LIST:
{
// We don't really support lists on the broker side.
// So we just pretend that it is a vector instead.
auto list = v->AsListVal();
broker::vector rval;
rval.reserve(list->Length());
for ( auto i = 0; i < list->Length(); ++i )
{
const auto& item_val = list->Idx(i);
if ( ! item_val )
continue;
auto item = val_to_data(item_val.get());
if ( ! item )
return broker::ec::invalid_data;
rval.emplace_back(move(*item));
}
return {std::move(rval)};
}
case TYPE_RECORD: