Class: Arrow::ChunkedArray

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

Instance Method Summary collapse

Methods included from GenericTakeable

included, #take_generic

Methods included from GenericFilterable

#filter_generic, included

Methods included from ArrayComputable

#max, #min, #uniq

Instance Method Details

#[](i) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/arrow/chunked-array.rb', line 52

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



105
106
107
108
109
110
# File 'lib/arrow/chunked-array.rb', line 105

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



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

def chunks
  @chunks ||= chunks_raw
end

#chunks_rawObject



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

alias_method :chunks_raw, :chunks

#count(options: nil) ⇒ Object



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

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

#each(&block) ⇒ Object



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

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

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

#each_chunk(&block) ⇒ Object



77
78
79
# File 'lib/arrow/chunked-array.rb', line 77

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

#null?(i) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#packObject



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

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



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

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



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

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

#uniqueObject



101
102
103
# File 'lib/arrow/chunked-array.rb', line 101

def unique
  compute("unique")
end

#valid?(i) ⇒ Boolean

Returns:

  • (Boolean)


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

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