Awkward Array: UnionBuilder Class Reference

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
UnionBuilder Class Reference

Builder node for accumulated heterogeneous data. More...

`#include <UnionBuilder.h>`

Inheritance diagram for UnionBuilder:

## Public Member Functions
| UnionBuilder (const BuilderOptions &options, GrowableBuffer< int8_t > tags, GrowableBuffer< int64_t > index, std::vector< BuilderPtr > &contents)
| Create a UnionBuilder from a full set of parameters. More...
const std::string | classname () const override
| User-friendly name of this class: `"UnionBuilder"`. More...
const std::string | to_buffers (BuffersContainer &container, int64_t &form_key_id) const override
| Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON). More...
int64_t | length () const override
| Current length of the accumulated array. More...
void | clear () override
| Removes all accumulated data without resetting the type knowledge. More...
bool | active () const override
| If `true`, this node has started but has not finished a multi-step command (e.g. `beginX ... endX`). More...
const BuilderPtr | null () override
| Adds a `null` value to the accumulated data. More...
const BuilderPtr | boolean (bool x) override
| Adds a boolean value `x` to the accumulated data. More...
const BuilderPtr | integer (int64_t x) override
| Adds an integer value `x` to the accumulated data. More...
const BuilderPtr | real (double x) override
| Adds a real value `x` to the accumulated data. More...
const BuilderPtr | complex (std::complex< double > x) override
| Adds a complex value `x` to the accumulated data. More...
const BuilderPtr | datetime (int64_t x, const std::string &unit) override
| Adds a datetime value `x` to the accumulated data. More...
const BuilderPtr | timedelta (int64_t x, const std::string &unit) override
| Adds a timedelta value `x` to the accumulated data. More...
const BuilderPtr | string (const char *x, int64_t length, const char *encoding) override
| Adds a string value `x` with a given `length` and `encoding` to the accumulated data. More...
const BuilderPtr | beginlist () override
| Begins building a nested list. More...
const BuilderPtr | endlist () override
| Ends a nested list. More...
const BuilderPtr | begintuple (int64_t numfields) override
| Begins building a tuple with a fixed number of fields. More...
const BuilderPtr | index (int64_t index) override
| Sets the pointer to a given tuple field index; the next command will fill that slot. More...
const BuilderPtr | endtuple () override
| Ends a tuple. More...
const BuilderPtr | beginrecord (const char *name, bool check) override
| Begins building a record with an optional name. More...
void | field (const char *key, bool check) override
| Sets the pointer to a given record field `key`; the next command will fill that slot. More...
const BuilderPtr | endrecord () override
| Ends a record. More...
const BuilderOptions & | options () const
const GrowableBuffer< int8_t > & | tags () const
GrowableBuffer< int8_t > & | tags_buffer ()
const GrowableBuffer< int64_t > & | index () const
GrowableBuffer< int64_t > & | index_buffer ()
const std::vector< BuilderPtr > & | contents () const
std::vector< BuilderPtr > & | builders ()
int8_t | current ()
Public Member Functions inherited from Builder
virtual | ~Builder ()
| Virtual destructor acts as a first non-inline virtual function that determines a specific translation unit in which vtable shall be emitted. More...
virtual const std::string | classname () const =0
| User-friendly name of this class. More...
virtual const std::string | to_buffers (BuffersContainer &container, int64_t &form_key_id) const =0
| Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON). More...
virtual int64_t | length () const =0
| Current length of the accumulated array. More...
virtual void | clear ()=0
| Removes all accumulated data without resetting the type knowledge. More...
virtual bool | active () const =0
| If `true`, this node has started but has not finished a multi-step command (e.g. `beginX ... endX`). More...
virtual const BuilderPtr | null ()=0
| Adds a `null` value to the accumulated data. More...
virtual const BuilderPtr | boolean (bool x)=0
| Adds a boolean value `x` to the accumulated data. More...
virtual const BuilderPtr | integer (int64_t x)=0
| Adds an integer value `x` to the accumulated data. More...
virtual const BuilderPtr | real (double x)=0
| Adds a real value `x` to the accumulated data. More...
virtual const BuilderPtr | complex (std::complex< double > x)=0
| Adds a complex value `x` to the accumulated data. More...
virtual const BuilderPtr | datetime (int64_t x, const std::string &unit)=0
| Adds a datetime value `x` to the accumulated data. More...
virtual const BuilderPtr | timedelta (int64_t x, const std::string &unit)=0
| Adds a timedelta value `x` to the accumulated data. More...
virtual const BuilderPtr | string (const char *x, int64_t length, const char *encoding)=0
| Adds a string value `x` with a given `length` and `encoding` to the accumulated data. More...
virtual const BuilderPtr | beginlist ()=0
| Begins building a nested list. More...
virtual const BuilderPtr | endlist ()=0
| Ends a nested list. More...
virtual const BuilderPtr | begintuple (int64_t numfields)=0
| Begins building a tuple with a fixed number of fields. More...
virtual const BuilderPtr | index (int64_t index)=0
| Sets the pointer to a given tuple field index; the next command will fill that slot. More...
virtual const BuilderPtr | endtuple ()=0
| Ends a tuple. More...
virtual const BuilderPtr | beginrecord (const char *name, bool check)=0
| Begins building a record with an optional name. More...
virtual void | field (const char *key, bool check)=0
| Sets the pointer to a given record field `key`; the next command will fill that slot. More...
virtual const BuilderPtr | endrecord ()=0
| Ends a record. More...

