Class: Tarantool::Client::SpaceInfo

Inherits:
Data
  • Object
show all
Defined in:
tarantool-client/lib/tarantool/client/space_info.rb

Overview

Format and indexes of a space from the loaded schema. indexes maps names to IndexInfo in id order.

Defined Under Namespace

Classes: Field

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fields ⇒ Object (readonly)

Returns the value of attribute fields

Returns:

  • (Object) —

    the current value of fields



6
7
8
# File 'tarantool-client/lib/tarantool/client/space_info.rb', line 6

def fields
  @fields
end

#id ⇒ Object (readonly)

Returns the value of attribute id

Returns:

  • (Object) —

    the current value of id



6
7
8
# File 'tarantool-client/lib/tarantool/client/space_info.rb', line 6

def id
  @id
end

#indexes ⇒ Object (readonly)

Returns the value of attribute indexes

Returns:

  • (Object) —

    the current value of indexes



6
7
8
# File 'tarantool-client/lib/tarantool/client/space_info.rb', line 6

def indexes
  @indexes
end

#name ⇒ Object (readonly)

Returns the value of attribute name

Returns:

  • (Object) —

    the current value of name



6
7
8
# File 'tarantool-client/lib/tarantool/client/space_info.rb', line 6

def name
  @name
end

Class Method Details

.from_tuples(space, index_tuples) ⇒ Object



9
10
11
12
13
14
15
# File 'tarantool-client/lib/tarantool/client/space_info.rb', line 9

def self.from_tuples(space, index_tuples)
  id, _owner, name, _engine, _field_count, _flags, format = space
  fields = (format || []).map { |raw| SpaceInfo::Field.from_raw(raw) }
  indexes = index_tuples.map { |tuple| IndexInfo.from_tuple(tuple, fields) }.sort_by(&:id)

  new(id:, name:, fields:, indexes: indexes.to_h { |index| [index.name, index] })
end

Instance Method Details

#primary_index ⇒ Object



17
18
19
# File 'tarantool-client/lib/tarantool/client/space_info.rb', line 17

def primary_index
  indexes.each_value.find { |index| index.id.zero? }
end