Awkward Array: GrowableBuffer< PRIMITIVE > Class Template Reference

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
GrowableBuffer< PRIMITIVE > Class Template Reference

Discontiguous, one-dimensional buffer (which consists of multiple contiguous, one-dimensional panels) that can grow indefinitely by calling append. More...

`#include <GrowableBuffer.h>`

## Public Member Functions
| GrowableBuffer (const BuilderOptions &options, std::unique_ptr< PRIMITIVE[]> ptr, int64_t length, int64_t reserved)
| Creates a GrowableBuffer from a full set of parameters. More...
| GrowableBuffer (const BuilderOptions &options)
| Creates a GrowableBuffer by allocating a new buffer, taking an options #reserved from options. More...
| GrowableBuffer (GrowableBuffer &&other) noexcept
| Move constructor. More...
size_t | length () const
| Currently used number of elements. More...
const BuilderOptions & | options () const
| Return options of this GrowableBuffer. More...
void | clear ()
| Discards accumulated data, the #reserved returns to options.initial(), and a new #ptr is allocated. More...
PRIMITIVE | last () const
| Last element in last panel. More...
size_t | nbytes () const
| Currently used number of bytes. More...
void | append (PRIMITIVE datum)
| Inserts one `datum` into the panel, possibly triggering allocation of a new panel. More...
void | extend (const PRIMITIVE *ptr, size_t size)
| Inserts an entire array into the panel(s), possibly triggering allocation of a new panel. More...
PRIMITIVE & | append_and_get_ref (PRIMITIVE datum)
| Like append, but the type signature returns the reference to `PRIMITIVE`. More...
void | concatenate (PRIMITIVE *external_pointer) const noexcept
| Copies and concatenates all accumulated data from multiple panels to one contiguously allocated `external_pointer`. More...
void | concatenate_from (PRIMITIVE *external_pointer, size_t to, size_t from) const noexcept
| Copies and concatenates all accumulated data from multiple panels to one contiguously allocated `external_pointer`. More...
void | append (PRIMITIVE *external_pointer, size_t offset, size_t from, int64_t length) const noexcept
| Copies data from a panel to one contiguously allocated `external_pointer`. More...

## Static Public Member Functions
static GrowableBuffer< PRIMITIVE > | empty (const BuilderOptions &options)
| Creates an empty GrowableBuffer. More...
static GrowableBuffer< PRIMITIVE > | empty (const BuilderOptions &options, int64_t minreserve)
| Creates an empty GrowableBuffer with a minimum reservation. More...
static GrowableBuffer< PRIMITIVE > | zeros (const BuilderOptions &options, int64_t length)
| Creates a GrowableBuffer in which all elements are initialized to `0`. More...
static GrowableBuffer< PRIMITIVE > | full (const BuilderOptions &options, PRIMITIVE value, int64_t length)
| Creates a GrowableBuffer in which all elements are initialized to a given value. More...
static GrowableBuffer< PRIMITIVE > | arange (const BuilderOptions &options, int64_t length)
| Creates a GrowableBuffer in which the elements are initialized to numbers counting from `0` to `length`. More...
template<typename TO_PRIMITIVE >
static GrowableBuffer< TO_PRIMITIVE > | copy_as (const GrowableBuffer< PRIMITIVE > &other)
| Takes a (possibly multi-panels) GrowableBuffer<PRIMITIVE> and makes another (one panel) GrowableBuffer<TO_PRIMITIVE>. More...

## Detailed Description

template<typename PRIMITIVE>
class awkward::GrowableBuffer< PRIMITIVE >

Discontiguous, one-dimensional buffer (which consists of multiple contiguous, one-dimensional panels) that can grow indefinitely by calling append.

Configured by BuilderOptions, the buffer starts by reserving `initial` slots. When the number of slots used reaches the number reserved, a new panel is allocated that is `resize` times larger.

When `ArrayBuilder::to_buffers` is called, these buffers are copied to the new Content array.

## Constructor & Destructor Documentation

## ◆ GrowableBuffer() [1/3]

GrowableBuffer | ( | const BuilderOptions & | options,
|  | std::unique_ptr< PRIMITIVE[]> | ptr,
|  | int64_t | length,
|  | int64_t | reserved
| ) |  |
| inline

Creates a GrowableBuffer from a full set of parameters.

Parameters

  options | Initial size configuration for building a panel.
  ptr | Reference-counted pointer to the array buffer.
  length | Currently used number of elements.
  reserved | Currently allocated number of elements.

Although the length increments every time append is called, it is always less than or equal to #reserved because of allocations of new panels.

## ◆ GrowableBuffer() [2/3]

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

Creates a GrowableBuffer by allocating a new buffer, taking an options #reserved from options.

Parameters

  options | Initial size configuration for building a panel.

## ◆ GrowableBuffer() [3/3]