## Static Public Member Functions
static const BuilderPtr | fromsingle (const BuilderOptions &options, const BuilderPtr &firstcontent)

## Detailed Description

Builder node for accumulated heterogeneous data.

## Constructor & Destructor Documentation

## ◆ UnionBuilder()

UnionBuilder | ( | const BuilderOptions & | options,
|  | GrowableBuffer< int8_t > | tags,
|  | GrowableBuffer< int64_t > | index,
|  | std::vector< BuilderPtr > & | contents
| ) |  |

Create a UnionBuilder from a full set of parameters.

Parameters

  options | Configuration options for building an array; these are passed to every Builder's constructor.
  tags | Contains the accumulated tags (like `UnionArray::tags`).
  index | Contains the accumulated index (like `UnionArray::index`).
  contents | A Builder for each of the union's possibilities.

## Member Function Documentation

## ◆ active()

bool active | ( |  | ) | const
| overridevirtual

If `true`, this node has started but has not finished a multi-step command (e.g. `beginX ... endX`).

A UnionBuilder is active if and only if one of its `contents` is active.

Implements Builder.

## ◆ beginlist()

const BuilderPtr beginlist | ( |  | ) |
| overridevirtual

Begins building a nested list.

Implements Builder.

## ◆ beginrecord()

const BuilderPtr beginrecord | ( | const char * | name,
|  | bool | check
| ) |  |
| overridevirtual

Begins building a record with an optional name.

Parameters

  name | If specified, this name is used to distinguish records of different types in heterogeneous data (to build a union of record arrays, rather than a record array with union fields and optional values) and it also sets the `"__record__"` parameter to later add custom behaviors in Python.
  check | If `true`, actually do a string comparison to see if the provided `name` matches the previous `name`; if `false`, assume that the same pointer means the same string (safe for string literals).

Implements Builder.

## ◆ begintuple()

const BuilderPtr begintuple | ( | int64_t | numfields | ) |
| overridevirtual

Begins building a tuple with a fixed number of fields.

Implements Builder.

## ◆ boolean()

const BuilderPtr boolean | ( | bool | x | ) |
| overridevirtual

Adds a boolean value `x` to the accumulated data.

Implements Builder.

## ◆ builders()

std::vector< BuilderPtr > & builders | ( |  | ) |
| inline

## ◆ classname()

const std::string classname | ( |  | ) | const
| overridevirtual

User-friendly name of this class: `"UnionBuilder"`.

Implements Builder.

## ◆ clear()

void clear | ( |  | ) |
| overridevirtual

Removes all accumulated data without resetting the type knowledge.

