199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
# File 'lib/arrow/array-builder.rb', line 199
def append(*values)
value_convertable = respond_to?(:convert_to_arrow_value, true)
start_index = 0
current_index = 0
status = :value
values.each do |value|
if value.nil?
if status == :value
if start_index != current_index
target_values = values[start_index...current_index]
if value_convertable
target_values = target_values.collect do |v|
convert_to_arrow_value(v)
end
end
append_values(target_values, nil)
start_index = current_index
end
status = :null
end
else
if status == :null
append_nulls(current_index - start_index)
start_index = current_index
status = :value
end
end
current_index += 1
end
if start_index != current_index
if status == :value
if start_index == 0 and current_index == values.size
target_values = values
else
target_values = values[start_index...current_index]
end
if value_convertable
target_values = target_values.collect do |v|
convert_to_arrow_value(v)
end
end
append_values(target_values, nil)
else
append_nulls(current_index - start_index)
end
end
end
|