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

Loading...
Searching...
No Matches
TupleBuilder.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_TUPLEBUILDER_H_
4#define AWKWARD_TUPLEBUILDER_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 TupleBuilder: public Builder {
19 public:
23 static const BuilderPtr
24 fromempty(const BuilderOptions& options);
25
35 TupleBuilder(const BuilderOptions& options,
36 const std::vector<BuilderPtr>& contents,
37 int64_t length,
38 bool begun,
39 size_t nextindex);
40
42 int64_t
43 numfields() const;
44
46 const std::string
47 classname() const override;
48
49 const std::string
50 to_buffers(BuffersContainer& container, int64_t& form_key_id) const override;
51
52 int64_t
53 length() const override;
54
55 void
56 clear() override;
57
62 bool
63 active() const override;
64
65 const BuilderPtr
66 null() override;
67
68 const BuilderPtr
69 boolean(bool x) override;
70
71 const BuilderPtr
72 integer(int64_t x) override;
73
74 const BuilderPtr
75 real(double x) override;
76
77 const BuilderPtr
78 complex(std::complex<double> x) override;
79
80 const BuilderPtr
81 datetime(int64_t x, const std::string& unit) override;
82
83 const BuilderPtr
84 timedelta(int64_t x, const std::string& unit) override;
85
86 const BuilderPtr
87 string(const char* x, int64_t length, const char* encoding) override;
88
89 const BuilderPtr
90 beginlist() override;
91
92 const BuilderPtr
93 endlist() override;
94
95 const BuilderPtr
96 begintuple(int64_t numfields) override;
97
98 const BuilderPtr
99 index(int64_t index) override;
100
101 const BuilderPtr
102 endtuple() override;
103
104 const BuilderPtr
105 beginrecord(const char* name, bool check) override;
106
107 void
108 field(const char* key, bool check) override;
109
110 const BuilderPtr
111 endrecord() override;
112
113 const BuilderOptions&
114 options() const { return options_; }
115
116 const std::vector<BuilderPtr>& contents() const { return contents_; }
117
118 bool begun() { return begun_; }
119
120 int64_t nextindex() { return nextindex_; }
121
122 void
123 maybeupdate(int64_t i, const BuilderPtr builder);
124
125 private:
126 const BuilderOptions options_;
127 std::vector<BuilderPtr> contents_;
128 int64_t length_;
129 bool begun_;
130 int64_t nextindex_;
131 };
132}
133
134#endif // AWKWARD_TUPLEBUILDER_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::TupleBuilder
Builder node for accumulated tuples.
Definition: TupleBuilder.h:18
awkward::TupleBuilder::nextindex
int64_t nextindex()
Definition: TupleBuilder.h:120
awkward::TupleBuilder::real
const BuilderPtr real(double x) override
Adds a real value x to the accumulated data.
awkward::TupleBuilder::endlist
const BuilderPtr endlist() override
Ends a nested list.
awkward::TupleBuilder::fromempty
static const BuilderPtr fromempty(const BuilderOptions &options)
Create an empty TupleBuilder.
awkward::TupleBuilder::timedelta
const BuilderPtr timedelta(int64_t x, const std::string &unit) override
Adds a timedelta value x to the accumulated data.
awkward::TupleBuilder::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::TupleBuilder::complex
const BuilderPtr complex(std::complex< double > x) override
Adds a complex value x to the accumulated data.
awkward::TupleBuilder::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::TupleBuilder::length
int64_t length() const override
Current length of the accumulated array.
awkward::TupleBuilder::endrecord
const BuilderPtr endrecord() override
Ends a record.
awkward::TupleBuilder::numfields
int64_t numfields() const
Current number of fields.
awkward::TupleBuilder::active
bool active() const override
If true, this node has started but has not finished a multi-step command (e.g. beginX ....
awkward::TupleBuilder::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::TupleBuilder::options
const BuilderOptions & options() const
Definition: TupleBuilder.h:114
awkward::TupleBuilder::maybeupdate
void maybeupdate(int64_t i, const BuilderPtr builder)
awkward::TupleBuilder::integer
const BuilderPtr integer(int64_t x) override
Adds an integer value x to the accumulated data.
awkward::TupleBuilder::begun
bool begun()
Definition: TupleBuilder.h:118
awkward::TupleBuilder::datetime
const BuilderPtr datetime(int64_t x, const std::string &unit) override
Adds a datetime value x to the accumulated data.
awkward::TupleBuilder::beginrecord
const BuilderPtr beginrecord(const char *name, bool check) override
Begins building a record with an optional name.
awkward::TupleBuilder::null
const BuilderPtr null() override
Adds a null value to the accumulated data.
awkward::TupleBuilder::contents
const std::vector< BuilderPtr > & contents() const
Definition: TupleBuilder.h:116
awkward::TupleBuilder::TupleBuilder
TupleBuilder(const BuilderOptions &options, const std::vector< BuilderPtr > &contents, int64_t length, bool begun, size_t nextindex)
Create a TupleBuilder from a full set of parameters.
awkward::TupleBuilder::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::TupleBuilder::beginlist
const BuilderPtr beginlist() override
Begins building a nested list.
awkward::TupleBuilder::boolean
const BuilderPtr boolean(bool x) override
Adds a boolean value x to the accumulated data.
awkward::TupleBuilder::begintuple
const BuilderPtr begintuple(int64_t numfields) override
Begins building a tuple with a fixed number of fields.
awkward::TupleBuilder::endtuple
const BuilderPtr endtuple() override
Ends a tuple.
awkward::TupleBuilder::classname
const std::string classname() const override
User-friendly name of this class: "TupleBuilder".
awkward::TupleBuilder::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