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