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



74
75
76
77
78
79
80
81
# File 'lib/arrow/chunked-array.rb', line 74

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



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

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



45
46
47
48
49
50
51
# File 'lib/arrow/chunked-array.rb', line 45

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

#chunks_rawObject



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

alias_method :chunks_raw, :chunks

#count(options: nil) ⇒ Object



115
116
117
# File 'lib/arrow/chunked-array.rb', line 115

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

#each(&block) ⇒ Object



83
84
85
86
87
88
89
# File 'lib/arrow/chunked-array.rb', line 83

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

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

#each_chunk(&block) ⇒ Object



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

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

#get_chunk(i) ⇒ Object



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

def get_chunk(i)
  chunks[i]
end

#get_chunk_rawObject



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

alias_method :get_chunk_raw, :get_chunk

#null?(i) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#packObject



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/arrow/chunked-array.rb', line 103

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



91
92
93
94
95
96
97
# File 'lib/arrow/chunked-array.rb', line 91

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



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

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
# File 'lib/arrow/chunked-array.rb', line 31

def to_arrow_array
  combine
end

#to_arrow_chunked_arrayObject



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

def to_arrow_chunked_array
  self
end

#uniqueObject



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

def unique
  compute("unique")
end

#valid?(i) ⇒ Boolean

Returns:

  • (Boolean)


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

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