Class: Avro::Schema::FixedSchema
- Inherits:
-
NamedSchema
- Object
- Avro::Schema
- NamedSchema
- Avro::Schema::FixedSchema
- Defined in:
- lib/avro/schema.rb
Constant Summary
Constants inherited from Avro::Schema
CRC_EMPTY, DECIMAL_LOGICAL_TYPE, DEFAULT_VALIDATE_OPTIONS, INT_MAX_VALUE, INT_MIN_VALUE, LONG_MAX_VALUE, LONG_MIN_VALUE, NAMED_TYPES, NAMED_TYPES_SYM, NAME_REGEX, PRIMITIVE_TYPES, PRIMITIVE_TYPES_SYM, SINGLE_OBJECT_MAGIC_NUMBER, VALID_TYPES, VALID_TYPES_SYM
Instance Attribute Summary collapse
-
#precision ⇒ Object
readonly
Returns the value of attribute precision.
-
#scale ⇒ Object
readonly
Returns the value of attribute scale.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from NamedSchema
Attributes inherited from Avro::Schema
Instance Method Summary collapse
-
#initialize(name, space, size, names = nil, logical_type = nil, aliases = nil, precision = nil, scale = nil) ⇒ FixedSchema
constructor
A new instance of FixedSchema.
- #match_schema?(schema) ⇒ Boolean
- #to_avro(names = Set.new) ⇒ Object
Methods inherited from NamedSchema
#fullname, #fullname_aliases, #match_fullname?
Methods inherited from Avro::Schema
#==, #be_read?, #crc_64_avro_fingerprint, #hash, #initFPTable, #md5_fingerprint, #mutual_read?, parse, #read?, real_parse, #sha256_fingerprint, #single_object_encoding_header, #single_object_schema_fingerprint, #subparse, #to_s, #type, #type_adapter, validate
Constructor Details
#initialize(name, space, size, names = nil, logical_type = nil, aliases = nil, precision = nil, scale = nil) ⇒ FixedSchema
Returns a new instance of FixedSchema.
533 534 535 536 537 538 539 540 541 542 |
# File 'lib/avro/schema.rb', line 533 def initialize(name, space, size, names=nil, logical_type=nil, aliases=nil, precision=nil, scale=nil) # Ensure valid cto args unless size.is_a?(Integer) raise AvroError, 'Fixed Schema requires a valid integer for size property.' end super(:fixed, name, space, names, nil, logical_type, aliases) @size = size @precision = precision @scale = scale end |
Instance Attribute Details
#precision ⇒ Object (readonly)
Returns the value of attribute precision.
532 533 534 |
# File 'lib/avro/schema.rb', line 532 def precision @precision end |
#scale ⇒ Object (readonly)
Returns the value of attribute scale.
532 533 534 |
# File 'lib/avro/schema.rb', line 532 def scale @scale end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
532 533 534 |
# File 'lib/avro/schema.rb', line 532 def size @size end |
Instance Method Details
#match_schema?(schema) ⇒ Boolean
554 555 556 557 558 559 560 561 562 |
# File 'lib/avro/schema.rb', line 554 def match_schema?(schema) return true if super && size == schema.size if logical_type == DECIMAL_LOGICAL_TYPE && schema.logical_type == DECIMAL_LOGICAL_TYPE return precision == schema.precision && (scale || 0) == (schema.scale || 0) end false end |
#to_avro(names = Set.new) ⇒ Object
544 545 546 547 548 549 550 551 552 |
# File 'lib/avro/schema.rb', line 544 def to_avro(names=Set.new) avro = super return avro if avro.is_a?(String) avro['size'] = size avro['precision'] = precision if precision avro['scale'] = scale if scale avro end |