Class: ArrowFormat::Array

Inherits:
Object
  • Object
show all
Defined in:
lib/arrow-format/array.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, size, validity_buffer) ⇒ Array

Returns a new instance of Array.



28
29
30
31
32
33
34
# File 'lib/arrow-format/array.rb', line 28

def initialize(type, size, validity_buffer)
  @type = type
  @size = size
  @offset = 0
  @validity_buffer = validity_buffer
  @sliced_buffers = {}
end

Instance Attribute Details

#offsetObject (readonly)

Returns the value of attribute offset.



26
27
28
# File 'lib/arrow-format/array.rb', line 26

def offset
  @offset
end

#sizeObject (readonly) Also known as: length

Returns the value of attribute size.



24
25
26
# File 'lib/arrow-format/array.rb', line 24

def size
  @size
end

#typeObject (readonly)

Returns the value of attribute type.



23
24
25
# File 'lib/arrow-format/array.rb', line 23

def type
  @type
end

#validity_bufferObject (readonly)

Returns the value of attribute validity_buffer.



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

def validity_buffer
  @validity_buffer
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/arrow-format/array.rb', line 59

def empty?
  @size.zero?
end

#n_nullsObject



51
52
53
54
55
56
57
# File 'lib/arrow-format/array.rb', line 51

def n_nulls
  if @validity_buffer.nil?
    0
  else
    @size - validity_bitmap.popcount
  end
end

#null?(i) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/arrow-format/array.rb', line 47

def null?(i)
  not valid?(i)
end

#slice(offset, size = nil) ⇒ Object



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

def slice(offset, size=nil)
  sliced = dup
  sliced.slice!(@offset + offset, size || @size - offset)
  sliced
end

#valid?(i) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
# File 'lib/arrow-format/array.rb', line 42

def valid?(i)
  return true if @validity_buffer.nil?
  validity_bitmap[i]
end