Class: Arrow::ChunkedArray

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

Instance Method Summary collapse

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

Instance Method Details

#[](i) ⇒ Object



78
79
80
81
82
83
84
85
# File 'lib/arrow/chunked-array.rb', line 78

def [](i)
  i += length if i < 0
  chunks.each do |array|
    return array[i] if i < array.length
    i -= array.length
  end
  nil
end

#cast(target_data_type, options: nil) ⇒ Object



131
132
133
134
135
136
# File 'lib/arrow/chunked-array.rb', line 131

def cast(target_data_type, options: nil)
  casted_chunks = chunks.collect do |chunk|
    chunk.cast(target_data_type, options)
  end
  self.class.new(casted_chunks)
end

#chunksObject



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

def chunks
  @chunks ||= chunks_raw.tap do |_chunks|
    _chunks.each do |chunk|
      share_input(chunk)
    end
  end
end

#chunks_rawObject



48
# File 'lib/arrow/chunked-array.rb', line 48

alias_method :chunks_raw, :chunks

#count(options: nil) ⇒ Object



119
120
121
# File 'lib/arrow/chunked-array.rb', line 119

def count(options: nil)
  compute("count", options: options).value
end

#each(&block) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/arrow/chunked-array.rb', line 87

def each(&block)
  return to_enum(__method__) unless block_given?

  chunks.each do |array|
    array.each(&block)
  end
end

#each_chunk(&block) ⇒ Object



103
104
105
# File 'lib/arrow/chunked-array.rb', line 103

def each_chunk(&block)
  chunks.each(&block)
end

#get_chunk(i) ⇒ Object



58
59
60
# File 'lib/arrow/chunked-array.rb', line 58

def get_chunk(i)
  chunks[i]
end

#get_chunk_rawObject



57
# File 'lib/arrow/chunked-array.rb', line 57

alias_method :get_chunk_raw, :get_chunk

#null?(i) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
65
66
67
68
# File 'lib/arrow/chunked-array.rb', line 62

def null?(i)
  chunks.each do |array|
    return array.null?(i) if i < array.length
    i -= array.length
  end
  nil
end

#packObject



107
108
109
110
111
112
113
114
115
116
117
# File 'lib/arrow/chunked-array.rb', line 107

def pack
  first_chunk = chunks.first
  data_type = first_chunk.value_data_type
  case data_type
  when TimestampDataType
    builder = TimestampArrayBuilder.new(data_type)
    builder.build(to_a)
  else
    first_chunk.class.new(to_a)
  end
end

#reverse_each(&block) ⇒ Object



95
96
97
98
99
100
101
# File 'lib/arrow/chunked-array.rb', line 95

def reverse_each(&block)
  return to_enum(__method__) unless block_given?

  chunks.reverse_each do |array|
    array.reverse_each(&block)
  end
end

#sum(options: nil) ⇒ Object



123
124
125
# File 'lib/arrow/chunked-array.rb', line 123

def sum(options: nil)
  compute("sum", options: options).value
end

#to_arrowObject



27
28
29
# File 'lib/arrow/chunked-array.rb', line 27

def to_arrow
  self
end

#to_arrow_arrayObject



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

def to_arrow_array
  if n_chunks.zero?
    value_data_type.build_array([])
  else
    combine
  end
end

#to_arrow_chunked_arrayObject



39
40
41
# File 'lib/arrow/chunked-array.rb', line 39

def to_arrow_chunked_array
  self
end

#uniqueObject



127
128
129
# File 'lib/arrow/chunked-array.rb', line 127

def unique
  compute("unique")
end

#valid?(i) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
73
74
75
76
# File 'lib/arrow/chunked-array.rb', line 70

def valid?(i)
  chunks.each do |array|
    return array.valid?(i) if i < array.length
    i -= array.length
  end
  nil
end