Class: Avro::IO::SingleObjectMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/ext/avro_patches.rb

Constant Summary collapse

SINGLE_OBJECT_MAGIC_NUMBER =
[0xC3, 0x01]

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ SingleObjectMessage

Returns a new instance of SingleObjectMessage.


41
42
43
# File 'lib/ext/avro_patches.rb', line 41

def initialize(schema)
  @schema = schema
end

Instance Method Details

#headerObject


46
47
48
# File 'lib/ext/avro_patches.rb', line 46

def header
  [SINGLE_OBJECT_MAGIC_NUMBER, schema_fingerprint].flatten
end

#schema_fingerprintObject


49
50
51
52
53
54
55
56
57
# File 'lib/ext/avro_patches.rb', line 49

def schema_fingerprint
  working = @schema.crc_64_avro_fingerprint
  bytes = Array.new(8)
  8.times do |i|
    bytes[7 - i] = (working & 0xff)
    working = working >> 8
  end
  bytes
end