3#ifndef AWKWARD_RECORDARRAY_H_
4#define AWKWARD_RECORDARRAY_H_
8#include <unordered_map>
26 const std::vector<FormPtr>& contents);
31 const std::vector<FormPtr>
43 const std::vector<std::pair<std::string, FormPtr>>
70 const std::pair<int64_t, int64_t>
73 const std::pair<bool, int64_t>
83 key(int64_t fieldindex)
const override;
86 haskey(
const std::string& key)
const override;
88 const std::vector<std::string>
93 bool check_identities,
94 bool check_parameters,
96 bool compatibility_check)
const override;
106 const std::vector<FormPtr> contents_;
124 public std::enable_shared_from_this<RecordArray> {
149 const std::vector<ArrayCachePtr>& caches);
209 form(
bool materialize)
const override;
215 caches(std::vector<ArrayCachePtr>& out)
const override;
219 const std::string& pre,
220 const std::string& post)
const override;
243 bool copyidentities)
const override;
268 const Slice& only_fields)
const override;
275 const Slice& only_fields)
const override;
280 const Index64& advanced)
const override;
288 const std::pair<int64_t, int64_t>
291 const std::pair<bool, int64_t>
301 key(int64_t fieldindex)
const override;
304 haskey(
const std::string& key)
const override;
306 const std::vector<std::string>
320 num(int64_t axis, int64_t depth)
const override;
322 const std::pair<Index64, ContentPtr>
341 rpad(int64_t target, int64_t axis, int64_t depth)
const override;
346 int64_t depth)
const override;
356 bool keepdims)
const override;
364 bool stable)
const override;
373 bool stable)
const override;
384 int64_t depth)
const override;
398 field(
const std::string& key)
const;
409 const std::vector<std::pair<std::string, ContentPtr>>
414 const std::shared_ptr<RecordArray>
420 const Index64& advanced)
const override;
425 const Index64& advanced)
const override;
430 const Index64& advanced)
const override;
435 const Index64& advanced)
const override;
440 const Index64& advanced)
const override;
445 const Index64& advanced)
const override;
451 const Slice& tail)
const override;
457 const Slice& tail)
const override;
463 const Slice& tail)
const override;
484 template <
typename S>
488 const S& slicecontent,
489 const Slice& tail)
const;
499 const std::vector<ArrayCachePtr> caches_;
Abstract superclass of all array node types (flat hierarchy). Any Content can be nested within any ot...
Definition: Content.h:276
A contiguous, one-dimensional array of integers used to represent data structures,...
Definition: Index.h:82
Represents an array of tuples or records, in which a tuple has a fixed number of differently typed fi...
Definition: RecordArray.h:124
int64_t purelist_depth() const override
The list-depth of this array, not counting any contained within a RecordArray.
const ContentPtr argsort_next(int64_t negaxis, const Index64 &starts, const Index64 &shifts, const Index64 &parents, int64_t outlength, bool ascending, bool stable) const override
This array sorted indices.
void caches(std::vector< ArrayCachePtr > &out) const override
Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determ...
const ContentPtr getitem_fields(const std::vector< std::string > &keys) const override
This array with the first nested RecordArray replaced by a RecordArray of a given subset of keys.
const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceArray64 &slicecontent, const Slice &tail) const override
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
const ContentPtr getitem_at(int64_t at) const override
Returns the element at a given position in the array, handling negative indexing and bounds-checking ...
void setidentities() override
Assign a surrogate index of Identities to this array (in-place).
const ContentPtr getitem_field(const std::string &key, const Slice &only_fields) const override
const ContentPtr getitem_next(const SliceArray64 &array, const Slice &tail, const Index64 &advanced) const override
Internal function that propagates a generic getitem request through one axis (including advanced inde...
const ContentPtr unique() const override
Returns an array where all components are unique.
const ContentPtr sort_next(int64_t negaxis, const Index64 &starts, const Index64 &parents, int64_t outlength, bool ascending, bool stable) const override
This array sorted.
void tojson_part(ToJson &builder, bool include_beginendlist) const override
Internal function to produce a JSON representation one node at a time.
const ContentPtr getitem_fields(const std::vector< std::string > &keys, const Slice &only_fields) const override
int64_t length() const override
The number of elements in the array.
const ContentPtr deep_copy(bool copyarrays, bool copyindexes, bool copyidentities) const override
Copies this node and all nodes hierarchically nested within it, optionally copying the associated arr...
const std::string validityerror(const std::string &path) const override
Returns an error message if this array is invalid; otherwise, returns an empty string.
const ContentPtr getitem_next(const SliceAt &at, const Slice &tail, const Index64 &advanced) const override
Internal function that propagates a generic getitem request through one axis (including advanced inde...
bool istuple() const override
Returns true if recordlookup is nullptr; false otherwise.
const ContentPtr getitem_next(const SliceField &field, const Slice &tail, const Index64 &advanced) const override
Internal function that propagates a generic getitem request through one axis (including advanced inde...
const ContentPtr getitem_nothing() const override
Internal function to get an empty slice (with the correct type).
kernel::lib kernels() const override
Returns the kernel library enum for all nested ptr_lib within the array's tree structure....
const ContentPtrVec fields() const
Returns all the fields (without trimming them to have the same length as this RecordArray).
const ContentPtr carry(const Index64 &carry, bool allow_lazy) const override
Returns an array of the same type with elements filtered, rearranged, and possibly duplicated by the ...
const ContentPtr combinations(int64_t n, bool replacement, const util::RecordLookupPtr &recordlookup, const util::Parameters ¶meters, int64_t axis, int64_t depth) const override
Tuples or records of all n-tuple combinations of list items at some axis depth.
void setidentities(const IdentitiesPtr &identities) override
Assign a specified set of Identities to this array (in-place).
const ContentPtr localindex(int64_t axis, int64_t depth) const override
A (possibly nested) array of integers indicating the positions of elements within each nested list.
const ContentPtr getitem_range_nowrap(int64_t start, int64_t stop) const override
Subinterval of this array, without handling negative indexing or bounds-checking.
const util::RecordLookupPtr recordlookup() const
A std::shared_ptr<std::vector<std::string>> optional list of key names. If absent (nullptr),...
const std::pair< Index64, ContentPtr > offsets_and_flattened(int64_t axis, int64_t depth) const override
Returns (a) an offsets Index and (b) a flattened version of the array at some axis depth.
int64_t fieldindex(const std::string &key) const override
The position of a tuple or record key name if this array contains a RecordArray.
void check_for_iteration() const override
Performs up-front validity checks on an array so that they don't have to be checked in getitem_at_now...
const ContentPtr field(int64_t fieldindex) const
Returns the field at a given index (without trimming it to have the same length as this RecordArray).
const std::vector< std::string > keys() const override
A list of RecordArray keys or an empty list if this array does not contain a RecordArray.
const ContentPtr getitem_next_jagged_generic(const Index64 &slicestarts, const Index64 &slicestops, const S &slicecontent, const Slice &tail) const
const ContentPtr getitem_field(const std::string &key) const override
This array with the first nested RecordArray replaced by the field at key.
const std::pair< bool, int64_t > branch_depth() const override
Returns (a) whether the list-depth of this array "branches," or differs when followed through differe...
const ContentPtr rpad(int64_t target, int64_t axis, int64_t depth) const override
If axis = 0, returns a view of this array padded on the right with None values to have a minimum leng...
const ContentPtr getitem_next(const SliceItemPtr &head, const Slice &tail, const Index64 &advanced) const override
Internal function that propagates a generic getitem request through one axis (including advanced inde...
const ContentPtr getitem_at_nowrap(int64_t at) const override
Returns the element at a given position in the array, without handling negative indexing or bounds-ch...
const ContentPtr field(const std::string &key) const
Returns the field with a given key name (without trimming it to have the same length as this RecordAr...
void nbytes_part(std::map< size_t, int64_t > &largest) const override
Internal function used to calculate nbytes.
const ContentPtr mergemany(const ContentPtrVec &others) const override
Returns an array with this and the others concatenated (in order, this first, others last).
const std::string key(int64_t fieldindex) const override
The record name associated with a given field index or the tuple index as a string (e....
const ContentPtr shallow_copy() const override
Copies this node without copying any nodes hierarchically nested within it or any array/index/identit...
const std::pair< int64_t, int64_t > minmax_depth() const override
Returns (a) the minimum list-depth and (b) the maximum list-depth of the array, which can differ if t...
bool is_unique() const override
Returns 'true' if all components of the array are unique.
RecordArray(const IdentitiesPtr &identities, const util::Parameters ¶meters, const ContentPtrVec &contents, const util::RecordLookupPtr &recordlookup, int64_t length)
Creates a RecordArray in which caches is derived from the contents.
const FormPtr form(bool materialize) const override
Low-level Form describing all the features of this array except the actual data buffers (Index,...
const SliceItemPtr asslice() const override
Converts this array into a SliceItem that can be used in getitem.
const std::string tostring_part(const std::string &indent, const std::string &pre, const std::string &post) const override
Internal function to build an output string for tostring.
const ContentPtr rpad_and_clip(int64_t target, int64_t axis, int64_t depth) const override
If axis = 0, returns a view of this array padded on the right.
const ContentPtr getitem_next(const SliceJagged64 &jagged, const Slice &tail, const Index64 &advanced) const override
Internal function that propagates a generic getitem request through one axis (including advanced inde...
const ContentPtr setitem_field(int64_t where, const ContentPtr &what) const
Returns a RecordArray with an additional or a replaced field at index where with value what.
const ContentPtr getitem_range(int64_t start, int64_t stop) const override
Subinterval of this array, handling negative indexing and bounds-checking like Python.
bool is_subrange_equal(const Index64 &start, const Index64 &stop) const override
Returns 'true' if subranges are equal.
const ContentPtr fillna(const ContentPtr &value) const override
Returns this array with None values replaced by a given value.
int64_t numfields() const override
The number of fields in the first nested tuple or records or -1 if this array does not contain a Reco...
bool referentially_equal(const ContentPtr &other) const override
Returns true if this array has all the same buffers and parameters as other; false otherwise.
const TypePtr type(const util::TypeStrs &typestrs) const override
High-level Type describing this array.
const ContentPtr num(int64_t axis, int64_t depth) const override
The length of this array (as a NumpyArray scalar) if axis = 0 or the lengths of subarrays (as an arra...
const ContentPtr getitem_next(const SliceFields &fields, const Slice &tail, const Index64 &advanced) const override
Internal function that propagates a generic getitem request through one axis (including advanced inde...
bool mergeable(const ContentPtr &other, bool mergebool) const override
Returns true if this array can be merged with the other; false otherwise.
bool haskey(const std::string &key) const override
Returns true if the array contains a RecordArray with the specified key; false otherwise.
const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceJagged64 &slicecontent, const Slice &tail) const override
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceMissing64 &slicecontent, const Slice &tail) const override
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
const ContentPtr getitem_next(const SliceRange &range, const Slice &tail, const Index64 &advanced) const override
Internal function that propagates a generic getitem request through one axis (including advanced inde...
const ContentPtr shallow_simplify() const override
Returns an equivalent array simplified at one level only using simplify_optiontype if an option-type ...
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 override
This array with one axis removed by applying a Reducer (e.g. "sum", "max", "any", "all).
RecordArray(const IdentitiesPtr &identities, const util::Parameters ¶meters, const ContentPtrVec &contents, const util::RecordLookupPtr &recordlookup, int64_t length, const std::vector< ArrayCachePtr > &caches)
Creates a RecordArray from a full set of parameters.
const std::shared_ptr< RecordArray > astuple() const
Returns this RecordArray without recordlookup, converting any records into tuples.
const ContentPtrVec contents() const
std::vector of Content instances representing the (ordered) fields.
const ContentPtr numbers_to_type(const std::string &name) const override
Change the leaf types to 'totype'.
RecordArray(const IdentitiesPtr &identities, const util::Parameters ¶meters, const ContentPtrVec &contents, const util::RecordLookupPtr &recordlookup)
Creates a RecordArray in which length is the minimum length of the contents or zero if there are no c...
const std::string classname() const override
User-friendly name of this class: "RecordArray".
const ContentPtr copy_to(kernel::lib ptr_lib) const override
Recursively copies components of the array from main memory to a GPU (if ptr_lib == kernel::lib::cuda...
const ContentPtr setitem_field(const std::string &where, const ContentPtr &what) const
Returns a RecordArray with an additional or a replaced field at key name where with value what.
const std::vector< std::pair< std::string, ContentPtr > > fielditems() const
Returns key, field pairs for all fields (without trimming them to have the same length as this Record...
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 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 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
#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< Identities > IdentitiesPtr
Definition: Identities.h:16