Class: Arrow::Array

Inherits:
Object
  • Object
show all
Includes:
GenericFilterable, GenericTakeable, Enumerable
Defined in:
lib/arrow/array.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GenericTakeable

included, #take_generic

Methods included from GenericFilterable

#filter_generic, included

Class Method Details

.builder_classObject



32
33
34
35
36
# File 'lib/arrow/array.rb', line 32

def builder_class
  builder_class_name = "#{name}Builder"
  return nil unless const_defined?(builder_class_name)
  const_get(builder_class_name)
end

.new(*args) ⇒ Object



25
26
27
28
29
30
# File 'lib/arrow/array.rb', line 25

def new(*args)
  _builder_class = builder_class
  return super if _builder_class.nil?
  return super unless _builder_class.buildable?(args)
  _builder_class.build(*args)
end

Instance Method Details

#[](i) ⇒ Object?

Returns The ‘i`-th value.

‘nil` for NULL value or out of range `i`.

Parameters:

  • i (Integer)

    The index of the value to be gotten.

    You can specify negative index like for ‘::Array#[]`.

Returns:

  • (Object, nil)

    The ‘i`-th value.

    ‘nil` for NULL value or out of range `i`.



48
49
50
51
52
53
54
55
56
# File 'lib/arrow/array.rb', line 48

def [](i)
  i += length if i < 0
  return nil if i < 0 or i >= length
  if null?(i)
    nil
  else
    get_value(i)
  end
end

#eachObject



58
59
60
61
62
63
64
# File 'lib/arrow/array.rb', line 58

def each
  return to_enum(__method__) unless block_given?

  length.times do |i|
    yield(self[i])
  end
end

#is_in(values) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/arrow/array.rb', line 88

def is_in(values)
  case values
  when ::Array
    if self.class.builder_class.buildable?([values])
      values = self.class.new(values)
    else
      values = self.class.new(value_data_type, values)
    end
    is_in_raw(values)
  when ChunkedArray
    is_in_chunked_array(values)
  else
    is_in_raw(values)
  end
end

#is_in_rawObject



87
# File 'lib/arrow/array.rb', line 87

alias_method :is_in_raw, :is_in

#reverse_eachObject



66
67
68
69
70
71
72
# File 'lib/arrow/array.rb', line 66

def reverse_each
  return to_enum(__method__) unless block_given?

  (length - 1).downto(0) do |i|
    yield(self[i])
  end
end

#to_aObject



83
84
85
# File 'lib/arrow/array.rb', line 83

def to_a
  values
end

#to_arrowObject



74
75
76
# File 'lib/arrow/array.rb', line 74

def to_arrow
  self
end

#value_data_typeObject



79
80
81
# File 'lib/arrow/array.rb', line 79

def value_data_type
  @value_data_type ||= value_data_type_raw
end

#value_data_type_rawObject



78
# File 'lib/arrow/array.rb', line 78

alias_method :value_data_type_raw, :value_data_type