Method: Aerospike::MultiCommand#parse_record

Defined in:
lib/aerospike/command/multi_command.rb

#parse_record(key, op_count, generation, expiration) ⇒ Object

Parses the given byte buffer and populate the result object. Returns the number of bytes that were parsed from the given buffer.



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/aerospike/command/multi_command.rb', line 178

def parse_record(key, op_count, generation, expiration)
  bins = op_count > 0 ? {} : nil
  i = 0
  while i < op_count
    raise Aerospike::Exceptions::QueryTerminated.new unless valid?

    read_bytes(8)

    op_size = @data_buffer.read_int32(0).ord
    particle_type = @data_buffer.read(5).ord
    name_size = @data_buffer.read(7).ord

    read_bytes(name_size)
    name = @data_buffer.read(0, name_size).force_encoding('utf-8')

    particle_bytes_size = op_size - (4 + name_size)
    read_bytes(particle_bytes_size)
    value = Aerospike.bytes_to_particle(particle_type, @data_buffer, 0, particle_bytes_size)

    bins[name] = value

    i = i.succ
  end

  Record.new(@node, key, bins, generation, expiration)
end