Class: Arrow::StructArray

Inherits:
Object
  • Object
show all
Defined in:
lib/arrow/struct-array.rb

Instance Method Summary collapse

Instance Method Details

#fieldsObject



55
56
57
# File 'lib/arrow/struct-array.rb', line 55

def fields
  @fields ||= fields_raw
end

#fields_rawObject



54
# File 'lib/arrow/struct-array.rb', line 54

alias_method :fields_raw, :fields

#find_field(index) ⇒ Arrow::Array? #find_field(name) ⇒ Arrow::Array?

Overloads:

  • #find_field(index) ⇒ Arrow::Array?

    Returns The ‘index`-th field or `nil` for out of range.

    Parameters:

    • index (Integer)

      The index of the field to be found.

    Returns:

    • (Arrow::Array, nil)

      The ‘index`-th field or `nil` for out of range.

  • #find_field(name) ⇒ Arrow::Array?

    Returns The field that has ‘name` or `nil` for nonexistent name.

    Parameters:

    • index (String, Symbol)

      The name of the field to be found.

    Returns:

    • (Arrow::Array, nil)

      The field that has ‘name` or `nil` for nonexistent name.



43
44
45
46
47
48
49
50
51
52
# File 'lib/arrow/struct-array.rb', line 43

def find_field(index_or_name)
  case index_or_name
  when String, Symbol
    name = index_or_name
    (@name_to_field ||= build_name_to_field)[name.to_s]
  else
    index = index_or_name
    fields[index]
  end
end

#get_value(i) ⇒ Hash

Returns The ‘i`-th struct.

Parameters:

  • i (Integer)

    The index of the value to be gotten. You must specify the value index.

    You can use Array#[] for convenient value access.

Returns:

  • (Hash)

    The ‘i`-th struct.



26
27
28
29
30
31
32
# File 'lib/arrow/struct-array.rb', line 26

def get_value(i)
  value = {}
  value_data_type.fields.zip(fields) do |field, field_array|
    value[field.name] = field_array[i]
  end
  value
end