ArrowArray constructor
Implementation
ArrowArray(
this.type,
List<ArrowValue?> values, {
List<bool>? validity,
this.dictionary,
List<ArrowArray> nestedDictionaries = const [],
}) : nestedDictionaries = List.unmodifiable(nestedDictionaries),
values = List.unmodifiable(values),
validity = List.unmodifiable(validity ?? values.map((v) => v != null)) {
if (this.validity.length != values.length) {
throw ArgumentError(
'Validity length ${this.validity.length} does not match value length ${values.length}',
);
}
for (var i = 0; i < values.length; i++) {
if (this.validity[i] != (values[i] != null)) {
throw ArgumentError('Validity and value disagree at index $i');
}
final value = values[i];
if (value != null) validateArrowValue(type, value, path: 'values[$i]');
}
if (_unwrapExtension(type) case final ArrowRunEndEncodedType ree) {
_checkRunEndLength(ree, values.length);
if (!ree.valuesField.nullable && this.validity.contains(false)) {
throw ArgumentError('Run-end encoded values field is not nullable');
}
}
if (_unwrapExtension(type) is ArrowUnionType &&
this.validity.contains(false)) {
throw ArgumentError(
'Union arrays have no top-level nulls; use ArrowUnionValue(id, null)',
);
}
_validateDictionaries(this);
}