Avro
view release on metacpan or search on metacpan
lib/Avro/Schema.pm view on Meta::CPAN
sub add_name {
my $schema = shift;
my ($names) = @_;
my $name = $schema->fullname;
if ( exists $names->{ $name } ) {
throw Avro::Schema::Error::Parse( "Name $name is already defined" );
}
$names->{$name} = $schema;
Scalar::Util::weaken( $names->{$name} );
return;
}
sub fullname {
my $schema = shift;
return join ".",
grep { defined $_ && length $_ }
map { $schema->{$_ } }
qw/namespace name/;
}
lib/Avro/Schema.pm view on Meta::CPAN
my $name = $struct->{name};
throw Avro::Schema::Error::Parse("Record.Field.name is required")
unless defined $name && length $name;
my $type = $struct->{type};
throw Avro::Schema::Error::Parse("Record.Field.name is required")
unless defined $type && length $type;
$type = Avro::Schema->parse_struct($type, $names, $namespace);
my $field = { name => $name, type => $type };
#TODO: find where to weaken precisely
#Scalar::Util::weaken($struct->{type});
if (exists $struct->{default}) {
my $is_valid = $type->is_data_valid($struct->{default});
my $t = $type->type;
throw Avro::Schema::Error::Parse(
"default value doesn't validate $t: '$struct->{default}'"
) unless $is_valid;
## small Perlish special case
if ($type eq 'boolean') {
( run in 0.529 second using v1.01-cache-2.11-cpan-65fba6d93b7 )