Get rid of SkipFnHolder

This commit is contained in:
Andrew Onyshchuk 2020-02-01 11:13:50 -06:00
parent 3c4f23f842
commit 16d4990088
2 changed files with 6 additions and 7 deletions

View File

@ -426,14 +426,14 @@ AvroDeserializer::SkipFn AvroDeserializer::createSkipFn(avro::NodePtr root_node)
}
case avro::AVRO_SYMBOLIC:
{
auto [it, inserted] = symbolic_skip_fn_map.emplace(root_node->name(), SkipFnHolder{});
auto [it, inserted] = symbolic_skip_fn_map.emplace(root_node->name(), SkipFn{});
if (inserted)
{
it->second.skip_fn = createSkipFn(avro::resolveSymbol(root_node));
it->second = createSkipFn(avro::resolveSymbol(root_node));
}
return [&holder = it->second](avro::Decoder & decoder)
return [&skip_fn = it->second](avro::Decoder & decoder)
{
holder.skip_fn(decoder);
skip_fn(decoder);
};
}
default:

View File

@ -28,7 +28,6 @@ public:
private:
using DeserializeFn = std::function<void(IColumn & column, avro::Decoder & decoder)>;
using SkipFn = std::function<void(avro::Decoder & decoder)>;
struct SkipFnHolder { SkipFn skip_fn; };
static DeserializeFn createDeserializeFn(avro::NodePtr root_node, DataTypePtr target_type);
SkipFn createSkipFn(avro::NodePtr root_node);
@ -41,9 +40,9 @@ private:
/// How to deserialize the corresponding field in Avro schema.
std::vector<DeserializeFn> deserialize_fns;
/// Map from name of named Avro type (record, enum, fixed) to SkipFn holder.
/// Map from name of named Avro type (record, enum, fixed) to SkipFn.
/// This is to avoid infinite recursion when Avro schema contains self-references. e.g. LinkedList
std::map<avro::Name, SkipFnHolder> symbolic_skip_fn_map;
std::map<avro::Name, SkipFn> symbolic_skip_fn_map;
};
class AvroRowInputFormat : public IRowInputFormat