Class: Arrow::StructArray

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

Constant Summary

Constants inherited from Array

Array::VectorAppender, Array::VectorEqualsVisitor

Instance Attribute Summary

Attributes inherited from Array

#vector

Instance Method Summary collapse

Methods inherited from Array

#+, #==, #[], builder_class, #cast, #close, #concatenate, #concatenate_raw, #each, #equal_array?, #initialize, #inspect, #is_in, #is_in_raw, #length, new, #null?, #resolve, #reverse_each, #size, #to_a, #to_arrow, #to_arrow_array, #to_arrow_chunked_array, #to_s, try_convert, #value_data_type, #value_data_type_raw, #values

Methods included from InputReferable

#refer_input, #share_input

Methods included from GenericTakeable

included, #take_generic

Methods included from GenericFilterable

#filter_generic, included

Methods included from ArrayComputable

#index, #max, #min, #uniq

Constructor Details

This class inherits a constructor from Arrow::Array

Instance Method Details

#fieldsObject

Raises:

  • (NotImplementedError)


105
106
107
# File 'lib/arrow/jruby/array.rb', line 105

def fields
  raise NotImplementedError
end

#fields_rawObject

Raises:

  • (NotImplementedError)


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

def fields
  raise NotImplementedError
end

#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