Class: Arrow::StructArrayBuilder
- Inherits:
-
Object
- Object
- Arrow::StructArrayBuilder
- Defined in:
- lib/arrow/struct-array-builder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](index_or_name) ⇒ Object
- #append(*values) ⇒ Object
- #append_null ⇒ Object
- #append_null_raw ⇒ Object
- #append_value(*args) ⇒ Object
- #append_value_raw ⇒ Object
- #append_values(values, is_valids = nil) ⇒ Object
- #find_field_builder(index_or_name) ⇒ Object
Class Method Details
.build(data_type, values) ⇒ Object
21 22 23 24 |
# File 'lib/arrow/struct-array-builder.rb', line 21 def build(data_type, values) builder = new(data_type) builder.build(values) end |
Instance Method Details
#[](index_or_name) ⇒ Object
27 28 29 |
# File 'lib/arrow/struct-array-builder.rb', line 27 def [](index_or_name) find_field_builder(index_or_name) end |
#append(*values) ⇒ Object
117 118 119 120 121 122 123 124 |
# File 'lib/arrow/struct-array-builder.rb', line 117 def append(*values) if values.empty? # For backward compatibility append_value_raw else super end end |
#append_null ⇒ Object
109 110 111 112 113 114 |
# File 'lib/arrow/struct-array-builder.rb', line 109 def append_null append_null_raw cached_field_builders.each do |builder| builder.append_null end end |
#append_null_raw ⇒ Object
108 |
# File 'lib/arrow/struct-array-builder.rb', line 108 alias_method :append_null_raw, :append_null |
#append_value ⇒ Object #append_value(value) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/arrow/struct-array-builder.rb', line 60 def append_value(*args) n_args = args.size case n_args when 0 append_value_raw when 1 value = args[0] case value when nil append_null when ::Array append_value_raw value.each_with_index do |sub_value, i| self[i].append(sub_value) end when Hash append_value_raw value.each do |name, sub_value| self[name].append(sub_value) end else = "struct value must be nil, Array or Hash: #{value.inspect}" raise ArgumentError, end else = "wrong number of arguments (given #{n_args}, expected 0..1)" raise ArgumentError, end end |
#append_value_raw ⇒ Object
42 |
# File 'lib/arrow/struct-array-builder.rb', line 42 alias_method :append_value_raw, :append_value |
#append_values(values, is_valids = nil) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/arrow/struct-array-builder.rb', line 92 def append_values(values, is_valids=nil) if is_valids is_valids.each_with_index do |is_valid, i| if is_valid append_value(values[i]) else append_null end end else values.each do |value| append_value(value) end end end |
#find_field_builder(index_or_name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/arrow/struct-array-builder.rb', line 31 def find_field_builder(index_or_name) case index_or_name when String, Symbol name = index_or_name (@name_to_builder ||= build_name_to_builder)[name.to_s] else index = index_or_name cached_field_builders[index] end end |