GrowableBuffer | ( | GrowableBuffer< PRIMITIVE > && | other | ) |
| inlinenoexcept

Move constructor.

panel_ is move-only.

## Member Function Documentation

## ◆ append() [1/2]

void append | ( | PRIMITIVE * | external_pointer,
|  | size_t | offset,
|  | size_t | from,
|  | int64_t | length
| ) |  | const
| inlinenoexcept

Copies data from a panel to one contiguously allocated `external_pointer`.

## ◆ append() [2/2]

void append | ( | PRIMITIVE | datum | ) |
| inline

Inserts one `datum` into the panel, possibly triggering allocation of a new panel.

This increases the length by 1; if the new length is larger than #reserved, a new panel will be allocated.

## ◆ append_and_get_ref()

PRIMITIVE & append_and_get_ref | ( | PRIMITIVE | datum | ) |
| inline

Like append, but the type signature returns the reference to `PRIMITIVE`.

## ◆ arange()

static GrowableBuffer< PRIMITIVE > arange | ( | const BuilderOptions & | options,
|  | int64_t | length
| ) |  |
| inlinestatic

Creates a GrowableBuffer in which the elements are initialized to numbers counting from `0` to `length`.

Parameters

  options | Initial size configuration for building a panel.
  length | The number of elements to initialize (and the GrowableBuffer's initial length).

This is similar to NumPy's arange.

## ◆ clear()

void clear | ( |  | ) |
| inline

Discards accumulated data, the #reserved returns to options.initial(), and a new #ptr is allocated.

## ◆ concatenate()

void concatenate | ( | PRIMITIVE * | external_pointer | ) | const
| inlinenoexcept

Copies and concatenates all accumulated data from multiple panels to one contiguously allocated `external_pointer`.

## ◆ concatenate_from()

void concatenate_from | ( | PRIMITIVE * | external_pointer,
|  | size_t | to,
|  | size_t | from
| ) |  | const
| inlinenoexcept

Copies and concatenates all accumulated data from multiple panels to one contiguously allocated `external_pointer`.

## ◆ copy_as()

static GrowableBuffer< TO_PRIMITIVE > copy_as | ( | const GrowableBuffer< PRIMITIVE > & | other | ) |
| inlinestatic

Takes a (possibly multi-panels) GrowableBuffer<PRIMITIVE> and makes another (one panel) GrowableBuffer<TO_PRIMITIVE>.

Used to change the data type of buffer content from `PRIMITIVE` to `TO_PRIMITIVE` for building arrays.

## ◆ empty() [1/2]

static GrowableBuffer< PRIMITIVE > empty | ( | const BuilderOptions & | options | ) |
| inlinestatic

Creates an empty GrowableBuffer.

Parameters

  options | Initial size configuration for building a panel.

## ◆ empty() [2/2]

static GrowableBuffer< PRIMITIVE > empty | ( | const BuilderOptions & | options,
|  | int64_t | minreserve
| ) |  |
| inlinestatic

Creates an empty GrowableBuffer with a minimum reservation.

Parameters

  options | Initial size configuration for building a panel.
  minreserve | The initial reservation will be the maximum of `minreserve` and `initial`.

## ◆ extend()

void extend | ( | const PRIMITIVE * | ptr,
|  | size_t | size
| ) |  |
| inline

Inserts an entire array into the panel(s), possibly triggering allocation of a new panel.

If the size is larger than the empty slots in the current panel, then, first, the empty slots are filled and then a new panel will be allocated for the rest of the array elements.

## ◆ full()

static GrowableBuffer< PRIMITIVE > full | ( | const BuilderOptions & | options,
|  | PRIMITIVE | value,
|  | int64_t | length
| ) |  |
| inlinestatic

Creates a GrowableBuffer in which all elements are initialized to a given value.

Parameters

  options | Initial size configuration for building a panel.
  value | The initialization value.
  length | The number of elements to initialize (and the GrowableBuffer's initial length).

This is similar to NumPy's full.

## ◆ last()

PRIMITIVE last | ( |  | ) | const
| inline

Last element in last panel.

## ◆ length()

size_t length | ( |  | ) | const
| inline

Currently used number of elements.

Although the length increments every time append is called, it is always less than or equal to #reserved because of allocations of new panels.

## ◆ nbytes()

size_t nbytes | ( |  | ) | const
| inline

Currently used number of bytes.

## ◆ options()

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

Return options of this GrowableBuffer.

## ◆ zeros()

static GrowableBuffer< PRIMITIVE > zeros | ( | const BuilderOptions & | options,
|  | int64_t | length
| ) |  |
| inlinestatic

Creates a GrowableBuffer in which all elements are initialized to `0`.

Parameters

  options | Initial size configuration for building a panel.
  length | The number of elements to initialize (and the GrowableBuffer's initial length).

This is similar to NumPy's zeros.

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

- src/awkward/_v2/cpp-headers/awkward/GrowableBuffer.h