3#ifndef AWKWARD_CONTENT_H_
4#define AWKWARD_CONTENT_H_
19 using FormKey = std::shared_ptr<std::string>;
44 const std::vector<int64_t>& inner_shape);
93 bool check_identities,
94 bool check_parameters,
96 bool compatibility_check)
const = 0;
105 virtual const std::string
148 virtual const std::pair<int64_t, int64_t>
157 virtual const std::pair<bool, int64_t>
174 virtual const std::string
175 key(int64_t fieldindex)
const = 0;
180 haskey(
const std::string& key)
const = 0;
184 virtual const std::vector<std::string>
193 virtual const std::string
200 virtual const std::string
311 virtual const std::string
357 form(
bool materialize)
const = 0;
369 caches(std::vector<ArrayCachePtr>& out)
const = 0;
377 virtual const std::string
379 const std::string& pre,
380 const std::string& post)
const = 0;
426 bool copyidentities)
const = 0;
484 const Slice& only_fields)
const = 0;
493 const Slice& only_fields)
const = 0;
515 const Index64& advanced)
const;
530 const Slice& tail)
const;
563 virtual const std::string
591 virtual const std::pair<int64_t, int64_t>
600 virtual const std::pair<bool, int64_t>
617 virtual const std::string
618 key(int64_t fieldindex)
const = 0;
623 haskey(
const std::string& key)
const = 0;
627 virtual const std::vector<std::string>
636 virtual const std::string
661 num(int64_t axis, int64_t depth)
const = 0;
676 virtual const std::pair<Index64, ContentPtr>
719 virtual const std::pair<ContentPtrVec, ContentPtrVec>
767 rpad(int64_t target, int64_t axis, int64_t depth)
const = 0;
822 bool keepdims)
const = 0;
849 bool stable)
const = 0;
880 bool stable)
const = 0;
970 int64_t depth)
const = 0;
1002 const char* nan_string =
nullptr,
1003 const char* infinity_string =
nullptr,
1004 const char* minus_infinity_string =
nullptr,
1005 const char* complex_real_string =
nullptr,
1006 const char* complex_imag_string =
nullptr)
const;
1031 int64_t maxdecimals,
1033 const char* nan_string =
nullptr,
1034 const char* infinity_string =
nullptr,
1035 const char* minus_infinity_string =
nullptr,
1036 const char* complex_real_string =
nullptr,
1037 const char* complex_imag_string =
nullptr)
const;
1065 bool keepdims)
const;
1080 sort(int64_t axis,
bool ascending,
bool stable)
const;
1096 argsort(int64_t axis,
bool ascending,
bool stable)
const;
1247 const Index64& advanced)
const = 0;
1256 const Index64& advanced)
const = 0;
1265 const Index64& advanced)
const;
1274 const Index64& advanced)
const;
1283 const Index64& advanced)
const = 0;
1292 const Index64& advanced)
const;
1301 const Index64& advanced)
const;
1310 const Index64& advanced)
const;
1319 const Index64& advanced)
const = 0;
1329 const Slice& tail)
const = 0;
1339 const Slice& tail)
const = 0;
1349 const Slice& tail)
const = 0;
1404 const std::vector<int64_t>& shape)
const;
1415 const std::string& pre,
1416 const std::string& post)
const;
Abstract superclass of cache for VirtualArray, defining the interface.
Definition: ArrayCache.h:17
Abstract superclass of all array node types (flat hierarchy). Any Content can be nested within any ot...
Definition: Content.h:276
Content(const IdentitiesPtr &identities, const util::Parameters ¶meters)
Called by all subclass constructors; assigns identities and parameters upon construction.
const ContentPtr rpad_axis0(int64_t target, bool clip) const
Internal function to handle the axis = 0 case of rpad and rpad_and_clip.
bool parameter_isstring(const std::string &key) const
Returns true if the parameter associated with key is a string; false otherwise.
virtual bool dimension_optiontype() const
Returns true if this dimension has option-type; false otherwise.
util::Parameters parameters_
See parameters.
Definition: Content.h:1426
bool parameter_equals(const std::string &key, const std::string &value) const
Returns true if the parameter associated with key exists and is equal to value; false otherwise.
virtual bool istuple() const =0
Returns true if the outermost RecordArray is a tuple.
virtual ~Content()
Empty destructor; required for some C++ reason.
Definition: Content.h:284
virtual const ContentPtr carry(const Index64 &carry, bool allow_lazy) const =0
Returns an array of the same type with elements filtered, rearranged, and possibly duplicated by the ...
virtual const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceArray64 &slicecontent, const Slice &tail) const =0
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
kernel::lib kernels_compare(kernel::lib from_index, const ContentPtr &content) const
Internal function to support most of the logic in kernels.
virtual const ContentPtr combinations(int64_t n, bool replacement, const util::RecordLookupPtr &recordlookup, const util::Parameters ¶meters, int64_t axis, int64_t depth) const =0
Tuples or records of all n-tuple combinations of list items at some axis depth.
const std::string parameter(const std::string &key) const
Get one parameter from this array node.
virtual void setidentities()=0
Assign a surrogate index of Identities to this array (in-place).
virtual const ContentPtr sort_next(int64_t negaxis, const Index64 &starts, const Index64 &parents, int64_t outlength, bool ascending, bool stable) const =0
This array sorted.
const std::string tostring() const
Returns a string representation of this array (multi-line XML).
virtual const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceJagged64 &slicecontent, const Slice &tail) const =0
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
const std::string tojson(bool pretty, int64_t maxdecimals, const char *nan_string=nullptr, const char *infinity_string=nullptr, const char *minus_infinity_string=nullptr, const char *complex_real_string=nullptr, const char *complex_imag_string=nullptr) const
Returns a JSON representation of this array.
virtual const ContentPtr deep_copy(bool copyarrays, bool copyindexes, bool copyidentities) const =0
Copies this node and all nodes hierarchically nested within it, optionally copying the associated arr...
virtual const ContentPtr getitem_fields(const std::vector< std::string > &keys, const Slice &only_fields) const =0
virtual const std::pair< int64_t, int64_t > minmax_depth() const =0
Returns (a) the minimum list-depth and (b) the maximum list-depth of the array, which can differ if t...
virtual const std::string key(int64_t fieldindex) const =0
The record name associated with a given field index or the tuple index as a string (e....
int64_t nbytes() const
The number of bytes contained in all array buffers, Index buffers, and Identities buffers,...
virtual const ContentPtr getitem_next(const SliceItemPtr &head, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const ContentPtr getitem_next(const SliceField &field, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
const ContentPtr combinations_axis0(int64_t n, bool replacement, const util::RecordLookupPtr &recordlookup, const util::Parameters ¶meters) const
Internal function to handle the axis = 0 case of combinations.
virtual const ContentPtr getitem_nothing() const =0
Internal function to get an empty slice (with the correct type).
virtual const ContentPtr numbers_to_type(const std::string &name) const =0
Change the leaf types to 'totype'.
const int64_t axis_wrap_if_negative(int64_t axis) const
Internal function defining the negative axis handling for many operations.
virtual const ContentPtr rpad(int64_t target, int64_t axis, int64_t depth) const =0
If axis = 0, returns a view of this array padded on the right with None values to have a minimum leng...
bool purelist_isregular() const
Returns true if all nested lists down to the first RecordArray are RegularArray nodes; false otherwis...
virtual const ContentPtr getitem_range(int64_t start, int64_t stop) const =0
Subinterval of this array, handling negative indexing and bounds-checking like Python.
virtual bool mergeable(const ContentPtr &other, bool mergebool) const =0
Returns true if this array can be merged with the other; false otherwise.
virtual void tojson_part(ToJson &builder, bool include_beginendlist) const =0
Internal function to produce a JSON representation one node at a time.
virtual const ContentPtr copy_to(kernel::lib ptr_lib) const =0
Recursively copies components of the array from main memory to a GPU (if ptr_lib == kernel::lib::cuda...
virtual const ContentPtr num(int64_t axis, int64_t depth) const =0
The length of this array (as a NumpyArray scalar) if axis = 0 or the lengths of subarrays (as an arra...
virtual const ContentPtr getitem_fields(const std::vector< std::string > &keys) const =0
This array with the first nested RecordArray replaced by a RecordArray of a given subset of keys.
virtual const std::pair< ContentPtrVec, ContentPtrVec > merging_strategy(const ContentPtrVec &others) const
Partitions this array plus a list of others into a head sequence and a tail sequence:
virtual void check_for_iteration() const =0
Performs up-front validity checks on an array so that they don't have to be checked in getitem_at_now...
virtual const ContentPtr localindex(int64_t axis, int64_t depth) const =0
A (possibly nested) array of integers indicating the positions of elements within each nested list.
virtual bool is_unique() const =0
Returns 'true' if all components of the array are unique.
virtual const ContentPtr getitem_at_nowrap(int64_t at) const =0
Returns the element at a given position in the array, without handling negative indexing or bounds-ch...
virtual const ContentPtr shallow_copy() const =0
Copies this node without copying any nodes hierarchically nested within it or any array/index/identit...
IdentitiesPtr identities_
See identities.
Definition: Content.h:1424
virtual void caches(std::vector< ArrayCachePtr > &out) const =0
Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determ...
virtual const ContentPtr getitem_at(int64_t at) const =0
Returns the element at a given position in the array, handling negative indexing and bounds-checking ...
virtual kernel::lib kernels() const =0
Returns the kernel library enum for all nested ptr_lib within the array's tree structure....
virtual int64_t purelist_depth() const =0
The list-depth of this array, not counting any contained within a RecordArray.
virtual const ContentPtr mergemany(const ContentPtrVec &others) const =0
Returns an array with this and the others concatenated (in order, this first, others last).
virtual const std::string purelist_parameter(const std::string &key) const
The parameter associated with key at the first level that has a non-null value, descending only as de...
virtual const ContentPtr getitem_field(const std::string &key) const =0
This array with the first nested RecordArray replaced by the field at key.
const ContentPtr merge_as_union(const ContentPtr &other) const
Concatenates this array with other by creating a UnionArray instead of actually merging the data....
virtual bool referentially_equal(const ContentPtr &other) const =0
Returns true if this array has all the same buffers and parameters as other; false otherwise.
const ContentPtr reduce(const Reducer &reducer, int64_t axis, bool mask, bool keepdims) const
This array with one axis removed by applying a Reducer (e.g. "sum", "max", "any", "all).
virtual const std::string tostring_part(const std::string &indent, const std::string &pre, const std::string &post) const =0
Internal function to build an output string for tostring.
virtual const ContentPtr getitem_next(const SliceArray64 &array, const Slice &tail, const Index64 &advanced) const =0
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const ContentPtr unique() const =0
Returns sorted unique values.
virtual const ContentPtr getitem_next(const SliceRange &range, const Slice &tail, const Index64 &advanced) const =0
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual int64_t numfields() const =0
The number of fields in the first nested tuple or records or -1 if this array does not contain a Reco...
virtual const ContentPtr getitem_next(const SliceJagged64 &jagged, const Slice &tail, const Index64 &advanced) const =0
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const ContentPtr getitem_range_nowrap(int64_t start, int64_t stop) const =0
Subinterval of this array, without handling negative indexing or bounds-checking.
virtual bool isscalar() const
Returns true if the data represented by this node is scalar, not a true array.
virtual const IdentitiesPtr identities() const
Optional Identities for each element of the array (may be nullptr).
bool parameters_equal(const util::Parameters &other, bool check_all) const
Returns true if all parameters of this array node are equal to the other parameters.
virtual const ContentPtr getitem_field(const std::string &key, const Slice &only_fields) const =0
virtual const ContentPtr getitem_next(const SliceMissing64 &missing, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const TypePtr type(const util::TypeStrs &typestrs) const =0
High-level Type describing this array.
virtual const ContentPtr reduce_next(const Reducer &reducer, int64_t negaxis, const Index64 &starts, const Index64 &shifts, const Index64 &parents, int64_t outlength, bool mask, bool keepdims) const =0
This array with one axis removed by applying a Reducer (e.g. "sum", "max", "any", "all).
const std::string validityerror_parameters(const std::string &path) const
Internal function to determine if a particular set of parameters are allowed on a particular node (ce...
virtual int64_t fieldindex(const std::string &key) const =0
The position of a tuple or record key name if this array contains a RecordArray.
const std::string parameter_asstring(const std::string &key) const
Returns the parameter associated with key as a string if parameter_isstring; raises an error otherwis...
const ContentPtr localindex_axis0() const
Internal function to handle the axis = 0 case of localindex.
virtual const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceMissing64 &slicecontent, const Slice &tail) const =0
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
virtual const ContentPtr shallow_simplify() const =0
Returns an equivalent array simplified at one level only using simplify_optiontype if an option-type ...
void setparameter(const std::string &key, const std::string &value)
Assign one parameter for this array node (in-place).
virtual const std::string classname() const =0
User-friendly name of this class, including integer-type specialization.
void setparameters(const util::Parameters ¶meters)
Assign all the parameters for this array node (in-place).
bool parameter_isname(const std::string &key) const
Returns true if the parameter associated with key is a string that matches [A-Za-z_][A-Za-z_0-9]*; fa...
const ContentPtr getitem_next_array_wrap(const ContentPtr &outcontent, const std::vector< int64_t > &shape) const
Internal function to wrap putative getitem output with enough RegularArray nodes to satisfy a given s...
virtual void setidentities(const IdentitiesPtr &identities)=0
Assign a specified set of Identities to this array (in-place).
virtual const ContentPtr getitem_next(const SliceFields &fields, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const ContentPtr argsort_next(int64_t negaxis, const Index64 &starts, const Index64 &shifts, const Index64 &parents, int64_t outlength, bool ascending, bool stable) const =0
This array sorted indices.
void tojson(FILE *destination, bool pretty, int64_t maxdecimals, int64_t buffersize, const char *nan_string=nullptr, const char *infinity_string=nullptr, const char *minus_infinity_string=nullptr, const char *complex_real_string=nullptr, const char *complex_imag_string=nullptr) const
Writes a JSON representation of this array to a destination file.
virtual const std::vector< std::string > keys() const =0
A list of RecordArray keys or an empty list if this array does not contain a RecordArray.
const ContentPtr argsort(int64_t axis, bool ascending, bool stable) const
This array indices with one axis sorted by applying a sorting algorithm.
virtual void nbytes_part(std::map< size_t, int64_t > &largest) const =0
Internal function used to calculate nbytes.
virtual const ContentPtr rpad_and_clip(int64_t target, int64_t axis, int64_t depth) const =0
If axis = 0, returns a view of this array padded on the right.
virtual const ContentPtr fillna(const ContentPtr &value) const =0
Returns this array with None values replaced by a given value.
virtual const ContentPtr getitem_next(const SliceEllipsis &ellipsis, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const std::string validityerror(const std::string &path) const =0
Returns an error message if this array is invalid; otherwise, returns an empty string.
virtual const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceItemPtr &slicecontent, const Slice &tail) const
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
virtual bool is_subrange_equal(const Index64 &start, const Index64 &stop) const =0
Returns 'true' if subranges are equal.
virtual const std::pair< bool, int64_t > branch_depth() const =0
Returns (a) whether the list-depth of this array "branches," or differs when followed through differe...
const ContentPtr merge(const ContentPtr &other) const
An array with this and the other concatenated (this first, other last).
const ContentPtr sort(int64_t axis, bool ascending, bool stable) const
This array with one axis sorted by applying a sorting algorithm.
const std::string parameters_tostring(const std::string &indent, const std::string &pre, const std::string &post) const
Internal function to convert parameters into a string fragment for tostring.
virtual const FormPtr form(bool materialize) const =0
Low-level Form describing all the features of this array except the actual data buffers (Index,...
virtual const std::pair< Index64, ContentPtr > offsets_and_flattened(int64_t axis, int64_t depth) const =0
Returns (a) an offsets Index and (b) a flattened version of the array at some axis depth.
virtual const SliceItemPtr asslice() const =0
Converts this array into a SliceItem that can be used in getitem.
virtual const ContentPtr getitem_next(const SliceNewAxis &newaxis, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
const util::Parameters parameters() const
String-to-JSON map that augments the meaning of this array.
virtual int64_t length() const =0
The number of elements in the array.
virtual const ContentPtr getitem_next(const SliceAt &at, const Slice &tail, const Index64 &advanced) const =0
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual bool haskey(const std::string &key) const =0
Returns true if the array contains a RecordArray with the specified key; false otherwise.
virtual const ContentPtr reverse_merge(const ContentPtr &other) const
Merges a single other with this array in reverse order: other first, this last.
virtual const ContentPtr getitem(const Slice &where) const
Entry point for general slicing: Slice represents a tuple of SliceItem nodes applying to each level o...
A contiguous, one-dimensional array of integers used to represent data structures,...
Definition: Index.h:82
Abstract class for all reducer algorithms.
Definition: Reducer.h:20
Represents an array of integers in a slice (possibly converted from an array of booleans).
Definition: Slice.h:229
Represents an integer in a tuple of slices passed to __getitem__ in Python.
Definition: Slice.h:58
Represents a Python Ellipsis object (usual syntax: array[...]).
Definition: Slice.h:169
Represents a single string in a slice tuple, indicating that a RecordArray should be replaced by one ...
Definition: Slice.h:340
Represents an array of nested lists, where the content may be SliceArrayOf, SliceMissingOf,...
Definition: Slice.h:515
Represents a SliceArrayOf, SliceMissingOf, or SliceJaggedOf with missing values: None (no equivalent ...
Definition: Slice.h:435
Represents NumPy's newaxis marker (a.k.a. None), which prompts __getitem__ to insert a length-1 regul...
Definition: Slice.h:197
Represents a Python slice object (usual syntax: array[start:stop:step]).
Definition: Slice.h:93
A sequence of SliceItem objects representing a tuple passed to Python's __getitem__.
Definition: Slice.h:585
Produces a JSON-formatted file.
Definition: json.h:203
Produces a pretty JSON-formatted file.
Definition: json.h:268
Produces a pretty JSON-formatted string.
Definition: json.h:139
Produces a JSON-formatted string.
Definition: json.h:75
Abstract superclass of all high level types (flat hierarchy).
Definition: Type.h:23
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
lib
Definition: kernel-dispatch.h:20
std::map< std::string, std::string > Parameters
Definition: util.h:165
std::shared_ptr< RecordLookup > RecordLookupPtr
Definition: util.h:130
std::map< std::string, std::string > TypeStrs
Definition: util.h:215
Definition: BitMaskedArray.h:15
std::shared_ptr< std::string > FormKey
Definition: Content.h:19
std::vector< std::shared_ptr< Content > > ContentPtrVec
Definition: Content.h:16
std::shared_ptr< SliceItem > SliceItemPtr
Definition: Slice.h:15
std::shared_ptr< Content > ContentPtr
Definition: Content.h:15
std::shared_ptr< Form > FormPtr
Definition: Content.h:18
std::shared_ptr< Type > TypePtr
Definition: Content.h:23
std::shared_ptr< ArrayCache > ArrayCachePtr
Definition: Content.h:21
std::shared_ptr< Identities > IdentitiesPtr
Definition: Identities.h:16