Types
Array layout classes
In Python, we make a distinction between high-level ak.Array
(for data analysts) and low-level Content
memory layouts (for downstream developers). In Julia, it's more advantageous to expose the concrete type details to all users, particularly for defining functions with multiple dispatch. Thus, there is no ak.Array
equivalent.
The layout classes (subclasses of AwkwardArray.Content
) are:
Julia class | corresponding Python | corresponding Arrow | description |
---|---|---|---|
PrimitiveArray | NumpyArray | primitive | one-dimensional array of booleans, numbers, date-times, or time-differences |
EmptyArray | EmptyArray | (none) | length-zero array with unknown type (usually derived from untyped sources) |
ListOffsetArray | ListOffsetArray | list | variable-length lists defined by an index of offsets |
ListArray | ListArray | (none) | variable-length lists defined by more general starts and stops indexes |
RegularArray | RegularArray | fixed-size | lists of uniform size |
RecordArray | RecordArray with fields | struct | struct-like records with named fields of different types |
TupleArray | RecordArray with fields=None | (none) | tuples of unnamed fields of different types |
IndexedArray | IndexedArray | dictionary | data that are lazily filtered, duplicated, and/or rearranged by an integer index |
IndexedOptionArray | IndexedOptionArray | (none) | same but negative values in the index correspond to Missing values |
ByteMaskedArray | ByteMaskedArray | (none) | possibly-missing data, defined by a byte mask |
BitMaskedArray (only lsb_order = true ) | BitMaskedArray | bitmaps | same, defined by a BitVector |
UnmaskedArray | UnmaskedArray | same | in-principle missing data, but none are actually missing so no mask |
UnionArray | UnionArray | dense union | data of different types in the same array |
Any node in the data-type tree can carry Dict{String,Any}
metadata as parameters
, as well as a behavior::Symbol
that can be used to define specialized behaviors. For instance, arrays of strings (constructed with StringOffsetArray
, StringArray
, or StringRegularArray
) are defined by behavior = :string
(instead of behavior = :default
).
Types specification
AwkwardArray.BitMaskedArray
— TypeBitMaskedArray{CONTENT<:Content,BEHAVIOR} <: OptionType{BEHAVIOR}
Specialized array type designed to handle masked arrays, where certain elements can be marked as valid or invalid using a BitVector
.
Inherits from OptionType
.
struct BitMaskedArray{CONTENT<:Content,BEHAVIOR} <: OptionType{BEHAVIOR}
mask::BitVector
content::CONTENT
valid_when::Bool
parameters::Parameters
BitMaskedArray(
mask::BitVector,
content::CONTENT;
valid_when::Bool = false,
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {CONTENT<:Content} =
new{CONTENT,behavior}(mask, content, valid_when, parameters)
end
Type Parameters:
CONTENT<:Content
: TheCONTENT
type parameter is constrained to be a subtype ofContent
.BEHAVIOR
: A type parameter that can represent different behaviors associated with the array.
Inheritance:
<: OptionType{BEHAVIOR}
: Indicates thatBitMaskedArray
is a subtype ofOptionType
parameterized byBEHAVIOR
.
Fields:
mask::BitVector
: ABitVector
indicating which elements are valid or invalid.content::CONTENT
: The actual data content, constrained to be a subtype ofContent
.valid_when::Bool
: A flag indicating when the mask is valid (by defaultfalse
).
NumPy MaskedArray's convention; note that Arrow's is true
.
parameters::Parameters
: Additional parameters associated with the array, defined elsewhere.
Constructor:
BitMaskedArray(
mask::BitVector,
content::CONTENT;
valid_when::Bool = false,
parameters::Parameters = Parameters(),
behavior::Symbol = :default
) where {CONTENT<:Content}
This is the outer constructor for the BitMaskedArray
struct. It initializes a new instance of BitMaskedArray
with the given mask
, content
, and optional valid_when
, parameters
, and behavior
. The where {CONTENT<:Content}
clause ensures that CONTENT
satisfies the specified constraint.
new{CONTENT,behavior}(mask, content, valid_when, parameters)
creates a new instance of BitMaskedArray
with the specified type parameters and field values.
All Python BitMaskedArrays
must be converted to lsb_order = true
.
AwkwardArray.BitMaskedArray
— MethodBitMaskedArray{CONTENT}(;
valid_when::Bool = false,
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {CONTENT<:Content}
Outer constructor to create an instance of BitMaskedArray
with default or specified values for valid_when
, parameters
, and behavior
, while initializing the mask
and content
with default empty instances.
BitMaskedArray{CONTENT}(;
valid_when::Bool = false,
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {CONTENT<:Content} = BitMaskedArray(
BitVector(),
CONTENT(),
valid_when = valid_when,
parameters = parameters,
behavior = behavior,
)
AwkwardArray.ByteMaskedArray
— TypeByteMaskedArray{INDEX<:IndexBool, CONTENT<:Content, BEHAVIOR} <: OptionType{BEHAVIOR}
Specialized array type designed to handle arrays where elements can be optionally masked using a mask of type INDEX
(which is constrained to be a subtype of IndexBool
).
Inherits from OptionType
.
struct ByteMaskedArray{INDEX<:IndexBool, CONTENT<:Content, BEHAVIOR} <: OptionType{BEHAVIOR}
mask::INDEX
content::CONTENT
valid_when::Bool
parameters::Parameters
ByteMaskedArray(
mask::INDEX,
content::CONTENT;
valid_when::Bool = false, # the NumPy MaskedArray convention
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {INDEX<:IndexBool, CONTENT<:Content} =
new{INDEX, CONTENT, behavior}(mask, content, valid_when, parameters)
end
Type Parameters:
INDEX<:IndexBool
: TheINDEX
type parameter is constrained to be a subtype ofIndexBool
, indicating that the mask is of a specific boolean index type.CONTENT<:Content
: TheCONTENT
type parameter is constrained to be a subtype ofContent
.BEHAVIOR
: A type parameter that can represent different behaviors associated with the array.
Inheritance:
<: OptionType{BEHAVIOR}
: Indicates thatByteMaskedArray
is a subtype ofOptionType
parameterized byBEHAVIOR
.
Fields:
mask::INDEX
: The mask used to indicate valid or invalid elements, constrained to be a subtype ofIndexBool
.content::CONTENT
: The actual data content, constrained to be a subtype ofContent
.valid_when::Bool
: A flag indicating when themask
is valid (by defaultfalse
).parameters::Parameters
: Additional parameters associated with the array, defined elsewhere.
Constructor:
ByteMaskedArray(
mask::INDEX,
content::CONTENT;
valid_when::Bool = false,
parameters::Parameters = Parameters(),
behavior::Symbol = :default
) where {INDEX<:IndexBool, CONTENT<:Content}:
This is the outer constructor for the ByteMaskedArray
struct. It initializes a new instance of ByteMaskedArray
with the given mask
, content
, and optional valid_when
, parameters
, and behavior
. The where {INDEX<:IndexBool, CONTENT<:Content}
clause ensures that INDEX
and CONTENT
satisfy the specified constraints.
new{INDEX, CONTENT, behavior}(mask, content, valid_when, parameters)
creates a new instance of ByteMaskedArray
with the specified type parameters and field values.
AwkwardArray.ByteMaskedArray
— MethodByteMaskedArray{INDEX,CONTENT}(;
valid_when::Bool = false,
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {INDEX<:IndexBool} where {CONTENT<:Content}
Convenience constructor for the ByteMaskedArray
struct. This constructor allows you to create a ByteMaskedArray
instance with default values for its fields, particularly for the mask
and content
, by specifying only the optional parameters
.
ByteMaskedArray{INDEX,CONTENT}(;
valid_when::Bool = false,
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {INDEX<:IndexBool} where {CONTENT<:Content} = ByteMaskedArray(
INDEX([]),
CONTENT(),
valid_when = valid_when,
parameters = parameters,
behavior = behavior,
)
AwkwardArray.Content
— TypeAbstract Content type. Each layout is subtype from this.
List of functions
Every Content
subclass has the following built-in functions:
Base.length
Base.size
(1-tuple oflength
)Base.firstindex
,Base.lastindex
(1-based or inherited from its index)Base.getindex
: select byInt
(single item),UnitRange{Int}
(slice), andSymbol
(record field)Base.iterate
Base.:(==)
(equality defined by values: aListOffsetArray
and aListArray
may be considered the same)Base.push!
Base.append!
Base.show
They also have the following functions for manipulating and checking structure:
AwkwardArray.parameters_of
: gets all parametersAwkwardArray.has_parameter
: returns true if a parameter existsAwkwardArray.get_parameter
: returns a parameter or raises an errorAwkwardArray.with_parameter
: returns a copy of this node with a specified parameterAwkwardArray.copy
: shallow-copy of the array, allowing properties to be replacedAwkwardArray.is_valid
: verifies that the structure adheres to Awkward Array's protocol
They have the following functions for filling an array:
AwkwardArray.end_list!
: closes off aListType
array (ListOffsetArray
,ListArray
, orRegularArray
) in the manner of Python's ak.ArrayBuilder (nobegin_list
is necessary)AwkwardArray.end_record!
: closes off aRecordArray
AwkwardArray.end_tuple!
: closes off aTupleArray
AwkwardArray.push_null!
: pushes a missing value ontoOptionType
arrays (IndexedOptionArray
,ByteMaskedArray
,BitMaskedArray
, orUnmaskedArray
)AwkwardArray.push_dummy!
: pushes an unspecified value onto the array (used byByteMaskedArray
andBitMaskedArray
, which need to have a placeholder in memory behind eachmissing
value)
RecordArray
and TupleArray
have the following for selecting fields (as opposed to rows):
AwkwardArray.slot
: gets aRecordArray
orTupleArray
field, to avoid conflicts withBase.getindex
forTupleArrays
(both use integers to select a field)AwkwardArray.Record
: scalar representation of an item from aRecordArray
AwkwardArray.SlotRecord
: scalar representation of an item from aTupleArray
(note: not the same asBase.Tuple
)
UnionArray
has the following for dealing with specializations:
AwkwardArray.Specialization
: selects aUnionArray
specialization forpush!
,append!
, etc.
Finally, all Content
subclasses can be converted with the following:
AwkwardArray.layout_for
: returns an appropriately-nestedContent
type for a given Julia type (DataType
)AwkwardArray.from_iter
: converts Julia data into an Awkward ArrayAwkwardArray.to_vector
: converts an Awkward Array into Julia dataAwkwardArray.from_buffers
: constructs an Awkward Array from a Form (JSON), length, and buffers for zero-copy passing from PythonAwkwardArray.to_buffers
: deconstructs an Awkward Array into a Form (JSON), length, and buffers for zero-copy passing to Python
AwkwardArray.EmptyArray
— TypeRepresents an array that is always empty.
struct EmptyArray{BEHAVIOR} <: LeafType{BEHAVIOR}
behavior::Symbol
function EmptyArray(; behavior::Symbol = :default)
new{behavior}(behavior)
end
end
Type Parameter:
{BEHAVIOR}
: TheEmptyArray
type has a parameterBEHAVIOR
which is used to parameterize the type. This can be useful for specifying different behaviors or properties for different instances ofEmptyArray
.
Inheritance:
<: LeafType{BEHAVIOR}
: This indicates thatEmptyArray
is a subtype ofLeafType
with the sameBEHAVIOR
parameter.
Field:
behavior::Symbol
: This field stores aSymbol
indicating the behavior of the empty array. A Symbol in Julia is a type that represents interned strings and is often used for identifiers and labels.
Constructor:
function EmptyArray(; behavior::Symbol = :default)
: This is an inner constructor that allows for the creation of EmptyArray
instances. The behavior
argument is optional and defaults to :default
if not provided. new{behavior}(behavior)
: The new
function is used to create an instance of EmptyArray
with the specified behavior. The {behavior}
syntax is used to pass the type parameter to the instance.
AwkwardArray.IndexedArray
— TypeIndexedArray{INDEX<:IndexBig,CONTENT<:Content,BEHAVIOR} <: Content{BEHAVIOR}
IndexedArray
represents an array that references its elements through an index.
struct IndexedArray{INDEX<:IndexBig, CONTENT<:Content, BEHAVIOR} <: Content{BEHAVIOR}
index::INDEX
content::CONTENT
parameters::Parameters
IndexedArray(
index::INDEX,
content::CONTENT;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {INDEX<:IndexBig, CONTENT<:Content} =
new{INDEX, CONTENT, behavior}(index, content, parameters)
end
Type Parameters:
{INDEX<:IndexBig, CONTENT<:Content, BEHAVIOR}
: These are the type parameters for the struct.INDEX<:IndexBig
:INDEX
must be a subtype ofIndexBig
.CONTENT<:Content
:CONTENT
must be a subtype ofContent
.BEHAVIOR
: A type parameter for specifying behavior, often used for distinguishing different kinds of behaviors or properties in the array.
Inheritance:
<: Content{BEHAVIOR}
: This indicates thatIndexedArray
is a subtype ofContent
with the specifiedBEHAVIOR
parameter.
Fields:
index::INDEX
: An index of typeINDEX
, which is a subtype ofIndexBig
.content::CONTENT
: The actual content of the array, of typeCONTENT
, which is a subtype ofContent
.parameters::Parameters
: An instance ofParameters
that holds additional metadata or configuration for the array.
Constructor:
IndexedArray(index::INDEX, content::CONTENT; parameters::Parameters = Parameters(), behavior::Symbol = :default)
This is an inner constructor that allows for the creation of IndexedArray
instances. It takes the following arguments:
index
: The index for the array.content
: The content of the array.parameters
: Optional parameters for the array, defaulting to a newParameters
instance.behavior
: An optional symbol indicating the behavior, defaulting to:default
.
@example new{INDEX, CONTENT, behavior}(index, content, parameters)
The new
function is used to create an instance of IndexedArray
with the specified fields and type parameters.
AwkwardArray.IndexedArray
— MethodIndexedArray{INDEX,CONTENT}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {INDEX<:IndexBig} where {CONTENT<:Content}
Constructor for the IndexedArray
, allowing for the creation of an IndexedArray
with default values for its components when specific instances are not provided.
IndexedArray{INDEX, CONTENT}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {INDEX<:IndexBig} where {CONTENT<:Content} =
IndexedArray(INDEX([]), CONTENT(), parameters = parameters, behavior = behavior)
AwkwardArray.IndexedOptionArray
— TypeIndexedOptionArray{INDEX<:IndexBigSigned, CONTENT<:Content, BEHAVIOR} <: OptionType{BEHAVIOR}
A type of array where elements are indexed and can be optionally present or missing.
struct IndexedOptionArray{INDEX<:IndexBigSigned, CONTENT<:Content, BEHAVIOR} <: OptionType{BEHAVIOR}
index::INDEX
content::CONTENT
parameters::Parameters
IndexedOptionArray(
index::INDEX,
content::CONTENT;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {INDEX<:IndexBigSigned, CONTENT<:Content} =
new{INDEX, CONTENT, behavior}(index, content, parameters)
end
Type Parameters:
INDEX<:IndexBigSigned
: TheINDEX
type parameter must be a subtype ofIndexBigSigned
.CONTENT<:Content
: TheCONTENT
type parameter must be a subtype ofContent
.BEHAVIOR
: A type parameter without constraints, allowing flexibility in specifying behavior.
Fields:
index::INDEX
: Holds the index values, which determine the presence or absence of elements.content::CONTENT
: Holds the actual data elements.parameters::Parameters
: Holds any additional parameters or metadata associated with the array.
Constructor:
The inner constructor IndexedOptionArray takes three arguments: index
, content
, and optionally parameters
and behavior
. Default values are provided for parameters (Parameters()
) and behavior (:default
). The constructor uses new{INDEX, CONTENT, behavior}(index, content, parameters)
to create an instance of IndexedOptionArray
with the specified types and values.
Inheritance:
<: OptionType{BEHAVIOR}
means that IndexedOptionArray
is a subtype of OptionType{BEHAVIOR}
. This indicates that it is a specialized form of OptionType
designed to handle optional or nullable data.
AwkwardArray.IndexedOptionArray
— MethodIndexedOptionArray{INDEX,CONTENT}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {INDEX<:IndexBigSigned} where {CONTENT<:Content}
Constructor for the IndexedOptionArray
with default values for its parameters
and behavior
.
AwkwardArray.LeafType
— TypeLeafType{BEHAVIOR} <: Content{BEHAVIOR}
Abstract type LeafType
inherits from Content
and is parameterized by BEHAVIOR
.
This allows to create a flexible and hierarchical type system where different kinds of content can be represented, and specific behaviors can be parameterized.
All Python NumpyArrays have to be converted to 1-dimensional (inner_shape == ()) with RegularArrays when converting to Julia.
AwkwardArray.ListArray
— TypeListArray{INDEX<:IndexBig,CONTENT<:Content,BEHAVIOR} <: ListType{BEHAVIOR}
An array of variable-length lists, where the lengths and positions of the lists are specified by starts
and stops
indices.
Type Parameters:
INDEX<:IndexBig
: This ensures that the typeINDEX
is a subtype ofIndexBig
.CONTENT<:Content
: This ensures that the typeCONTENT
is a subtype ofContent
.BEHAVIOR
: This parameter allows for any type and is used to specify the behavior of theListArray
.
Fields:
starts::INDEX
: An index specifying the starting positions of the lists within the content.stops::INDEX
: An index specifying the stopping positions of the lists within the content.content::CONTENT
: The actual content of the array, which contains the elements of the lists.parameters::Parameters
: Additional parameters that can provide metadata or other information.
Constructor:
The primary constructor initializes a ListArray
with given starts
, stops
indices, and content
. parameters::Parameters = Parameters()
: This sets a default value for parameters if it is not provided when the constructor is called. behavior::Symbol = :default
: This sets a default value for behavior if it is not provided when the constructor is called.
AwkwardArray.ListArray
— MethodListArray{INDEX,CONTENT,BEHAVIOR}(;
parameters::Parameters = Parameters(),
) where {INDEX<:IndexBig} where {CONTENT<:Content} where {BEHAVIOR}
Constructor of a ListArray
with default parameters, initializing the starts, stops and content with default values.
AwkwardArray.ListArray
— MethodListArray{INDEX,CONTENT}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {INDEX<:IndexBig} where {CONTENT<:Content}
Constructor of a ListArray
with default parameters, initializing the starts, stops, content and behavior with default values.
AwkwardArray.ListOffsetArray
— TypeListOffsetArray{INDEX<:IndexBig,CONTENT<:Content,BEHAVIOR} <: ListType{BEHAVIOR}
A specialized array to represent variable-length lists within a larger array.
Type Parameters:
INDEX<:IndexBig
: Defines a type parameterINDEX
which is constrained to subtypes ofIndexBig
.IndexBig
typically refers to integer types capable of holding large indices, such asInt32
orInt64
.CONTENT<:Content
: Defines a type parameterCONTENT
which is constrained to subtypes ofContent
.BEHAVIOR
: A type parameter for behavior, used to define specialized behaviors or metadata associated with the array.
Inheritance:
<: ListType{BEHAVIOR}
: Indicates thatListOffsetArray
is a subtype ofListType
.
Fields:
offsets::INDEX
: An array of offsets that indicate the start of each sublist within the content array. The length of this array is one more than the number of sublists, with the last element pointing to the end of the last sublist.content::CONTENT
: The actual data stored in the array. This can be any kind of array or list of elements.parameters::Parameters
: A structure to hold additional parameters or metadata associated with the array.
AwkwardArray.ListOffsetArray
— MethodListOffsetArray{INDEX,CONTENT,BEHAVIOR}(;
parameters::Parameters = Parameters(),
) where {INDEX<:IndexBig} where {CONTENT<:Content} where {BEHAVIOR}
Constructor of a ListOffsetArray
with default parameters, initializing the offsets and content with default values.
AwkwardArray.ListOffsetArray
— MethodListOffsetArray{INDEX,CONTENT}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {INDEX<:IndexBig} where {CONTENT<:Content}
Constructor of a ListOffsetArray
with default parameters, initializing the offsets, content and behavior with default values.
AwkwardArray.ListType
— TypeListType{BEHAVIOR} <: Content{BEHAVIOR}
Abstract type ListType
inherits from Content
and is parameterized by BEHAVIOR
.
AwkwardArray.OptionType
— TypeOptionType{BEHAVIOR} <: Content{BEHAVIOR}
Abstract type that serves as a base for other types representing optional or nullable data.
AwkwardArray.Parameters
— TypeParameters
AwkwardArray.Parameters
— MethodParameters(pairs::Vararg{Pair{String,<:Any}})
AwkwardArray.Parameters
— MethodParameters()
AwkwardArray.PrimitiveArray
— TypePrimitiveArray{ITEM,BUFFER<:AbstractVector{ITEM},BEHAVIOR} <: LeafType{BEHAVIOR}
A specialized array type designed to handle primitive data types with additional parameters and behaviors.
Type Parameters:
ITEM
: Represents the type of the elements stored in the array.BUFFER<:AbstractVector{ITEM}
: ConstrainsBUFFER
to be a subtype ofAbstractVector
that holds items of typeITEM
.BEHAVIOR
: A type parameter that can represent different behaviors associated with the array.
Inheritance:
<: LeafType{BEHAVIOR}
: Indicates thatPrimitiveArray
is a subtype ofLeafType
parameterized byBEHAVIOR
.
Fields:
data::BUFFER
: The main storage for the array, constrained to be anAbstractVector
ofITEM
.parameters::Parameters
: Additional parameters associated with the array, presumably defined elsewhere in the code.
Constructor:
PrimitiveArray(data::BUFFER; parameters::Parameters = Parameters(), behavior::Symbol = :default) where {ITEM,BUFFER<:AbstractVector{ITEM}}
: This is the inner constructor for the PrimitiveArray struct. It initializes a new instance ofPrimitiveArray
with the given data and optional parameters and behavior. The where{ITEM,BUFFER<:AbstractVector{ITEM}}
clause ensures thatITEM
andBUFFER
satisfy the specified constraints.
new{ITEM,BUFFER,behavior}(data, parameters)
creates a new instance of PrimitiveArray
with the specified type parameters and field values.
AwkwardArray.PrimitiveArray
— MethodPrimitiveArray{ITEM,BUFFER,BEHAVIOR}(;
parameters::Parameters = Parameters(),
) where {ITEM,BUFFER<:AbstractVector{ITEM},BEHAVIOR}
AwkwardArray.PrimitiveArray
— MethodPrimitiveArray{ITEM,BUFFER}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {ITEM,BUFFER<:AbstractVector{ITEM}}
AwkwardArray.PrimitiveArray
— MethodPrimitiveArray{ITEM}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {ITEM}
AwkwardArray.Record
— TypeRecord{FIELDS,CONTENTS<:Base.Tuple{Vararg{Content}},BEHAVIOR}
AwkwardArray.RecordArray
— TypeRecordArray{FIELDS,CONTENTS<:Base.Tuple{Vararg{Content}},BEHAVIOR} <:Content{BEHAVIOR}
AwkwardArray.RecordArray
— MethodRecordArray(
contents::NamedTuple{FIELDS,CONTENTS};
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {FIELDS,CONTENTS<:Base.Tuple{Vararg{Content}}}
AwkwardArray.RecordArray
— MethodRecordArray{FIELDS,CONTENTS}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {FIELDS,CONTENTS<:Base.Tuple{Vararg{Content}}}
AwkwardArray.RegularArray
— TypeRegularArray{CONTENT<:Content,BEHAVIOR} <: ListType{BEHAVIOR}
A multidimensional array with a fixed size for each dimension, where the overall length of the array is determined by the size of its content and the specified size per dimension.
Type Parameters:
CONTENT<:Content
: Ensures that the typeCONTENT
is a subtype ofContent
.BEHAVIOR
: This parameter can be any type and is used to specify the behavior of theRegularArray
.
Fields:
content::CONTENT
: The actual content of the array, which contains the elements.size::Int64
: The fixed size for each dimension of the array.length::Int64
: The total length of the array, calculated based on thecontent
length andsize
.parameters::Parameters
: Additional parameters that can provide metadata or other information.
Constructor:
The constructor initializes a RegularArray
with the given content
and size
. zeros_length::Int = 0
: This sets a default value for the zeros_length
parameter if it is not provided. parameters::Parameters = Parameters()
: This sets a default value for parameters
if it is not provided. behavior::Symbol = :default
: This sets a default value for behavior
if it is not provided. The length of the array is calculated as zeros_length
if size is 0, otherwise it is calculated as the integer division of the length of content by size.
AwkwardArray.RegularArray
— MethodRegularArray{CONTENT}(
size::Int;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {CONTENT<:Content}
Constructor of a RegularArray
with default parameters, initializing the behavior and content with default values.
AwkwardArray.RegularArray
— MethodRegularArray{CONTENT,BEHAVIOR}(;
parameters::Parameters = Parameters(),
) where {CONTENT<:Content,BEHAVIOR}
Constructor of a RegularArray
with default parameters, initializing the size and content with default values.
AwkwardArray.RegularArray
— MethodRegularArray{CONTENT}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {CONTENT<:Content}
Constructor of a RegularArray
with default parameters, initializing the size, behavior and content with default values.
AwkwardArray.SlotRecord
— TypeSlotRecord{CONTENTS<:Base.Tuple{Vararg{Content}},BEHAVIOR}
AwkwardArray.Specialization
— TypeSpecialization{ARRAY<:UnionArray,TAGGED<:Content}
AwkwardArray.Specialization
— MethodSpecialization(layout::UnionArray, tag::Int)
AwkwardArray.TupleArray
— TypeTupleArray{CONTENTS<:Base.Tuple{Vararg{Content}},BEHAVIOR} <:
Content{BEHAVIOR}
AwkwardArray.TupleArray
— MethodTupleArray(
contents::CONTENTS;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {CONTENTS<:Base.Tuple{Vararg{Content}}}
AwkwardArray.TupleArray
— MethodTupleArray{CONTENTS}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {CONTENTS<:Base.Tuple{Vararg{Content}}}
AwkwardArray.UnionArray
— TypeUnionArray{
TAGS<:Index8,
INDEX<:IndexBig,
CONTENTS<:Base.Tuple{Vararg{Content}},
BEHAVIOR,
} <: Content{BEHAVIOR}
AwkwardArray.UnionArray
— MethodUnionArray{TAGS,INDEX,CONTENTS}(
contents::CONTENTS;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
)
AwkwardArray.UnionArray
— MethodUnionArray{TAGS,INDEX,CONTENTS}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
)
AwkwardArray.UnmaskedArray
— TypeUnmaskedArray{CONTENT<:Content,BEHAVIOR} <: OptionType{BEHAVIOR}
AwkwardArray.UnmaskedArray
— MethodUnmaskedArray{CONTENT}(;
parameters::Parameters = Parameters(),
behavior::Symbol = :default,
) where {CONTENT<:Content}
Examples
julia> using AwkwardArray: StringOffsetArray
julia> array = StringOffsetArray()
0-element ListOffsetArray{Vector{Int64}, PrimitiveArray{UInt8, Vector{UInt8}, :char}, :string}
julia> append!(array, ["one", "two", "three", "four", "five"])
5-element ListOffsetArray{Vector{Int64}, PrimitiveArray{UInt8, Vector{UInt8}, :char}, :string}:
"one"
"two"
"three"
"four"
"five"
julia> array[3]
"three"
julia> typeof(array[3])
String
Most applications of behavior
apply to RecordArrays
(e.g. Vector in Python).
Index
AwkwardArray.BitMaskedArray
AwkwardArray.BitMaskedArray
AwkwardArray.ByteMaskedArray
AwkwardArray.ByteMaskedArray
AwkwardArray.Content
AwkwardArray.EmptyArray
AwkwardArray.IndexedArray
AwkwardArray.IndexedArray
AwkwardArray.IndexedOptionArray
AwkwardArray.IndexedOptionArray
AwkwardArray.LeafType
AwkwardArray.ListArray
AwkwardArray.ListArray
AwkwardArray.ListArray
AwkwardArray.ListOffsetArray
AwkwardArray.ListOffsetArray
AwkwardArray.ListOffsetArray
AwkwardArray.ListType
AwkwardArray.OptionType
AwkwardArray.Parameters
AwkwardArray.Parameters
AwkwardArray.Parameters
AwkwardArray.PrimitiveArray
AwkwardArray.PrimitiveArray
AwkwardArray.PrimitiveArray
AwkwardArray.PrimitiveArray
AwkwardArray.Record
AwkwardArray.RecordArray
AwkwardArray.RecordArray
AwkwardArray.RecordArray
AwkwardArray.RegularArray
AwkwardArray.RegularArray
AwkwardArray.RegularArray
AwkwardArray.RegularArray
AwkwardArray.SlotRecord
AwkwardArray.Specialization
AwkwardArray.Specialization
AwkwardArray.TupleArray
AwkwardArray.TupleArray
AwkwardArray.TupleArray
AwkwardArray.UnionArray
AwkwardArray.UnionArray
AwkwardArray.UnionArray
AwkwardArray.UnmaskedArray
AwkwardArray.UnmaskedArray