ark::serialization::SchemaRegistry

Defined in header “ark/serialization/schema_registry.hh”.


A schema registry is a container that allows you to hold multiple schemas together in a single place. This allows you to quickly decode multiple “any” objects, even nested “any” objects, from one class.

You must manually add schemas into this registry for it to be able to decode “any” objects.

Methods

  • void add_schema(Schema schema)
    Adds a new schema to this registry. This will then be available for deserialization. If the schema already exists, this will throw.

  • void add_schema(std::shared_ptr< const Schema > schema)
    Adds a new schema to this registry. This will then be available for deserialization. If the schema already exists, this will throw.

  • void add_schemas(const std::vector< Schema > & schemas)
    Adds all of the schemas contained in the given list. If any schema in this list already exists, this will throw.

  • bool has_schema(const std::string & type_name)
    Returns true if a schema exists that matches the given type name, or false otherwise.

  • const Schema & schema(const std::string & type_name)
    Returns a reference to the given schema (by type name) if it exists, or throws an exception otherwise.

  • std::shared_ptr< const Schema > schema_ptr(const std::string & type_name)
    Returns a pointer to the given schema (by type name) if it exists, or throws an exception otherwise.

  • std::vector< Schema > schemas()
    Returns all of the schemas in this registry.

  • void add_enum(EnumDescriptor descriptor)
    Adds a new enumeration to this registry. This will then be available for deserialization. If the enumeration already exists, then this will throw.

  • void add_enums(const std::vector< EnumDescriptor > & enums)
    Adds all of the enums contained in the given list. If any enum in this list already exists, this will throw.

  • bool has_enum(const std::string & type_name)
    Returns true if a enum exists that matches the given type name, or false otherwise.

  • const EnumDescriptor & enum_descriptor(const std::string & type_name)
    Returns a reference to the given enum (by type name) if it exists, or throws an exception otherwise.

  • std::vector< EnumDescriptor > enums()
    Returns all of the enumerated descriptors in this registry.

  • SchemaRegistry minimal_registry(const std::string & type_name)
    Returns a new schema registry containing only the types necessary to support the given schema.

  • void merge(const SchemaRegistry & other)
    Merges the given registry into this registry. If any types already exist in this registry, they will be ignored.

  • void validate()
    Validates the registry does some sanity checks to ensure that all expected types are present. Throws if validation fails.

  • size_t schema_count()
    Returns the count of schemas stored in this registry.

  • size_t enum_count()
    Returns the count of enums stored in this registry.

  • bool operator==(const SchemaRegistry & other)
    Comparison operator, for equality checking.