Implements Builder.

## ◆ complex()

const BuilderPtr complex | ( | std::complex< double > | x | ) |
| overridevirtual

Adds a complex value `x` to the accumulated data.

Implements Builder.

## ◆ contents()

const std::vector< BuilderPtr > & contents | ( |  | ) | const
| inline

## ◆ current()

int8_t current | ( |  | ) |
| inline

## ◆ datetime()

const BuilderPtr datetime | ( | int64_t | x,
|  | const std::string & | unit
| ) |  |
| overridevirtual

Adds a datetime value `x` to the accumulated data.

Implements Builder.

## ◆ endlist()

const BuilderPtr endlist | ( |  | ) |
| overridevirtual

Ends a nested list.

Implements Builder.

## ◆ endrecord()

const BuilderPtr endrecord | ( |  | ) |
| overridevirtual

Ends a record.

Implements Builder.

## ◆ endtuple()

const BuilderPtr endtuple | ( |  | ) |
| overridevirtual

Ends a tuple.

Implements Builder.

## ◆ field()

void field | ( | const char * | key,
|  | bool | check
| ) |  |
| overridevirtual

Sets the pointer to a given record field `key`; the next command will fill that slot.

Parameters

  key | Indicates the field to fill.
  check | If `true`, actually do a string comparison to see if `key` matches the previous `key`; if `false`, assume that the same pointer means the same string (safe for string literals).

Record keys are checked in round-robin order. The best performance will be achieved by filling them in the same order for each record. Lookup time for random order scales with the number of fields.

Implements Builder.

## ◆ fromsingle()

static const BuilderPtr fromsingle | ( | const BuilderOptions & | options,
|  | const BuilderPtr & | firstcontent
| ) |  |
| static

## ◆ index() [1/2]

const GrowableBuffer< int64_t > & index | ( |  | ) | const
| inline

## ◆ index() [2/2]

const BuilderPtr index | ( | int64_t | index | ) |
| overridevirtual

Sets the pointer to a given tuple field index; the next command will fill that slot.

Implements Builder.

## ◆ index_buffer()

GrowableBuffer< int64_t > & index_buffer | ( |  | ) |
| inline

## ◆ integer()

const BuilderPtr integer | ( | int64_t | x | ) |
| overridevirtual

Adds an integer value `x` to the accumulated data.

Implements Builder.

## ◆ length()

int64_t length | ( |  | ) | const
| overridevirtual

Current length of the accumulated array.

Implements Builder.

## ◆ null()

const BuilderPtr null | ( |  | ) |
| overridevirtual

Adds a `null` value to the accumulated data.

Implements Builder.

## ◆ options()

const BuilderOptions & options | ( |  | ) | const
| inline

## ◆ real()

const BuilderPtr real | ( | double | x | ) |
| overridevirtual

Adds a real value `x` to the accumulated data.

Implements Builder.

## ◆ string()

const BuilderPtr string | ( | const char * | x,
|  | int64_t | length,
|  | const char * | encoding
| ) |  |
| overridevirtual

Adds a string value `x` with a given `length` and `encoding` to the accumulated data.

Note
  Currently, only `encoding =`

- `nullptr` (no encoding; a bytestring)
- `"utf-8"` (variable-length Unicode 8-bit encoding)

are supported.

Implements Builder.

## ◆ tags()

const GrowableBuffer< int8_t > & tags | ( |  | ) | const
| inline

## ◆ tags_buffer()

GrowableBuffer< int8_t > & tags_buffer | ( |  | ) |
| inline

## ◆ timedelta()

const BuilderPtr timedelta | ( | int64_t | x,
|  | const std::string & | unit
| ) |  |
| overridevirtual

Adds a timedelta value `x` to the accumulated data.

Implements Builder.

## ◆ to_buffers()

const std::string to_buffers | ( | BuffersContainer & | container,
|  | int64_t & | form_key_id
| ) |  | const
| overridevirtual

Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON).

Implements Builder.

The documentation for this class was generated from the following file:

- include/awkward/builder/UnionBuilder.h