Awkward Array: include/awkward/builder/ListBuilder.h Source File

Loading...
Searching...
No Matches
ListBuilder.h
Go to the documentation of this file.
1// BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
2
3#ifndef AWKWARD_LISTBUILDER_H_
4#define AWKWARD_LISTBUILDER_H_
5
6#include <vector>
7
8#include "awkward/common.h"
9#include "awkward/BuilderOptions.h"
10#include "awkward/GrowableBuffer.h"
11#include "awkward/builder/Builder.h"
12
13namespace awkward {
14
18 class LIBAWKWARD_EXPORT_SYMBOL ListBuilder: public Builder {
19 public:
23 static const BuilderPtr
24 fromempty(const BuilderOptions& options);
25
36 ListBuilder(const BuilderOptions& options,
37 GrowableBuffer<int64_t> offsets,
38 const BuilderPtr& content,
39 bool begun);
40
42 const std::string
43 classname() const override;
44
45 const std::string
46 to_buffers(BuffersContainer& container, int64_t& form_key_id) const override;
47
48 int64_t
49 length() const override;
50
51 void
52 clear() override;
53
58 bool
59 active() const override;
60
61 const BuilderPtr
62 null() override;
63
64 const BuilderPtr
65 boolean(bool x) override;
66
67 const BuilderPtr
68 integer(int64_t x) override;
69
70 const BuilderPtr
71 real(double x) override;
72
73 const BuilderPtr
74 complex(std::complex<double> x) override;
75
76 const BuilderPtr
77 datetime(int64_t x, const std::string& unit) override;
78
79 const BuilderPtr
80 timedelta(int64_t x, const std::string& unit) override;
81
82 const BuilderPtr
83 string(const char* x, int64_t length, const char* encoding) override;
84
85 const BuilderPtr
86 beginlist() override;
87
88 const BuilderPtr
89 endlist() override;
90
91 const BuilderPtr
92 begintuple(int64_t numfields) override;
93
94 const BuilderPtr
95 index(int64_t index) override;
96
97 const BuilderPtr
98 endtuple() override;
99
100 const BuilderPtr
101 beginrecord(const char* name, bool check) override;
102
103 void
104 field(const char* key, bool check) override;
105
106 const BuilderPtr
107 endrecord() override;
108
109 const BuilderOptions&
110 options() const { return options_; }
111
112 const GrowableBuffer<int64_t>& buffer() const { return offsets_; }
113
114 const BuilderPtr builder() const { return content_; }
115
116 bool begun() { return begun_; }
117
118 void
119 maybeupdate(const BuilderPtr builder);
120
121 private:
122 const BuilderOptions options_;
123 GrowableBuffer<int64_t> offsets_;
124 BuilderPtr content_;
125 bool begun_;
126 };
127}
128
129#endif // AWKWARD_LISTBUILDER_H_
BuilderOptions.h
Builder.h
GrowableBuffer.h
awkward::BuffersContainer
Abstract class to represent the output of ak.to_buffers. In Python, this would be a dict of NumPy arr...
Definition: Builder.h:20
awkward::Builder
Abstract base class for nodes within an ArrayBuilder that cumulatively discover an array's type and f...
Definition: Builder.h:41
awkward::GrowableBuffer
Discontiguous, one-dimensional buffer (which consists of multiple contiguous, one-dimensional panels)...
Definition: GrowableBuffer.h:174
awkward::ListBuilder
Builder node that accumulates lists.
Definition: ListBuilder.h:18
awkward::ListBuilder::real
const BuilderPtr real(double x) override
Adds a real value x to the accumulated data.
awkward::ListBuilder::buffer
const GrowableBuffer< int64_t > & buffer() const
Definition: ListBuilder.h:112
awkward::ListBuilder::endlist
const BuilderPtr endlist() override
Ends a nested list.
awkward::ListBuilder::fromempty
static const BuilderPtr fromempty(const BuilderOptions &options)
Create an empty ListBuilder.
awkward::ListBuilder::timedelta
const BuilderPtr timedelta(int64_t x, const std::string &unit) override
Adds a timedelta value x to the accumulated data.
awkward::ListBuilder::field
void field(const char *key, bool check) override
Sets the pointer to a given record field key; the next command will fill that slot.
awkward::ListBuilder::complex
const BuilderPtr complex(std::complex< double > x) override
Adds a complex value x to the accumulated data.
awkward::ListBuilder::index
const BuilderPtr index(int64_t index) override
Sets the pointer to a given tuple field index; the next command will fill that slot.
awkward::ListBuilder::length
int64_t length() const override
Current length of the accumulated array.
awkward::ListBuilder::endrecord
const BuilderPtr endrecord() override
Ends a record.
awkward::ListBuilder::active
bool active() const override
If true, this node has started but has not finished a multi-step command (e.g. beginX ....
awkward::ListBuilder::string
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.
awkward::ListBuilder::options
const BuilderOptions & options() const
Definition: ListBuilder.h:110
awkward::ListBuilder::integer
const BuilderPtr integer(int64_t x) override
Adds an integer value x to the accumulated data.
awkward::ListBuilder::ListBuilder
ListBuilder(const BuilderOptions &options, GrowableBuffer< int64_t > offsets, const BuilderPtr &content, bool begun)
Create a ListBuilder from a full set of parameters.
awkward::ListBuilder::begun
bool begun()
Definition: ListBuilder.h:116
awkward::ListBuilder::datetime
const BuilderPtr datetime(int64_t x, const std::string &unit) override
Adds a datetime value x to the accumulated data.
awkward::ListBuilder::maybeupdate
void maybeupdate(const BuilderPtr builder)
awkward::ListBuilder::beginrecord
const BuilderPtr beginrecord(const char *name, bool check) override
Begins building a record with an optional name.
awkward::ListBuilder::null
const BuilderPtr null() override
Adds a null value to the accumulated data.
awkward::ListBuilder::builder
const BuilderPtr builder() const
Definition: ListBuilder.h:114
awkward::ListBuilder::to_buffers
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).
awkward::ListBuilder::beginlist
const BuilderPtr beginlist() override
Begins building a nested list.
awkward::ListBuilder::boolean
const BuilderPtr boolean(bool x) override
Adds a boolean value x to the accumulated data.
awkward::ListBuilder::begintuple
const BuilderPtr begintuple(int64_t numfields) override
Begins building a tuple with a fixed number of fields.
awkward::ListBuilder::endtuple
const BuilderPtr endtuple() override
Ends a tuple.
awkward::ListBuilder::classname
const std::string classname() const override
User-friendly name of this class: "ListBuilder".
awkward::ListBuilder::clear
void clear() override
Removes all accumulated data without resetting the type knowledge.
common.h
LIBAWKWARD_EXPORT_SYMBOL
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
awkward
Definition: BitMaskedArray.h:15
awkward::BuilderPtr
std::shared_ptr< Builder > BuilderPtr
Definition: ArrayBuilder.h:16
awkward::Options
Container for all configuration options needed by ArrayBuilder, GrowableBuffer, LayoutBuilder and the...
Definition: BuilderOptions.h:20